Esempio n. 1
0
    def test_authorization_action(self, mock_post, create_hash, get_current_host):
        """
        Play some posts that Vitepay might fire at us.
        """
        self.init_projects()
        order = OrderFactory.create()
        DonationFactory.create(amount=Money(2000, XOF), order=order)
        order_payment = OrderPaymentFactory.create(payment_method="vitepayOrangemoney", order=order)
        adapter = VitepayPaymentAdapter(order_payment)
        authorization_action = adapter.get_authorization_action()
        data = {
            u"api_key": u"123",
            u"hash": u"123123",
            u"redirect": 0,
            u"payment": {
                u"description": u"Thanks for your donation!",
                u"order_id": u"opc-{}".format(order_payment.id),
                u"decline_url": u"https://onepercentclub.com/orders/{}/failed".format(order_payment.order.id),
                u"p_type": u"orange_money",
                u"country_code": u"ML",
                u"language_code": u"fr",
                u"amount_100": 200000,
                u"cancel_url": u"https://onepercentclub.com/orders/{}/failed".format(order_payment.order.id),
                u"currency_code": u"XOF",
                u"callback_url": u"https://onepercentclub.com/payments_vitepay/status_update/",
                u"return_url": u"https://onepercentclub.com/orders/{}/success".format(order_payment.order.id),
            },
        }

        self.assertEqual(mock_post.call_args[0][0], "https://api.vitepay.com/v1/prod/payments")
        self.assertEqual(json.loads(mock_post.call_args[1]["data"]), data)
        self.assertEqual(mock_post.call_args[1]["headers"], {"Content-Type": "application/json"})

        self.assertEqual(authorization_action["url"], "https://vitepay.com/some-path-to-pay")
Esempio n. 2
0
    def test_authorization_action(self, mock_post, create_hash, get_current_host):
        """
        Play some posts that Vitepay might fire at us.
        """
        self.init_projects()
        order = OrderFactory.create()
        DonationFactory.create(amount=Money(2000, XOF), order=order)
        order_payment = OrderPaymentFactory.create(payment_method='vitepayOrangemoney', order=order)
        adapter = VitepayPaymentAdapter(order_payment)
        authorization_action = adapter.get_authorization_action()
        data = {
            u"api_key": u"123",
            u"hash": u"123123",
            u"redirect": 0,
            u"payment": {
                u"description": u"Thanks for your donation!",
                u"order_id": u"opc-{}".format(order_payment.id),
                u"decline_url": u"https://onepercentclub.com/orders/{}/failed".format(order_payment.order.id),
                u"p_type": u"orange_money",
                u"country_code": u"ML",
                u"language_code": u"fr",
                u"amount_100": 200000,
                u"cancel_url": u"https://onepercentclub.com/orders/{}/failed".format(order_payment.order.id),
                u"currency_code": u"XOF",
                u"callback_url": u"https://onepercentclub.com/payments_vitepay/status_update/",
                u"return_url": u"https://onepercentclub.com/orders/{}/success".format(order_payment.order.id)
            }
        }

        self.assertEqual(mock_post.call_args[0][0], 'https://api.vitepay.com/v1/prod/payments')
        self.assertEqual(json.loads(mock_post.call_args[1]['data']), data)
        self.assertEqual(mock_post.call_args[1]['headers'], {'Content-Type': 'application/json'})

        self.assertEqual(authorization_action['url'], 'https://vitepay.com/some-path-to-pay')
Esempio n. 3
0
 def test_create_payment_with_wrong_payment_method(self, get_current_host):
     with self.assertRaises(PaymentException):
         order_payment = OrderPaymentFactory.create(payment_method="docdataIdeal", amount=Money(3500, XOF))
         adapter = VitepayPaymentAdapter(order_payment)
         adapter.create_payment()
Esempio n. 4
0
 def test_create_payment_with_wrong_payment_method(self, get_current_host):
     with self.assertRaises(PaymentException):
         order_payment = OrderPaymentFactory.create(payment_method='docdataIdeal',
                                                    amount=Money(3500, XOF))
         adapter = VitepayPaymentAdapter(order_payment)
         adapter.create_payment()
Esempio n. 5
0
 def test_create_payment_with_wrong_currency(self, get_current_host):
     with self.assertRaises(PaymentException):
         order_payment = OrderPaymentFactory.create(payment_method='vitepayOrangemoney',
                                                    amount=Money(200, EUR))
         VitepayPaymentAdapter(order_payment)
Esempio n. 6
0
 def test_create_payment(self, get_current_host):
     order = OrderFactory.create()
     DonationFactory.create(amount=Money(2000, XOF), order=order)
     order_payment = OrderPaymentFactory.create(payment_method='vitepayOrangemoney', order=order)
     adapter = VitepayPaymentAdapter(order_payment)
     self.assertEqual(adapter.payment.amount_100, 200000)