本文整理汇总了Python中bluebottle.test.factory_models.payments.OrderPaymentFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python OrderPaymentFactory.create方法的具体用法?Python OrderPaymentFactory.create怎么用?Python OrderPaymentFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bluebottle.test.factory_models.payments.OrderPaymentFactory
的用法示例。
在下文中一共展示了OrderPaymentFactory.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
def setUp(self):
super(PaymentMockTests, self).setUp()
self.init_projects()
self.order_payment = OrderPaymentFactory.create(status=StatusDefinition.CREATED, amount=100, payment_method='mock')
self.user1 = BlueBottleUserFactory.create()
self.user1_token = "JWT {0}".format(self.user1.get_jwt_token())
示例2: test_normal_userdata
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
def test_normal_userdata(self, mock_client_create):
mock_client_create.return_value = {'order_key': 123, 'order_id': 123}
mock_create_payment = patch.object(DocdataPaymentAdapter, 'create_payment', fake_create_payment)
user = BlueBottleUserFactory()
holland = CountryFactory(name='Netherlands', alpha2_code='NL')
address = BlueBottleAddressFactory(user=user, line1='Dam 1a', line2='Bovenste bel', city='Amsterdam',
postal_code='1000AA', country=holland)
self.order = OrderFactory.create(user=user)
self.order_payment = OrderPaymentFactory.create(order=self.order, payment_method='docdataIdeal',
integration_data={'default_pm': 'ideal'})
self.service = PaymentService(order_payment=self.order_payment)
user_data = self.service.adapter.get_user_data()
self.assertEqual(user_data['id'], user.id)
self.assertEqual(user_data['first_name'], user.first_name)
self.assertEqual(user_data['last_name'], user.last_name)
self.assertEqual(user_data['email'], user.email)
self.assertEqual(user_data['street'], 'Dam')
self.assertEqual(user_data['house_number'], '1a')
self.assertEqual(user_data['postal_code'], '1000AA')
self.assertEqual(user_data['city'], 'Amsterdam')
self.assertEqual(user_data['country'], 'NL')
self.assertEqual(user_data['company'], '')
self.assertEqual(user_data['kvk_number'], '')
self.assertEqual(user_data['vat_number'], '')
self.assertEqual(user_data['house_number_addition'], '')
self.assertEqual(user_data['state'], '')
示例3: test_no_payment_method_change
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
def test_no_payment_method_change(self, mock_fetch_status,
mock_transaction):
self.assertEquals(PaymentLogEntry.objects.count(), 1)
# Mock the status check with docdata
mock_fetch_status.return_value = self.create_status_response(
'AUTHORIZED')
order = OrderFactory.create()
order_payment = OrderPaymentFactory.create(
order=order, payment_method='docdataCreditcard')
docdata_payment = DocdataPaymentFactory.create(
order_payment=order_payment,
default_pm='mastercard',
payment_cluster_id='1234',
total_gross_amount=100)
DocdataTransactionFactory.create(payment=docdata_payment,
payment_method='VISA')
c = Client()
merchant_order_id = "{0}-1".format(order_payment.id)
resp = c.get(reverse('docdata-payment-status-update',
kwargs={'merchant_order_id': merchant_order_id}))
self.assertEqual(resp.status_code, 200)
self.assertEqual(resp.content, 'success')
# Reload the order payment
order_payment = OrderPayment.objects.get(id=order_payment.id)
self.assertEqual(order_payment.payment_method, 'docdataCreditcard')
示例4: test_incomplete_userdata
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
def test_incomplete_userdata(self, mock_client):
# Mock response to creating the payment at docdata
instance = mock_client.return_value
instance.create.return_value = {'order_key': 123, 'order_id': 123}
patch.object(DocdataPaymentAdapter, 'create_payment',
fake_create_payment)
user = BlueBottleUserFactory()
self.order = OrderFactory.create(user=user)
self.order_payment = OrderPaymentFactory.create(
order=self.order, payment_method='docdataIdeal',
integration_data={'default_pm': 'ideal'})
self.service = PaymentService(order_payment=self.order_payment)
user_data = self.service.adapter.get_user_data()
self.assertEqual(user_data['id'], user.id)
self.assertEqual(user_data['first_name'], user.first_name)
self.assertEqual(user_data['last_name'], user.last_name)
self.assertEqual(user_data['email'], user.email)
self.assertEqual(user_data['street'], 'Unknown')
self.assertEqual(user_data['house_number'], 'Unknown')
self.assertEqual(user_data['postal_code'], 'Unknown')
self.assertEqual(user_data['city'], 'Unknown')
self.assertEqual(user_data['country'], 'NL')
self.assertEqual(user_data['company'], '')
self.assertEqual(user_data['kvk_number'], '')
self.assertEqual(user_data['vat_number'], '')
self.assertEqual(user_data['house_number_addition'], '')
self.assertEqual(user_data['state'], '')
示例5: test_authorization_action
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
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")
示例6: setUp
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
def setUp(self):
super(PaymentFeeTestCase, self).setUp()
self.init_projects()
self.order = OrderFactory.create()
self.donation = DonationFactory(amount=60, order=self.order)
self.order_payment = OrderPaymentFactory.create(order=self.order)
示例7: setUp
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
def setUp(self):
super(PaymentsMockTestCase, self).setUp()
self.init_projects()
self.order = OrderFactory.create(total=35)
self.order_payment = OrderPaymentFactory.create(order=self.order, payment_method='mock')
self.service = PaymentService(order_payment=self.order_payment)
示例8: setUp
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
def setUp(self):
self.order = OrderFactory.create(total=Money(200, 'EUR'))
self.order_payment = OrderPaymentFactory.create(
payment_method='docdata',
order=self.order
)
PaymentFactory.create(order_payment=self.order_payment)
self.adapter = BasePaymentAdapter(self.order_payment)
示例9: setUp
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
def setUp(self, mock_client_create):
super(TestPaymentLogger, self).setUp()
mock_client_create.return_value = {'order_key': 123, 'order_id': 123}
self.order = OrderFactory.create(total=35)
self.order_payment = OrderPaymentFactory.create(payment_method='docdataIdeal', order=self.order,
integration_data={'default_pm': 'ideal'})
self.service = PaymentService(self.order_payment)
示例10: test_no_success_payment_status_check
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
def test_no_success_payment_status_check(self, mock_check_payment_status):
self.order = OrderFactory.create(user=self.user1, total=15)
self.order_payment = OrderPaymentFactory.create(order=self.order,
payment_method='mock')
self.service = PaymentService(order_payment=self.order_payment)
self.client.get(reverse('manage-order-detail',
kwargs={'pk': self.order.id}),
token=self.user1_token)
self.assertEqual(mock_check_payment_status.called, True)
示例11: test_success_payment_status_check
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
def test_success_payment_status_check(self, mock_check_payment_status):
self.order = OrderFactory.create(user=self.user1, total=15,
status=StatusDefinition.SUCCESS)
self.order_payment = OrderPaymentFactory.create(order=self.order,
payment_method='mock',
status=StatusDefinition.AUTHORIZED)
self.client.get(reverse('manage-order-detail',
kwargs={'pk': self.order.id}),
token=self.user1_token)
self.assertEqual(mock_check_payment_status.called, False)
示例12: setUp
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
def setUp(self, mock_client_create):
# Mock response to creating the payment at docdata
mock_client_create.return_value = {'order_key': 123, 'order_id': 123}
# Mock create payment
mock_create_payment = patch.object(DocdataPaymentAdapter, 'create_payment', fake_create_payment)
self.order = OrderFactory.create()
self.order_payment = OrderPaymentFactory.create(order=self.order, payment_method='docdataIdeal',
integration_data={'default_pm': 'ideal'})
self.service = PaymentService(order_payment=self.order_payment)
示例13: test_direct_debit_wrong_pm
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
def test_direct_debit_wrong_pm(self):
"""
Test that a direct debit payments default_pm will be forced
to 'sepa_direct_debit'.
"""
order_payment = OrderPaymentFactory.create(amount=1000)
docdata_payment = DocdataDirectdebitPaymentFactory.create(
order_payment=order_payment,
default_pm='ideal',
total_gross_amount=1000
)
self.assertEqual(docdata_payment.default_pm, 'sepa_direct_debit')
示例14: test_order_status_cannot_pledge
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
def test_order_status_cannot_pledge(self):
"""
Normal user can not pledge
"""
user = BlueBottleUserFactory()
order = OrderFactory.create(user=user)
order_payment = OrderPaymentFactory.create(
order=order, user=user, payment_method='pledgeStandard'
)
with self.assertRaises(PaymentException):
self.service = PaymentService(order_payment=order_payment)
示例15: test_get_fee_absolute
# 需要导入模块: from bluebottle.test.factory_models.payments import OrderPaymentFactory [as 别名]
# 或者: from bluebottle.test.factory_models.payments.OrderPaymentFactory import create [as 别名]
def test_get_fee_absolute(self):
"""
Test that the correct fee is returned given the defined percentage. In this test case the
amount is 100 and the fee percentage is 1.5%, so the result should be 100 * 0.015.
"""
order_payment = OrderPaymentFactory.create(amount=1000)
docdata_payment = DocdataPaymentFactory.create(order_payment=order_payment,
default_pm='ideal',
total_gross_amount=1000)
order_payment.amount = 100
fee_total = docdata_payment.get_fee()
self.assertEqual(fee_total, 100 * 0.015)