def test_amount_without_subscriptions_success(self): self.base_processor.invoice.add_offer(self.subscription_offer) price = Price() price.offer = self.subscription_offer price.cost = 25 price.start_date = timezone.now() - timedelta(days=1) price.save() self.assertNotEquals( self.existing_invoice.total, self.base_processor.amount_without_subscriptions())
def test_is_card_valid_success(self): self.existing_invoice.add_offer(self.subscription_offer) price = Price() price.offer = self.subscription_offer price.cost = randrange(1, 1000) price.start_date = timezone.now() - timedelta(days=1) price.save() self.existing_invoice.save() self.processor = AuthorizeNetProcessor(self.existing_invoice) self.processor.set_billing_address_form_data( self.form_data.get('billing_address_form'), BillingAddressForm) self.processor.set_payment_info_form_data( self.form_data.get('credit_card_form'), CreditCardForm) self.processor.is_data_valid() self.processor.create_payment_model() self.assertTrue(self.processor.is_card_valid())
def test_create_subscription_success(self): """ Test a successfull subscription enrollment. """ self.existing_invoice.add_offer(self.subscription_offer) price = Price() price.offer = self.subscription_offer price.cost = randrange(1,1000) price.start_date = timezone.now() - timedelta(days=1) price.save() self.existing_invoice.save() self.processor = AuthorizeNetProcessor(self.existing_invoice) self.processor.get_billing_address_form_data(self.form_data.get('billing_address_form'), BillingAddressForm) self.processor.get_payment_info_form_data(self.form_data.get('credit_card_form'), CreditCardForm) self.processor.authorize_payment() # print(self.processor.transaction_message) self.assertTrue(self.processor.transaction_submitted) self.assertIn('subscriptionId', self.processor.transaction_response['raw'])
def test_create_subscription_success(self): """ Test a successfull subscription enrollment. """ self.existing_invoice.add_offer(self.subscription_offer) self.existing_invoice.add_offer(self.subscription_offer) price = Price() price.offer = self.subscription_offer price.cost = randrange(1, 1000) price.start_date = timezone.now() - timedelta(days=1) price.save() self.existing_invoice.save() self.processor = AuthorizeNetProcessor(self.existing_invoice) self.processor.get_billing_address_form_data( self.form_data.get('billing_address_form'), BillingAddressForm) self.processor.get_payment_info_form_data( self.form_data.get('credit_card_form'), CreditCardForm) subscription_list = self.existing_invoice.order_items.filter( offer__terms=TermType.SUBSCRIPTION) subscription = subscription_list[0] subscription.offer.name = "".join( [choice(ascii_letters) for i in range(0, 10)]) subscription.offer.save() self.processor.invoice.status = Invoice.InvoiceStatus.COMPLETE self.processor.payment = Payment.objects.get(pk=1) self.processor.create_receipts() self.processor.subscription_payment(subscription) # print(self.processor.transaction_message) self.assertTrue(self.processor.transaction_submitted) self.assertIsNotNone( self.processor.transaction_response.subscriptionId)