本文整理汇总了Python中getpaid_test_project.orders.models.Order.save方法的典型用法代码示例。如果您正苦于以下问题:Python Order.save方法的具体用法?Python Order.save怎么用?Python Order.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类getpaid_test_project.orders.models.Order
的用法示例。
在下文中一共展示了Order.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_payment_get_paid
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def test_payment_get_paid(self, mock_Request):
Payment = apps.get_model('getpaid', 'Payment')
order = Order(name='Test EUR order', total='123.45', currency='PLN')
order.save()
payment = Payment(pk=99, order=order, amount=order.total, currency=order.currency,
backend='getpaid.backends.payu')
payment.save(force_insert=True)
payment = Payment.objects.get(
pk=99) # this line is because django bug https://code.djangoproject.com/ticket/5903
processor = getpaid.backends.payu.PaymentProcessor(payment)
processor.get_payment_status(u'99:1342616247.41')
self.assertEqual(payment.status, u'paid')
self.assertNotEqual(payment.paid_on, None)
self.assertNotEqual(payment.amount_paid, Decimal('0'))
url = 'https://www.platnosci.pl/paygw/UTF/Payment/get/txt'
callargs = mock_Request.call_args_list
self.assertEqual(url, callargs[0][0][0])
if six.PY3:
self.assertIsInstance(callargs[0][0][1], bytes)
self.assertTrue(b'pos_id=123456789' in callargs[0][0][1])
self.assertTrue(b'session_id=99%3A1342616247.41' in callargs[0][0][1])
else:
self.assertIsInstance(callargs[0][0][1], str)
self.assertTrue('pos_id=123456789' in callargs[0][0][1])
self.assertTrue('session_id=99%3A1342616247.41' in callargs[0][0][1])
示例2: test_failure_order_additional_validation
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def test_failure_order_additional_validation(self):
"""
Tests if HTTP304 when order additional validation signal raises
ValidationError exception.
"""
def custom_validation_listener(sender=None, request=None, order=None,
backend=None, **kwargs):
raise ValidationError("BOOM!")
suid = 'test-order_additional_validation'
signals.order_additional_validation.connect(custom_validation_listener,
dispatch_uid=suid)
order = Order(name='Test order custom validation',
total=100,
currency='PLN')
order.save()
try:
url = reverse('getpaid:new-payment', kwargs={'currency': 'PLN'})
data = {'order': order.pk, 'backend': 'getpaid.backends.payu'}
response = self.client.post(url, data)
self.assertEqual(response.status_code, 403)
finally:
signals.order_additional_validation.disconnect(dispatch_uid=suid)
示例3: test_online_payment_failure
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def test_online_payment_failure(self):
Payment = get_model('getpaid', 'Payment')
order = Order(name='Test EUR order', total='123.45', currency='RUB')
order.save()
payment = Payment(order=order, amount=order.total, currency=order.currency, backend='getpaid.backends.platron')
payment.save(force_insert=True)
self.assertEqual('OK', getpaid.backends.platron.PaymentProcessor.online(self.xml_result % (payment.pk, '0', '84c11ec90ac8a6f637e3adfa912bab60'), 'result.php'))
payment = Payment.objects.get(pk=payment.pk)
self.assertEqual(payment.status, 'failed')
示例4: test_online_payment_failure
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def test_online_payment_failure(self):
Payment = get_model('getpaid', 'Payment')
order = Order(name='Test EUR order', total='123.45', currency='PLN')
order.save()
payment = Payment(order=order, amount=order.total, currency=order.currency, backend='getpaid.backends.payu')
payment.save(force_insert=True)
self.assertEqual('TRUE', getpaid.backends.transferuj.PaymentProcessor.online('195.149.229.109', '1234', '1', '', payment.pk, '123.45', '23.45', '', False, 0, '', '21b028c2dbdcb9ca272d1cc67ed0574e'))
payment = Payment.objects.get(pk=payment.pk)
self.assertEqual(payment.status, 'failed')
示例5: test_payment_get_failed
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def test_payment_get_failed(self):
Payment = get_model('getpaid', 'Payment')
order = Order(name='Test EUR order', total='123.45', currency='PLN')
order.save()
payment = Payment(pk=98, order=order, amount=order.total, currency=order.currency, backend='getpaid.backends.payu')
payment.save(force_insert=True)
payment = Payment.objects.get(pk=98) # this line is because django bug https://code.djangoproject.com/ticket/5903
processor = getpaid.backends.payu.PaymentProcessor(payment)
processor.get_payment_status('98:1342616247.41')
self.assertEqual(payment.status, 'failed')
self.assertEqual(payment.paid_on, None)
self.assertEqual(payment.amount_paid, Decimal('0'))
示例6: setUp
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def setUp(self):
self.client = Client()
Payment = apps.get_model('getpaid', 'Payment')
order = Order(name='Test DKK order', total='123.45', currency='DKK')
order.save()
payment = Payment(order=order,
amount=order.total,
currency=order.currency,
backend='getpaid.backends.epaydk')
payment.save()
self.test_payment = Payment.objects.get(pk=payment.id)
示例7: test_failure_create_payment_eur
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def test_failure_create_payment_eur(self):
"""
Tests if payment fails when wrong currency for backend.
PayU accepts only PLN currency payments.
"""
order = Order(name='Test EUR order', total=100, currency='EUR')
order.save()
response = self.client.post(reverse('getpaid-new-payment',
kwargs={'currency': 'EUR'}),
{'order': order.pk,
'backend': 'getpaid.backends.payu'})
self.assertEqual(response.status_code, 403)
示例8: test_get_payment_status_failed
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def test_get_payment_status_failed(self):
Payment = get_model('getpaid', 'Payment')
order = Order(name='Test PLN order', total='123.45', currency='PLN')
order.save()
payment = Payment(pk=192, order=order, amount=order.total, currency=order.currency, backend='getpaid.backends.przelewy24')
payment.save(force_insert=True)
payment = Payment.objects.get(pk=192)
processor = getpaid.backends.przelewy24.PaymentProcessor(payment)
processor.get_payment_status(p24_session_id='192:xxx:xxx', p24_order_id='192:external', p24_kwota='12245')
self.assertEqual(payment.status, 'failed')
self.assertEqual(payment.paid_on, None)
self.assertEqual(payment.amount_paid, Decimal('0.0'))
示例9: setUp
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def setUp(self):
self.client = Client()
Payment = get_model('getpaid', 'Payment')
order = Order(name='Test DKK order', total='123.45', currency='BRL')
order.save()
payment = Payment(
external_id="REF1234",
order=order,
amount=order.total,
currency=order.currency,
backend='getpaid.backends.pagseguro')
payment.save()
self.test_payment = Payment.objects.get(pk=payment.id)
示例10: test_online_payment_ok
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def test_online_payment_ok(self):
Payment = apps.get_model('getpaid', 'Payment')
order = Order(name='Test EUR order', total='123.45', currency='PLN')
order.save()
payment = Payment(order=order, amount=order.total, currency=order.currency, backend='getpaid.backends.payu')
payment.save(force_insert=True)
self.assertEqual('TRUE', PaymentProcessor.online('195.149.229.109', '1234', '1', '',
payment.pk, '123.45', '123.45', '',
'TRUE', 0, '',
'21b028c2dbdcb9ca272d1cc67ed0574e'))
payment = Payment.objects.get(pk=payment.pk)
self.assertEqual(payment.status, 'paid')
self.assertNotEqual(payment.paid_on, None)
self.assertEqual(payment.amount_paid, Decimal('123.45'))
示例11: test_get_payment_status_failed
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def test_get_payment_status_failed(self):
Payment = apps.get_model("getpaid", "Payment")
order = Order(name="Test PLN order", total="123.45", currency="PLN")
order.save()
payment = Payment(
pk=192, order=order, amount=order.total, currency=order.currency, backend="getpaid.backends.przelewy24"
)
payment.save(force_insert=True)
payment = Payment.objects.get(pk=192)
processor = getpaid.backends.przelewy24.PaymentProcessor(payment)
processor.get_payment_status(p24_session_id=u"192:xxx:xxx", p24_order_id=u"192:external", p24_kwota=u"12245")
self.assertEqual(payment.status, u"failed")
self.assertEqual(payment.paid_on, None)
self.assertEqual(payment.amount_paid, Decimal("0.0"))
示例12: test_success_init_payment
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def test_success_init_payment(self):
Payment = get_model('getpaid', 'Payment')
order = Order(name='Test EUR order', total='123.45', currency='RUB')
order.save()
payment = Payment(pk=99, order=order, amount=order.total, currency=order.currency, backend='getpaid.backends.platron')
payment.save(force_insert=True)
payment = Payment.objects.get(pk=99)
processor = getpaid.backends.platron.PaymentProcessor(payment)
fake_request = RequestFactory()
ip = {'REMOTE_ADDR': '123.123.123.123'}
setattr(fake_request, 'META', ip)
url, method, params = processor.get_gateway_url(fake_request)
self.assertEqual(url, 'https://www.platron.ru/payment_params.php?customer=ccaa41a4f425d124a23c3a53a3140bdc15826')
示例13: test_fail_init_payment
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def test_fail_init_payment(self):
Payment = get_model('getpaid', 'Payment')
order = Order(name='Test EUR order', total='123.45', currency='RUB')
order.save()
payment = Payment(pk=99, order=order, amount=order.total, currency=order.currency, backend='getpaid.backends.platron')
payment.save(force_insert=True)
payment = Payment.objects.get(pk=99)
processor = getpaid.backends.platron.PaymentProcessor(payment)
fake_request = RequestFactory()
ip = {'REMOTE_ADDR': '123.123.123.123'}
setattr(fake_request, 'META', ip)
setattr(fake_request, 'path', '/getpaid.backends.platron/failure/')
url, method, params = processor.get_gateway_url(fake_request)
self.assertEqual(url, '/getpaid.backends.platron/failure/?pg_error_code=101&pg_order_id=99&pg_error_description=Empty+merchant')
示例14: test_successful_create_payment_dummy_eur
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def test_successful_create_payment_dummy_eur(self):
"""
Tests if payment is successfully created
"""
order = Order(name='Test EUR order', total=100, currency='EUR')
order.save()
url = reverse('getpaid-new-payment', kwargs={'currency': 'EUR'})
data = {'order': order.pk, 'backend': 'getpaid.backends.dummy'}
response = self.client.post(url, data)
self.assertEqual(response.status_code, 302)
Payment = get_model('getpaid', 'Payment')
payment = Payment.objects.get(order=order.pk)
self.assertEqual(payment.backend, 'getpaid.backends.dummy')
self.assertEqual(payment.amount, order.total)
self.assertEqual(payment.currency, order.currency)
self.assertEqual(payment.status, 'in_progress')
self.assertEqual(payment.paid_on, None)
self.assertEqual(payment.amount_paid, 0)
示例15: test_successful_create_payment_payu_pln
# 需要导入模块: from getpaid_test_project.orders.models import Order [as 别名]
# 或者: from getpaid_test_project.orders.models.Order import save [as 别名]
def test_successful_create_payment_payu_pln(self):
"""
Tests if payment is successfully created
"""
order = Order(name='Test PLN order', total=100, currency='PLN')
order.save()
response = self.client.post(reverse('getpaid-new-payment', kwargs={'currency': 'PLN'}),
{'order': order.pk,
'backend': 'getpaid.backends.payu'}
)
self.assertEqual(response.status_code, 302)
Payment = apps.get_model('getpaid', 'Payment')
payment = Payment.objects.get(order=order.pk)
self.assertEqual(payment.backend, 'getpaid.backends.payu')
self.assertEqual(payment.amount, order.total)
self.assertEqual(payment.currency, order.currency)
self.assertEqual(payment.status, 'in_progress')
self.assertEqual(payment.paid_on, None)
self.assertEqual(payment.amount_paid, 0)