def test_authorization_action(self, get_current_host, create_hash): """ Play some posts that Vitepay might fire at us. """ self.init_projects() order = OrderFactory.create() DonationFactory.create(amount=Money(2000, NGN), order=order) order_payment = OrderPaymentFactory.create(payment_method='interswitchWebpay', order=order) adapter = InterswitchPaymentAdapter(order_payment) authorization_action = adapter.get_authorization_action() redirect_url = 'https://onepercentclub.com/payments_interswitch/payment_response/{0}'.format(order_payment.id) data = { 'hash': '123123', 'product_id': '1234', 'site_redirect_url': redirect_url, 'local_date_time': None, 'txn_ref': '-{0}'.format(order_payment.id), 'cust_name': None, 'currency': '566', 'amount': 200000, 'pay_item_name': None, 'cust_id': None, 'pay_item_id': '123', 'site_name': 'testserver', 'cust_id_desc': None, 'cust_name_desc': None } self.assertEqual(authorization_action['url'], 'https://stageserv.interswitchng.com/test_paydirect/pay') self.assertEqual(authorization_action['payload'], data)
def test_create_only_one_payment(self, get_current_host): self.init_projects() order = OrderFactory.create() DonationFactory.create(amount=Money(2000, NGN), order=order) order_payment = OrderPaymentFactory.create(payment_method='interswitchWebpay', order=order) InterswitchPaymentAdapter(order_payment) self.assertEqual(InterswitchPayment.objects.count(), 1) InterswitchPaymentAdapter(order_payment) self.assertEqual(InterswitchPayment.objects.count(), 1)
def test_create_payment(self, get_current_host): self.init_projects() order = OrderFactory.create() DonationFactory.create(amount=Money(2000, NGN), order=order) order_payment = OrderPaymentFactory.create(payment_method='interswitchWebpay', order=order) adapter = InterswitchPaymentAdapter(order_payment) self.assertEqual(adapter.payment.amount, 200000) # Check generated payload payload = adapter._get_payload() self.assertEqual(payload['product_id'], '1234') self.assertEqual(payload['amount'], 200000) tenant = connection.tenant self.assertEqual(payload['txn_ref'], '{0}-{1}'.format(tenant.name, order_payment.id))
def test_create_payment_with_wrong_payment_method(self, get_current_host): with self.assertRaises(ImproperlyConfigured): order_payment = OrderPaymentFactory.create(payment_method='docdataIdeal', amount=Money(3500, NGN)) InterswitchPaymentAdapter(order_payment)
def test_create_payment_with_wrong_currency(self, get_current_host): with self.assertRaises(ImproperlyConfigured): order_payment = OrderPaymentFactory.create(payment_method='interswitchWebpay', amount=Money(200, EUR)) InterswitchPaymentAdapter(order_payment)