Beispiel #1
0
 def test_create_payment_invalid_email_not_set(self):
     data = {
         'total': 13.37,
         'customer': {
             'name': 'foobar',
         },
     }
     globee_payment = GlobeePayment(payment_data=data)
     with self.assertRaises(ValidationError):
         globee_payment.create_request()
Beispiel #2
0
 def test_create_payment_invalid_key(self):
     data = {
         'total': 13.37,
         'customer': {
             'name': 'foobar',
             'email': '*****@*****.**'
         },
     }
     globee_payment = GlobeePayment(payment_data=data)
     self.assertTrue(globee_payment.check_required_fields())
     with self.assertRaises(ValidationError):
         globee_payment.create_request()
Beispiel #3
0
 def test_create_payment_invalid_urls(self):
     data = {
         'total': 13.37,
         'customer': {
             'email': '*****@*****.**'
         },
         'success_url': 'invalid-url',
         'cancel_url': 'invalid-url',
         'ipn_url': 'invalid-url',
     }
     globee_payment = GlobeePayment(payment_data=data)
     self.assertTrue(globee_payment.check_required_fields())
     with self.assertRaises(ValidationError):
         globee_payment.create_request()
Beispiel #4
0
 def test_update_payment_valid(self):
     data = {
         'total': 13.37,
         'currency': 'EUR',
         'customer': {
             'name': 'foobar',
             'email': '*****@*****.**'
         },
     }
     globee_payment = GlobeePayment(payment_data=data)
     self.assertTrue(globee_payment.check_required_fields())
     self.assertIn("https://test.globee.com/",
                   globee_payment.create_request())
     custom_payment_id = "NEWID"
     custom_store_reference = "NEWSTOREREF"
     updated_data = {
         "custom_payment_id": custom_payment_id,
         "custom_store_reference": custom_store_reference,
         'customer': {
             'email': '*****@*****.**'
         },
     }
     globee_payment.payment_data = updated_data
     response = globee_payment.update_payment_request()
     self.assertEqual(response['id'], globee_payment.payment_id)
     self.assertEqual(response['custom_payment_id'], custom_payment_id)
     self.assertEqual(response['custom_store_reference'],
                      custom_store_reference)
Beispiel #5
0
 def test_create_payment_valid(self):
     data = {
         'total': 13.37,
         'currency': 'EUR',
         'customer': {
             'name': 'foobar',
             'email': '*****@*****.**'
         },
     }
     globee_payment = GlobeePayment(payment_data=data)
     self.assertTrue(globee_payment.check_required_fields())
     self.assertIn("https://test.globee.com/",
                   globee_payment.create_request())
     self.assertIn("https://test.globee.com/",
                   globee_payment.get_payment_url())
Beispiel #6
0
 def test_get_payment_details_for_currency_valid(self):
     data = {
         'total': 13.37,
         'currency': 'EUR',
         'customer': {
             'name': 'foobar',
             'email': '*****@*****.**'
         },
     }
     globee_payment = GlobeePayment(payment_data=data)
     self.assertTrue(globee_payment.check_required_fields())
     self.assertIn("https://test.globee.com/",
                   globee_payment.create_request())
     response = globee_payment.get_payment_currency_details("BTC")
     self.assertIsInstance(response, dict)
Beispiel #7
0
 def test_update_payment_invalid_email_not_set(self):
     data = {
         'total': 13.37,
         'currency': 'EUR',
         'customer': {
             'name': 'foobar',
             'email': '*****@*****.**'
         },
     }
     globee_payment = GlobeePayment(payment_data=data)
     self.assertTrue(globee_payment.check_required_fields())
     self.assertIn("https://test.globee.com/",
                   globee_payment.create_request())
     custom_payment_id = "NEWID"
     custom_store_reference = "NEWSTOREREF"
     updated_data = {
         "custom_payment_id": custom_payment_id,
         "custom_store_reference": custom_store_reference,
     }
     globee_payment.payment_data = updated_data
     with self.assertRaises(ValidationError):
         globee_payment.update_payment_request()
Beispiel #8
0
 def test_create_payment_invalid_empty_data(self):
     globee_payment = GlobeePayment()
     with self.assertRaises(ValidationError):
         globee_payment.check_required_fields()
     with self.assertRaises(ValidationError):
         globee_payment.create_request()