本文整理汇总了Python中saleor.payment.utils.create_payment_information函数的典型用法代码示例。如果您正苦于以下问题:Python create_payment_information函数的具体用法?Python create_payment_information怎么用?Python create_payment_information使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_payment_information函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_charge
def test_charge(
mocked_gateway, razorpay_payment, razorpay_success_response, gateway_config
):
# Data to be passed
payment_token = "123"
# Mock the gateway response to a success response
mocked_gateway.return_value.payment.capture.return_value = razorpay_success_response
payment_info = create_payment_information(
razorpay_payment, payment_token=payment_token, amount=TRANSACTION_AMOUNT
)
# Attempt charging
response = capture(payment_info, gateway_config)
# Ensure the was no error returned
assert not response.error
assert response.is_success
assert response.kind == TransactionKind.CAPTURE
assert response.amount == TRANSACTION_AMOUNT
assert response.currency == razorpay_success_response["currency"]
assert response.raw_response == razorpay_success_response
assert response.transaction_id == razorpay_success_response["id"]
开发者ID:mirumee,项目名称:saleor,代码行数:26,代码来源:test_razorpay.py
示例2: test_charge
def test_charge(
mocked_gateway,
razorpay_payment,
razorpay_success_response,
gateway_params):
# Data to be passed
payment_token = '123'
# Mock the gateway response to a success response
mocked_gateway.return_value.payment.capture.return_value = (
razorpay_success_response)
payment_info = create_payment_information(
razorpay_payment, payment_token=payment_token,
amount=TRANSACTION_AMOUNT)
# Attempt charging
response = charge(payment_info, gateway_params)
# Ensure the was no error returned
assert not response['error']
assert response['is_success']
assert response['kind'] == TransactionKind.CHARGE
assert response['amount'] == TRANSACTION_AMOUNT
assert response['currency'] == razorpay_success_response['currency']
assert response['raw_response'] == razorpay_success_response
assert response['transaction_id'] == razorpay_success_response['id']
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:29,代码来源:test_razorpay.py
示例3: test_refund
def test_refund(
mocked_gateway,
charged_payment,
razorpay_success_response,
gateway_params):
# Mock the gateway response to a success response
mocked_gateway.return_value.payment.refund.return_value = (
razorpay_success_response)
payment_info = create_payment_information(
charged_payment, amount=TRANSACTION_AMOUNT)
# Attempt charging
response = refund(payment_info, gateway_params)
# Ensure the was no error returned
assert not response['error']
assert response['is_success']
assert response['kind'] == TransactionKind.REFUND
assert response['amount'] == TRANSACTION_AMOUNT
assert response['currency'] == razorpay_success_response['currency']
assert response['raw_response'] == razorpay_success_response
assert response['transaction_id'] == razorpay_success_response['id']
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:25,代码来源:test_razorpay.py
示例4: test_charge_invalid_request
def test_charge_invalid_request(
mocked_gateway, mocked_logger, razorpay_payment, gateway_config
):
# Data to be passed
payment_token = "123"
# Assign the side effect to the gateway's `capture()` method,
# that should trigger the expected error.
mocked_gateway.return_value.payment.capture.side_effect = BadRequestError()
payment_info = create_payment_information(
razorpay_payment, payment_token=payment_token, amount=TRANSACTION_AMOUNT
)
# Attempt charging
response = capture(payment_info, gateway_config)
# Ensure an error was returned
assert response.error == errors.INVALID_REQUEST
assert not response.is_success
# Ensure the response is correctly set
assert response.kind == TransactionKind.CAPTURE
assert response.transaction_id == payment_token
# Ensure the HTTP error was logged
assert mocked_logger.call_count == 1
开发者ID:mirumee,项目名称:saleor,代码行数:28,代码来源:test_razorpay.py
示例5: test_refund_invalid_data
def test_refund_invalid_data(
mocked_gateway,
mocked_logger,
charged_payment,
razorpay_success_response,
gateway_config,
):
# Assign the side effect to the gateway's `refund()` method,
# that should trigger the expected error.
mocked_gateway.return_value.payment.refund.side_effect = ServerError()
# Attempt charging
payment_info = create_payment_information(
charged_payment, amount=TRANSACTION_AMOUNT
)
response = refund(payment_info, gateway_config)
# Ensure a error was returned
assert response.error == errors.SERVER_ERROR
assert not response.is_success
# Ensure the transaction is correctly set
assert response.kind == TransactionKind.REFUND
# Ensure the HTTP error was logged
assert mocked_logger.call_count == 1
开发者ID:mirumee,项目名称:saleor,代码行数:27,代码来源:test_razorpay.py
示例6: transaction_data
def transaction_data(payment_dummy, gateway_response):
return {
'payment': payment_dummy,
'payment_information': create_payment_information(
payment_dummy, 'payment-token'),
'kind': TransactionKind.CAPTURE,
'gateway_response': gateway_response}
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:7,代码来源:test_payment.py
示例7: test_gateway_charge
def test_gateway_charge(
mock_get_payment_gateway, mock_handle_fully_paid_order, payment_txn_preauth,
gateway_params, transaction_token, dummy_response):
payment_token = transaction_token
txn = payment_txn_preauth.transactions.first()
payment = payment_txn_preauth
assert not payment.captured_amount
amount = payment.total
dummy_response['kind'] = TransactionKind.CHARGE
mock_charge = Mock(return_value=dummy_response)
mock_get_payment_gateway.return_value = (
Mock(charge=mock_charge), gateway_params)
payment_info = create_payment_information(payment, payment_token, amount)
gateway_charge(payment, payment_token, amount)
mock_get_payment_gateway.assert_called_once_with(payment.gateway)
mock_charge.assert_called_once_with(
payment_information=payment_info, connection_params=gateway_params)
payment.refresh_from_db()
assert payment.charge_status == ChargeStatus.FULLY_CHARGED
assert payment.captured_amount == payment.total
mock_handle_fully_paid_order.assert_called_once_with(payment.order)
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:25,代码来源:test_payment.py
示例8: test_authorize
def test_authorize(
mock_gateway, payment_dummy, braintree_success_response, gateway_config
):
payment = payment_dummy
mock_response = Mock(return_value=braintree_success_response)
mock_gateway.return_value = Mock(transaction=Mock(sale=mock_response))
payment_info = create_payment_information(payment, "auth-token")
response = authorize(payment_info, gateway_config)
assert not response.error
assert response.kind == TransactionKind.AUTH
assert response.amount == braintree_success_response.transaction.amount
assert response.currency == braintree_success_response.transaction.currency_iso_code
assert response.transaction_id == braintree_success_response.transaction.id
assert response.is_success == braintree_success_response.is_success
mock_response.assert_called_once_with(
{
"amount": str(payment.total),
"payment_method_nonce": "auth-token",
"options": {
"submit_for_settlement": CONFIRM_MANUALLY,
"three_d_secure": {"required": THREE_D_SECURE_REQUIRED},
},
**get_customer_data(payment_info),
}
)
开发者ID:mirumee,项目名称:saleor,代码行数:28,代码来源:test_braintree.py
示例9: test_authorize
def test_authorize(
mock_gateway, payment_dummy, braintree_success_response,
gateway_config):
payment = payment_dummy
mock_response = Mock(return_value=braintree_success_response)
mock_gateway.return_value = Mock(transaction=Mock(sale=mock_response))
payment_info = create_payment_information(payment, 'auth-token')
response = authorize(payment_info, gateway_config)
assert not response['error']
assert response['kind'] == TransactionKind.AUTH
assert response['amount'] == braintree_success_response.transaction.amount
assert response['currency'] == braintree_success_response.transaction.currency_iso_code
assert response['transaction_id'] == braintree_success_response.transaction.id
assert response['is_success'] == braintree_success_response.is_success
mock_response.assert_called_once_with({
'amount': str(payment.total),
'payment_method_nonce': 'auth-token',
'options': {
'submit_for_settlement': CONFIRM_MANUALLY,
'three_d_secure': {
'required': THREE_D_SECURE_REQUIRED}},
**get_customer_data(payment_info)})
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:25,代码来源:test_braintree.py
示例10: test_gateway_capture
def test_gateway_capture(
mock_get_payment_gateway,
mock_handle_fully_paid_order,
payment_txn_preauth,
gateway_config,
dummy_response,
):
payment = payment_txn_preauth
gateway_config.auto_capture = True
assert not payment.captured_amount
amount = payment.total
dummy_response.kind = TransactionKind.CAPTURE
mock_capture = Mock(return_value=dummy_response)
mock_get_payment_gateway.return_value = (Mock(capture=mock_capture), gateway_config)
payment_info = create_payment_information(payment, "", amount)
gateway_capture(payment, amount)
mock_capture.assert_called_once_with(
payment_information=payment_info, config=gateway_config
)
payment.refresh_from_db()
assert payment.charge_status == ChargeStatus.FULLY_CHARGED
assert payment.captured_amount == payment.total
mock_handle_fully_paid_order.assert_called_once_with(payment.order)
开发者ID:mirumee,项目名称:saleor,代码行数:27,代码来源:test_payment.py
示例11: test_get_payment_billing_fullname
def test_get_payment_billing_fullname(payment_dummy):
payment_info = create_payment_information(payment_dummy)
expected_fullname = "%s %s" % (
payment_dummy.billing_last_name,
payment_dummy.billing_first_name,
)
assert get_payment_billing_fullname(payment_info) == expected_fullname
开发者ID:mirumee,项目名称:saleor,代码行数:8,代码来源:test_stripe.py
示例12: test_widget_with_additional_attr
def test_widget_with_additional_attr(stripe_payment, gateway_config):
payment_info = create_payment_information(stripe_payment)
widget = StripeCheckoutWidget(
payment_info,
gateway_config.connection_params,
attrs={"data-custom": "custom-data"},
)
assert 'data-custom="custom-data"' in widget.render()
开发者ID:mirumee,项目名称:saleor,代码行数:9,代码来源:test_stripe.py
示例13: test_checkout_form
def test_checkout_form(razorpay_payment, gateway_params):
payment_info = create_payment_information(razorpay_payment)
form = create_form(
data={'razorpay_payment_id': '123'},
payment_information=payment_info,
connection_params=gateway_params)
assert isinstance(form, RazorPaymentForm)
assert form.is_valid()
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:9,代码来源:test_razorpay.py
示例14: test_payment_gateway_form_exists
def test_payment_gateway_form_exists(gateway_name, payment_dummy):
"""Test if for each payment gateway there's a corresponding
form for the old checkout.
An error will be raised if it's missing.
"""
payment_gateway, gateway_params = get_payment_gateway(gateway_name)
payment_info = create_payment_information(payment_dummy)
payment_gateway.create_form(None, payment_info, gateway_params)
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:9,代码来源:test_payment.py
示例15: test_braintree_payment_form_incorrect_amount
def test_braintree_payment_form_incorrect_amount(payment_dummy):
amount = Decimal('0.01')
data = {'amount': amount, 'payment_method_nonce': 'fake-nonce'}
assert amount != payment_dummy.total
payment_info = create_payment_information(payment_dummy)
form = BraintreePaymentForm(data=data, payment_information=payment_info)
assert not form.is_valid()
assert form.non_field_errors
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:9,代码来源:test_braintree.py
示例16: transaction_data
def transaction_data(payment_dummy, gateway_response):
return {
"payment": payment_dummy,
"payment_information": create_payment_information(
payment_dummy, "payment-token"
),
"kind": TransactionKind.CAPTURE,
"gateway_response": gateway_response,
}
开发者ID:mirumee,项目名称:saleor,代码行数:9,代码来源:test_payment.py
示例17: test_checkout_form
def test_checkout_form(razorpay_payment, gateway_config):
payment_info = create_payment_information(razorpay_payment)
form = create_form(
data={"razorpay_payment_id": "123"},
payment_information=payment_info,
connection_params=gateway_config.connection_params,
)
assert isinstance(form, RazorPaymentForm)
assert form.is_valid()
开发者ID:mirumee,项目名称:saleor,代码行数:10,代码来源:test_razorpay.py
示例18: test_widget_with_prefill_option
def test_widget_with_prefill_option(stripe_payment, gateway_config):
payment_info = create_payment_information(stripe_payment)
connection_params = gateway_config.connection_params
connection_params["prefill"] = True
widget = StripeCheckoutWidget(payment_info, connection_params)
assert 'data-email="[email protected]"' in widget.render()
connection_params["prefill"] = False
widget = StripeCheckoutWidget(payment_info, connection_params)
assert 'data-email="[email protected]"' not in widget.render()
开发者ID:mirumee,项目名称:saleor,代码行数:10,代码来源:test_stripe.py
示例19: test_widget_with_prefill_option
def test_widget_with_prefill_option(stripe_payment, gateway_params):
payment_info = create_payment_information(stripe_payment)
gateway_params['prefill'] = True
widget = StripeCheckoutWidget(payment_info, gateway_params)
assert 'data-email="[email protected]"' in widget.render()
gateway_params['prefill'] = False
widget = StripeCheckoutWidget(payment_info, gateway_params)
assert 'data-email="[email protected]"' not in widget.render()
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:10,代码来源:test_stripe.py
示例20: test_widget_with_remember_me_option
def test_widget_with_remember_me_option(stripe_payment, gateway_params):
payment_info = create_payment_information(stripe_payment)
gateway_params['remember_me'] = True
widget = StripeCheckoutWidget(payment_info, gateway_params)
assert 'data-allow-remember-me="true"' in widget.render()
gateway_params['remember_me'] = False
widget = StripeCheckoutWidget(payment_info, gateway_params)
assert 'data-allow-remember-me="false"' in widget.render()
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:10,代码来源:test_stripe.py
注:本文中的saleor.payment.utils.create_payment_information函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论