def test_view_payment_success(self):
        self.invoice.status = Invoice.InvoiceStatus.CHECKOUT
        self.invoice.save()
        Payment.objects.all().delete()
        form_data = {
            'billing_address_form': {
                'billing-name': 'Home',
                'billing-company': 'Whitemoon Dreams',
                'billing-country': 840,
                'billing-address_1': '221B Baker Street',
                'billing-address_2': '',
                'billing-locality': 'Marylebone',
                'billing-state': 'California',
                'billing-postal_code': '90292'
            },
            'credit_card_form': {
                'full_name': 'Bob Ross',
                'card_number': '5424000000000015',
                'expire_month': '12',
                'expire_year': '2030',
                'cvv_number': '900',
                'payment_type': '10'
            }
        }

        billing_address = BillingAddressForm(form_data['billing_address_form'])
        billing_address.is_bound = True
        billing_address.is_valid()
        payment_info = CreditCardForm(form_data['credit_card_form'])
        payment_info.is_bound = True
        payment_info.is_valid()

        session = self.client.session
        session['billing_address_form'] = {
            f'billing-{key}': value
            for key, value in billing_address.cleaned_data.items()
        }
        session['credit_card_form'] = payment_info.cleaned_data
        session.save()

        response = self.client.post(self.view_url)

        self.assertEquals(self.invoice.payments.all().count(),
                          Payment.objects.filter(invoice=self.invoice).count())
    def test_view_payment_success(self):
        Payment.objects.all().delete()
        form_data = { 
            'billing_address_form': 
                {'name':'Home','company':'Whitemoon Dreams','country':'581','address_1':'221B Baker Street','address_2':'','locality':'Marylebone','state':'California','postal_code':'90292'}, 
            'credit_card_form': 
                {'full_name':'Bob Ross','card_number':'5424000000000015','expire_month':'12','expire_year':'2030','cvv_number':'900','payment_type':'10'}
            }

        billing_address = BillingAddressForm(form_data['billing_address_form'])
        billing_address.is_bound = True
        billing_address.is_valid()
        payment_info = CreditCardForm(form_data['credit_card_form'])
        payment_info.is_bound = True
        payment_info.is_valid()

        session = self.client.session
        session['billing_address_form'] = billing_address.cleaned_data
        session['credit_card_form'] = payment_info.cleaned_data
        session.save()

        response = self.client.post(self.view_url)

        self.assertRedirects(response, reverse('vendor:purchase-summary', kwargs={'pk': 1}))