Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use extra payment context data when communicating with Stripe
Jakub Draganek8e8724db7492
diff --git a/saleor/payment/gateways/stripe_new/__init__.py b/saleor/payment/gateways/stripe_new/__init__.pyindex 066932c911..9dbfcb74b5 100644--- a/saleor/payment/gateways/stripe_new/__init__.py+++ b/saleor/payment/gateways/stripe_new/__init__.py@@ -16,6 +16,7 @@ from .utils import (get_amount_from_stripe,get_currency_for_stripe,get_currency_from_stripe,+ shipping_to_stripe_dict,)@@ -36,6 +37,11 @@ def authorize(stripe_amount = get_amount_for_stripe(payment_information.amount, currency)future_use = "off_session" if config.store_customer else "on_session"customer_id = PaymentData.customer_id if payment_information.reuse_source else None+ shipping = (+ shipping_to_stripe_dict(payment_information.shipping)+ if payment_information.shipping+ else None+ )try:intent = client.PaymentIntent.create(@@ -47,6 +53,7 @@ def authorize(capture_method=capture_method,setup_future_usage=future_use,customer=customer_id,+ shipping=shipping,)if config.store_customer and not customer_id:customer = client.Customer.create(payment_method=intent.payment_method)@@ -55,6 +62,7 @@ def authorize(response = _success_response(intent=intent, kind=kind, success=success, customer_id=customer_id)+ response = fill_card_details(intent, response)except stripe.error.StripeError as exc:response = _error_response(kind=kind, exc=exc, payment_info=payment_information)return response@@ -71,6 +79,7 @@ def capture(payment_information: PaymentData, config: GatewayConfig) -> GatewayRkind=TransactionKind.CAPTURE,success=capture.status in ("succeeded", "requires_action"),)+ response = fill_card_details(intent, response)except stripe.error.StripeError as exc:action_required = intent.status == "requires_action" if intent else Falseresponse = _error_response(@@ -219,3 +228,14 @@ def _success_response(raw_response=raw_response or intent,customer_id=customer_id,)+++def fill_card_details(intent: stripe.PaymentIntent, response: GatewayResponse):+ card = intent.charges["data"][-1]["payment_method_details"]["card"]+ response.card_info = CreditCardInfo(+ last_4=card["last4"],+ exp_year=card["exp_year"],+ exp_month=card["exp_month"],+ brand=card["brand"],+ )+ return responsediff --git a/saleor/payment/gateways/stripe_new/utils.py b/saleor/payment/gateways/stripe_new/utils.pyindex 03523d4f91..ca4a068629 100644--- a/saleor/payment/gateways/stripe_new/utils.py+++ b/saleor/payment/gateways/stripe_new/utils.py@@ -82,10 +82,14 @@ def get_payment_billing_fullname(payment_information: PaymentData) -> str:def shipping_to_stripe_dict(shipping: AddressData) -> Dict:return {- "line1": shipping.street_address_1,- "line2": shipping.street_address_2,- "city": shipping.city,- "state": shipping.country_area,- "postal_code": shipping.postal_code,- "country": dict(countries).get(shipping.country, ""),+ "name": shipping.first_name + " " + shipping.last_name,+ "phone": shipping.phone,+ "address": {+ "line1": shipping.street_address_1,+ "line2": shipping.street_address_2,+ "city": shipping.city,+ "state": shipping.country_area,+ "postal_code": shipping.postal_code,+ "country": dict(countries).get(shipping.country, ""),+ },}diff --git a/saleor/payment/interface.py b/saleor/payment/interface.pyindex de4d487683..0f49e6f0fb 100644--- a/saleor/payment/interface.py+++ b/saleor/payment/interface.py@@ -3,6 +3,17 @@ from decimal import Decimalfrom typing import Any, Dict, Optional+@dataclass+class CreditCardInfo:+ """Uniform way to represent Credit Card information."""++ last_4: str+ exp_year: int+ exp_month: int+ brand: Optional[str] = None+ name_on_card: Optional[str] = None++@dataclassclass GatewayResponse:"""Dataclass for storing gateway response.@@ -19,6 +30,7 @@ class GatewayResponse:transaction_id: strerror: Optional[str]customer_id: Optional[str] = None+ card_info: Optional[CreditCardInfo] = Noneraw_response: Optional[Dict[str, str]] = None@@ -81,16 +93,6 @@ class GatewayConfig:store_customer: bool = False-@dataclass-class CreditCardInfo:- """Uniform way to represent Credit Card information."""-- last_4: str- exp_year: int- exp_month: int- name_on_card: Optional[str] = None--@dataclassclass CustomerSource:"""Dataclass for storing information about stored payment sources in gateways."""diff --git a/tests/gateway/stripe/cassettes/test_authorize.yaml b/tests/gateway/stripe/cassettes/test_authorize.yamlindex 3b964be893..bb4b0283c4 100644--- a/tests/gateway/stripe/cassettes/test_authorize.yaml+++ b/tests/gateway/stripe/cassettes/test_authorize.yaml@@ -1,6 +1,6 @@interactions:- request:- body: payment_method=pm_card_pl&amount=4242¤cy=usd&confirmation_method=manual&confirm=True+ body: payment_method=pm_card_pl&amount=4242¤cy=usd&confirmation_method=manual&confirm=True&capture_method=automatic&setup_future_usage=on_session&shipping[name]=John+Doe&shipping[phone]=%2B48713988102&shipping[address][line1]=T%C4%99czowa+7&shipping[address][line2]=&shipping[address][city]=WROC%C5%81AW&shipping[address][state]=&shipping[address][postal_code]=53-601&shipping[address][country]=Polandheaders:Accept:- '*/*'@@ -9,11 +9,11 @@ interactions:Connection:- keep-aliveContent-Length:- - '90'+ - '401'Content-Type:- application/x-www-form-urlencodedIdempotency-Key:- - 86a2df12-11ff-478f-b6ab-86c6a3d7856b+ - bd0e72e0-c36e-4a18-8c55-dde0b2f7b61dUser-Agent:- Stripe/v1 PythonBindings/2.33.0X-Stripe-Client-User-Agent:@@ -25,21 +25,21 @@ interactions:uri: https://api.stripe.com/v1/payment_intentsresponse:body:- string: "{\n \"id\": \"pi_1F4pVYIUmJaD6OqvP2f7TJJs\",\n \"object\": \"payment_intent\"\+ string: "{\n \"id\": \"pi_1F70K4IUmJaD6OqvfXkgsCB9\",\n \"object\": \"payment_intent\"\,\n \"amount\": 4242,\n \"amount_capturable\": 0,\n \"amount_received\"\: 4242,\n \"application\": null,\n \"application_fee_amount\": null,\n \\ \"canceled_at\": null,\n \"cancellation_reason\": null,\n \"capture_method\"\: \"automatic\",\n \"charges\": {\n \"object\": \"list\",\n \"data\"\- : [\n {\n \"id\": \"ch_1F4pVYIUmJaD6OqvaIgZm1nV\",\n \"\+ : [\n {\n \"id\": \"ch_1F70K4IUmJaD6Oqv2JSKXPjK\",\n \"\object\": \"charge\",\n \"amount\": 4242,\n \"amount_refunded\"\: 0,\n \"application\": null,\n \"application_fee\": null,\n\\ \"application_fee_amount\": null,\n \"balance_transaction\"\- : \"txn_1F4pVYIUmJaD6OqvPp8FXmy5\",\n \"billing_details\": {\n \+ : \"txn_1F70K4IUmJaD6OqvMZN2Ac5d\",\n \"billing_details\": {\n \\ \"address\": {\n \"city\": null,\n \"country\"\: null,\n \"line1\": null,\n \"line2\": null,\n \\ \"postal_code\": null,\n \"state\": null\n },\n\\ \"email\": null,\n \"name\": null,\n \"phone\"\- : null\n },\n \"captured\": true,\n \"created\": 1565185732,\n\+ : null\n },\n \"captured\": true,\n \"created\": 1565703960,\n\\ \"currency\": \"usd\",\n \"customer\": null,\n \"description\"\: null,\n \"destination\": null,\n \"dispute\": null,\n \\ \"failure_code\": null,\n \"failure_message\": null,\n \@@ -47,10 +47,10 @@ interactions:livemode\": false,\n \"metadata\": {\n },\n \"on_behalf_of\"\: null,\n \"order\": null,\n \"outcome\": {\n \"network_status\"\: \"approved_by_network\",\n \"reason\": null,\n \"risk_level\"\- : \"normal\",\n \"risk_score\": 32,\n \"seller_message\"\+ : \"normal\",\n \"risk_score\": 35,\n \"seller_message\"\: \"Payment complete.\",\n \"type\": \"authorized\"\n },\n\- \ \"paid\": true,\n \"payment_intent\": \"pi_1F4pVYIUmJaD6OqvP2f7TJJs\"\- ,\n \"payment_method\": \"pm_1F4pVXIUmJaD6OqvO9uC5ok9\",\n \"\+ \ \"paid\": true,\n \"payment_intent\": \"pi_1F70K4IUmJaD6OqvfXkgsCB9\"\+ ,\n \"payment_method\": \"pm_1F70K3IUmJaD6OqvNgUunm34\",\n \"\payment_method_details\": {\n \"card\": {\n \"brand\"\: \"visa\",\n \"checks\": {\n \"address_line1_check\"\: null,\n \"address_postal_code_check\": null,\n \@@ -60,37 +60,48 @@ interactions:,\n \"last4\": \"0005\",\n \"three_d_secure\": null,\n\\ \"wallet\": null\n },\n \"type\": \"card\"\n\\ },\n \"receipt_email\": null,\n \"receipt_number\"\- : null,\n \"receipt_url\": \"https://pay.stripe.com/receipts/acct_1EzlmjIUmJaD6Oqv/ch_1F4pVYIUmJaD6OqvaIgZm1nV/rcpt_FZzUTCq6cC0URALvXaDNa9wHxDpO52d\"\+ : null,\n \"receipt_url\": \"https://pay.stripe.com/receipts/acct_1EzlmjIUmJaD6Oqv/ch_1F70K4IUmJaD6Oqv2JSKXPjK/rcpt_FcEn5fjksybnZeXqVUUF2G9cZGNCV8Z\"\,\n \"refunded\": false,\n \"refunds\": {\n \"object\"\: \"list\",\n \"data\": [\n\n ],\n \"has_more\"\- : false,\n \"total_count\": 0,\n \"url\": \"/v1/charges/ch_1F4pVYIUmJaD6OqvaIgZm1nV/refunds\"\- \n },\n \"review\": null,\n \"shipping\": null,\n \- \ \"source\": null,\n \"source_transfer\": null,\n \"statement_descriptor\"\- : null,\n \"statement_descriptor_suffix\": null,\n \"status\"\- : \"succeeded\",\n \"transfer_data\": null,\n \"transfer_group\"\- : null\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n\- \ \"url\": \"/v1/charges?payment_intent=pi_1F4pVYIUmJaD6OqvP2f7TJJs\"\n\- \ },\n \"client_secret\": \"pi_1F4pVYIUmJaD6OqvP2f7TJJs_secret_H7CU82eglCDj0dXAJTNkQcGze\"\- ,\n \"confirmation_method\": \"manual\",\n \"created\": 1565185732,\n \"\+ : false,\n \"total_count\": 0,\n \"url\": \"/v1/charges/ch_1F70K4IUmJaD6Oqv2JSKXPjK/refunds\"\+ \n },\n \"review\": null,\n \"shipping\": {\n \+ \ \"address\": {\n \"city\": \"WROC\u0141AW\",\n \"\+ country\": \"Poland\",\n \"line1\": \"T\u0119czowa 7\",\n \+ \ \"line2\": \"\",\n \"postal_code\": \"53-601\",\n \+ \ \"state\": \"\"\n },\n \"carrier\": null,\n \+ \ \"name\": \"John Doe\",\n \"phone\": \"+48713988102\",\n \+ \ \"tracking_number\": null\n },\n \"source\": null,\n\+ \ \"source_transfer\": null,\n \"statement_descriptor\": null,\n\+ \ \"statement_descriptor_suffix\": null,\n \"status\": \"succeeded\"\+ ,\n \"transfer_data\": null,\n \"transfer_group\": null\n \+ \ }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n \"\+ url\": \"/v1/charges?payment_intent=pi_1F70K4IUmJaD6OqvfXkgsCB9\"\n },\n\+ \ \"client_secret\": \"pi_1F70K4IUmJaD6OqvfXkgsCB9_secret_hgnbn7iX7DiQuKTT7dvFQ2YQ7\"\+ ,\n \"confirmation_method\": \"manual\",\n \"created\": 1565703960,\n \"\currency\": \"usd\",\n \"customer\": null,\n \"description\": null,\n \"\invoice\": null,\n \"last_payment_error\": null,\n \"livemode\": false,\n\\ \"metadata\": {\n },\n \"next_action\": null,\n \"on_behalf_of\": null,\n\- \ \"payment_method\": \"pm_1F4pVXIUmJaD6OqvO9uC5ok9\",\n \"payment_method_options\"\+ \ \"payment_method\": \"pm_1F70K3IUmJaD6OqvNgUunm34\",\n \"payment_method_options\"\: {\n \"card\": {\n \"request_three_d_secure\": \"automatic\"\n \\ }\n },\n \"payment_method_types\": [\n \"card\"\n ],\n \"receipt_email\"\- : null,\n \"review\": null,\n \"setup_future_usage\": null,\n \"shipping\"\- : null,\n \"source\": null,\n \"statement_descriptor\": null,\n \"statement_descriptor_suffix\"\+ : null,\n \"review\": null,\n \"setup_future_usage\": \"on_session\",\n\+ \ \"shipping\": {\n \"address\": {\n \"city\": \"WROC\u0141AW\",\n\+ \ \"country\": \"Poland\",\n \"line1\": \"T\u0119czowa 7\",\n \+ \ \"line2\": \"\",\n \"postal_code\": \"53-601\",\n \"state\"\+ : \"\"\n },\n \"carrier\": null,\n \"name\": \"John Doe\",\n \"\+ phone\": \"+48713988102\",\n \"tracking_number\": null\n },\n \"source\"\+ : null,\n \"statement_descriptor\": null,\n \"statement_descriptor_suffix\"\: null,\n \"status\": \"succeeded\",\n \"transfer_data\": null,\n \"transfer_group\"\: null\n}\n"headers:Connection:- keep-aliveContent-Length:- - '3996'+ - '4636'Content-Type:- application/jsonDate:- - Wed, 07 Aug 2019 13:48:53 GMT+ - Tue, 13 Aug 2019 13:46:01 GMTServer:- nginxStrict-Transport-Security:@@ -108,368 +119,11 @@ interactions:cache-control:- no-cache, no-storeidempotency-key:- - 86a2df12-11ff-478f-b6ab-86c6a3d7856b+ - bd0e72e0-c36e-4a18-8c55-dde0b2f7b61doriginal-request:- - req_8S93V2YnPF1OyS+ - req_dOzyCSUkqzrkKTrequest-id:- - req_8S93V2YnPF1OyS- stripe-version:- - '2019-05-16'- status:- code: 200- message: OK-- request:- body: payment_method=pm_card_pl&amount=4242¤cy=usd&confirmation_method=manual&confirm=True&capture_method=automatic- headers:- Accept:- - '*/*'- Accept-Encoding:- - gzip, deflate- Connection:- - keep-alive- Content-Length:- - '115'- Content-Type:- - application/x-www-form-urlencoded- Idempotency-Key:- - 6afa5daf-7c45-4835-a9be-f9acd81ff14f- User-Agent:- - Stripe/v1 PythonBindings/2.33.0- X-Stripe-Client-User-Agent:- - '{"bindings_version": "2.33.0", "lang": "python", "publisher": "stripe", "httplib":- "requests", "lang_version": "3.7.4", "platform": "Darwin-18.7.0-x86_64-i386-64bit",- "uname": "Darwin mbp-jakub.lan 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun- 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64 i386"}'- method: POST- uri: https://api.stripe.com/v1/payment_intents- response:- body:- string: "{\n \"id\": \"pi_1F5BoRIUmJaD6Oqv03Ly45Q1\",\n \"object\": \"payment_intent\"\- ,\n \"amount\": 4242,\n \"amount_capturable\": 0,\n \"amount_received\"\- : 4242,\n \"application\": null,\n \"application_fee_amount\": null,\n \- \ \"canceled_at\": null,\n \"cancellation_reason\": null,\n \"capture_method\"\- : \"automatic\",\n \"charges\": {\n \"object\": \"list\",\n \"data\"\- : [\n {\n \"id\": \"ch_1F5BoRIUmJaD6Oqv55kNLyfv\",\n \"\- object\": \"charge\",\n \"amount\": 4242,\n \"amount_refunded\"\- : 0,\n \"application\": null,\n \"application_fee\": null,\n\- \ \"application_fee_amount\": null,\n \"balance_transaction\"\- : \"txn_1F5BoRIUmJaD6OqvkYKclkL0\",\n \"billing_details\": {\n \- \ \"address\": {\n \"city\": null,\n \"country\"\- : null,\n \"line1\": null,\n \"line2\": null,\n \- \ \"postal_code\": null,\n \"state\": null\n },\n\- \ \"email\": null,\n \"name\": null,\n \"phone\"\- : null\n },\n \"captured\": true,\n \"created\": 1565271471,\n\- \ \"currency\": \"usd\",\n \"customer\": null,\n \"description\"\- : null,\n \"destination\": null,\n \"dispute\": null,\n \- \ \"failure_code\": null,\n \"failure_message\": null,\n \- \ \"fraud_details\": {\n },\n \"invoice\": null,\n \"\- livemode\": false,\n \"metadata\": {\n },\n \"on_behalf_of\"\- : null,\n \"order\": null,\n \"outcome\": {\n \"network_status\"\- : \"approved_by_network\",\n \"reason\": null,\n \"risk_level\"\- : \"normal\",\n \"risk_score\": 32,\n \"seller_message\"\- : \"Payment complete.\",\n \"type\": \"authorized\"\n },\n\- \ \"paid\": true,\n \"payment_intent\": \"pi_1F5BoRIUmJaD6Oqv03Ly45Q1\"\- ,\n \"payment_method\": \"pm_1F5BoRIUmJaD6OqvAffLcapg\",\n \"\- payment_method_details\": {\n \"card\": {\n \"brand\"\- : \"visa\",\n \"checks\": {\n \"address_line1_check\"\- : null,\n \"address_postal_code_check\": null,\n \- \ \"cvc_check\": null\n },\n \"country\": \"PL\",\n\- \ \"exp_month\": 8,\n \"exp_year\": 2020,\n \- \ \"fingerprint\": \"aleqpF0PMAATcfmb\",\n \"funding\": \"credit\"\- ,\n \"last4\": \"0005\",\n \"three_d_secure\": null,\n\- \ \"wallet\": null\n },\n \"type\": \"card\"\n\- \ },\n \"receipt_email\": null,\n \"receipt_number\"\- : null,\n \"receipt_url\": \"https://pay.stripe.com/receipts/acct_1EzlmjIUmJaD6Oqv/ch_1F5BoRIUmJaD6Oqv55kNLyfv/rcpt_FaMXtDcFUBkt6KlWuXdhQKQq9X09xVf\"\- ,\n \"refunded\": false,\n \"refunds\": {\n \"object\"\- : \"list\",\n \"data\": [\n\n ],\n \"has_more\"\- : false,\n \"total_count\": 0,\n \"url\": \"/v1/charges/ch_1F5BoRIUmJaD6Oqv55kNLyfv/refunds\"\- \n },\n \"review\": null,\n \"shipping\": null,\n \- \ \"source\": null,\n \"source_transfer\": null,\n \"statement_descriptor\"\- : null,\n \"statement_descriptor_suffix\": null,\n \"status\"\- : \"succeeded\",\n \"transfer_data\": null,\n \"transfer_group\"\- : null\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n\- \ \"url\": \"/v1/charges?payment_intent=pi_1F5BoRIUmJaD6Oqv03Ly45Q1\"\n\- \ },\n \"client_secret\": \"pi_1F5BoRIUmJaD6Oqv03Ly45Q1_secret_zNPgyxupLvz7U94FKGG4cGqQs\"\- ,\n \"confirmation_method\": \"manual\",\n \"created\": 1565271471,\n \"\- currency\": \"usd\",\n \"customer\": null,\n \"description\": null,\n \"\- invoice\": null,\n \"last_payment_error\": null,\n \"livemode\": false,\n\- \ \"metadata\": {\n },\n \"next_action\": null,\n \"on_behalf_of\": null,\n\- \ \"payment_method\": \"pm_1F5BoRIUmJaD6OqvAffLcapg\",\n \"payment_method_options\"\- : {\n \"card\": {\n \"request_three_d_secure\": \"automatic\"\n \- \ }\n },\n \"payment_method_types\": [\n \"card\"\n ],\n \"receipt_email\"\- : null,\n \"review\": null,\n \"setup_future_usage\": null,\n \"shipping\"\- : null,\n \"source\": null,\n \"statement_descriptor\": null,\n \"statement_descriptor_suffix\"\- : null,\n \"status\": \"succeeded\",\n \"transfer_data\": null,\n \"transfer_group\"\- : null\n}\n"- headers:- Connection:- - keep-alive- Content-Length:- - '3996'- Content-Type:- - application/json- Date:- - Thu, 08 Aug 2019 13:37:52 GMT- Server:- - nginx- Strict-Transport-Security:- - max-age=31556926; includeSubDomains; preload- access-control-allow-credentials:- - 'true'- access-control-allow-methods:- - GET, POST, HEAD, OPTIONS, DELETE- access-control-allow-origin:- - '*'- access-control-expose-headers:- - Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required- access-control-max-age:- - '300'- cache-control:- - no-cache, no-store- idempotency-key:- - 6afa5daf-7c45-4835-a9be-f9acd81ff14f- original-request:- - req_Xs3SMl52WIayjo- request-id:- - req_Xs3SMl52WIayjo- stripe-version:- - '2019-05-16'- status:- code: 200- message: OK-- request:- body: payment_method=pm_card_pl&amount=4242¤cy=usd&confirmation_method=manual&confirm=True&capture_method=automatic- headers:- Accept:- - '*/*'- Accept-Encoding:- - gzip, deflate- Connection:- - keep-alive- Content-Length:- - '115'- Content-Type:- - application/x-www-form-urlencoded- Idempotency-Key:- - 45bb4ac7-3a97-4979-8867-141ee1d598af- User-Agent:- - Stripe/v1 PythonBindings/2.33.0- X-Stripe-Client-User-Agent:- - '{"bindings_version": "2.33.0", "lang": "python", "publisher": "stripe", "httplib":- "requests", "lang_version": "3.7.4", "platform": "Darwin-18.7.0-x86_64-i386-64bit",- "uname": "Darwin mbp-jakub.lan 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun- 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64 i386"}'- method: POST- uri: https://api.stripe.com/v1/payment_intents- response:- body:- string: "{\n \"id\": \"pi_1F5BqtIUmJaD6OqvcyF3TbaZ\",\n \"object\": \"payment_intent\"\- ,\n \"amount\": 4242,\n \"amount_capturable\": 0,\n \"amount_received\"\- : 4242,\n \"application\": null,\n \"application_fee_amount\": null,\n \- \ \"canceled_at\": null,\n \"cancellation_reason\": null,\n \"capture_method\"\- : \"automatic\",\n \"charges\": {\n \"object\": \"list\",\n \"data\"\- : [\n {\n \"id\": \"ch_1F5BqtIUmJaD6OqvIghCPbWH\",\n \"\- object\": \"charge\",\n \"amount\": 4242,\n \"amount_refunded\"\- : 0,\n \"application\": null,\n \"application_fee\": null,\n\- \ \"application_fee_amount\": null,\n \"balance_transaction\"\- : \"txn_1F5BqtIUmJaD6Oqv6RKzEmxT\",\n \"billing_details\": {\n \- \ \"address\": {\n \"city\": null,\n \"country\"\- : null,\n \"line1\": null,\n \"line2\": null,\n \- \ \"postal_code\": null,\n \"state\": null\n },\n\- \ \"email\": null,\n \"name\": null,\n \"phone\"\- : null\n },\n \"captured\": true,\n \"created\": 1565271623,\n\- \ \"currency\": \"usd\",\n \"customer\": null,\n \"description\"\- : null,\n \"destination\": null,\n \"dispute\": null,\n \- \ \"failure_code\": null,\n \"failure_message\": null,\n \- \ \"fraud_details\": {\n },\n \"invoice\": null,\n \"\- livemode\": false,\n \"metadata\": {\n },\n \"on_behalf_of\"\- : null,\n \"order\": null,\n \"outcome\": {\n \"network_status\"\- : \"approved_by_network\",\n \"reason\": null,\n \"risk_level\"\- : \"normal\",\n \"risk_score\": 12,\n \"seller_message\"\- : \"Payment complete.\",\n \"type\": \"authorized\"\n },\n\- \ \"paid\": true,\n \"payment_intent\": \"pi_1F5BqtIUmJaD6OqvcyF3TbaZ\"\- ,\n \"payment_method\": \"pm_1F5BqsIUmJaD6OqvuktcY6sD\",\n \"\- payment_method_details\": {\n \"card\": {\n \"brand\"\- : \"visa\",\n \"checks\": {\n \"address_line1_check\"\- : null,\n \"address_postal_code_check\": null,\n \- \ \"cvc_check\": null\n },\n \"country\": \"PL\",\n\- \ \"exp_month\": 8,\n \"exp_year\": 2020,\n \- \ \"fingerprint\": \"aleqpF0PMAATcfmb\",\n \"funding\": \"credit\"\- ,\n \"last4\": \"0005\",\n \"three_d_secure\": null,\n\- \ \"wallet\": null\n },\n \"type\": \"card\"\n\- \ },\n \"receipt_email\": null,\n \"receipt_number\"\- : null,\n \"receipt_url\": \"https://pay.stripe.com/receipts/acct_1EzlmjIUmJaD6Oqv/ch_1F5BqtIUmJaD6OqvIghCPbWH/rcpt_FaMaP0ugMSJhcczaMpqMi6fkcpSaBAk\"\- ,\n \"refunded\": false,\n \"refunds\": {\n \"object\"\- : \"list\",\n \"data\": [\n\n ],\n \"has_more\"\- : false,\n \"total_count\": 0,\n \"url\": \"/v1/charges/ch_1F5BqtIUmJaD6OqvIghCPbWH/refunds\"\- \n },\n \"review\": null,\n \"shipping\": null,\n \- \ \"source\": null,\n \"source_transfer\": null,\n \"statement_descriptor\"\- : null,\n \"statement_descriptor_suffix\": null,\n \"status\"\- : \"succeeded\",\n \"transfer_data\": null,\n \"transfer_group\"\- : null\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n\- \ \"url\": \"/v1/charges?payment_intent=pi_1F5BqtIUmJaD6OqvcyF3TbaZ\"\n\- \ },\n \"client_secret\": \"pi_1F5BqtIUmJaD6OqvcyF3TbaZ_secret_T2aC8t512p9jFOwskIxyqQI3d\"\- ,\n \"confirmation_method\": \"manual\",\n \"created\": 1565271623,\n \"\- currency\": \"usd\",\n \"customer\": null,\n \"description\": null,\n \"\- invoice\": null,\n \"last_payment_error\": null,\n \"livemode\": false,\n\- \ \"metadata\": {\n },\n \"next_action\": null,\n \"on_behalf_of\": null,\n\- \ \"payment_method\": \"pm_1F5BqsIUmJaD6OqvuktcY6sD\",\n \"payment_method_options\"\- : {\n \"card\": {\n \"request_three_d_secure\": \"automatic\"\n \- \ }\n },\n \"payment_method_types\": [\n \"card\"\n ],\n \"receipt_email\"\- : null,\n \"review\": null,\n \"setup_future_usage\": null,\n \"shipping\"\- : null,\n \"source\": null,\n \"statement_descriptor\": null,\n \"statement_descriptor_suffix\"\- : null,\n \"status\": \"succeeded\",\n \"transfer_data\": null,\n \"transfer_group\"\- : null\n}\n"- headers:- Connection:- - keep-alive- Content-Length:- - '3996'- Content-Type:- - application/json- Date:- - Thu, 08 Aug 2019 13:40:24 GMT- Server:- - nginx- Strict-Transport-Security:- - max-age=31556926; includeSubDomains; preload- access-control-allow-credentials:- - 'true'- access-control-allow-methods:- - GET, POST, HEAD, OPTIONS, DELETE- access-control-allow-origin:- - '*'- access-control-expose-headers:- - Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required- access-control-max-age:- - '300'- cache-control:- - no-cache, no-store- idempotency-key:- - 45bb4ac7-3a97-4979-8867-141ee1d598af- original-request:- - req_YUZwIYFjguCgKX- request-id:- - req_YUZwIYFjguCgKX- stripe-version:- - '2019-05-16'- status:- code: 200- message: OK-- request:- body: payment_method=pm_card_pl&amount=4242¤cy=usd&confirmation_method=manual&confirm=True&capture_method=automatic- headers:- Accept:- - '*/*'- Accept-Encoding:- - gzip, deflate- Connection:- - keep-alive- Content-Length:- - '115'- Content-Type:- - application/x-www-form-urlencoded- Idempotency-Key:- - b03a30c0-feeb-442c-99d4-042d1763d0a6- User-Agent:- - Stripe/v1 PythonBindings/2.33.0- X-Stripe-Client-User-Agent:- - '{"bindings_version": "2.33.0", "lang": "python", "publisher": "stripe", "httplib":- "requests", "lang_version": "3.7.4", "platform": "Darwin-18.7.0-x86_64-i386-64bit",- "uname": "Darwin mbp-jakub.lan 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun- 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64 i386"}'- method: POST- uri: https://api.stripe.com/v1/payment_intents- response:- body:- string: "{\n \"id\": \"pi_1F5BsOIUmJaD6Oqvmh5vBJIA\",\n \"object\": \"payment_intent\"\- ,\n \"amount\": 4242,\n \"amount_capturable\": 0,\n \"amount_received\"\- : 4242,\n \"application\": null,\n \"application_fee_amount\": null,\n \- \ \"canceled_at\": null,\n \"cancellation_reason\": null,\n \"capture_method\"\- : \"automatic\",\n \"charges\": {\n \"object\": \"list\",\n \"data\"\- : [\n {\n \"id\": \"ch_1F5BsOIUmJaD6OqvbM6tKDjc\",\n \"\- object\": \"charge\",\n \"amount\": 4242,\n \"amount_refunded\"\- : 0,\n \"application\": null,\n \"application_fee\": null,\n\- \ \"application_fee_amount\": null,\n \"balance_transaction\"\- : \"txn_1F5BsOIUmJaD6OqvoDuvgoCK\",\n \"billing_details\": {\n \- \ \"address\": {\n \"city\": null,\n \"country\"\- : null,\n \"line1\": null,\n \"line2\": null,\n \- \ \"postal_code\": null,\n \"state\": null\n },\n\- \ \"email\": null,\n \"name\": null,\n \"phone\"\- : null\n },\n \"captured\": true,\n \"created\": 1565271716,\n\- \ \"currency\": \"usd\",\n \"customer\": null,\n \"description\"\- : null,\n \"destination\": null,\n \"dispute\": null,\n \- \ \"failure_code\": null,\n \"failure_message\": null,\n \- \ \"fraud_details\": {\n },\n \"invoice\": null,\n \"\- livemode\": false,\n \"metadata\": {\n },\n \"on_behalf_of\"\- : null,\n \"order\": null,\n \"outcome\": {\n \"network_status\"\- : \"approved_by_network\",\n \"reason\": null,\n \"risk_level\"\- : \"normal\",\n \"risk_score\": 8,\n \"seller_message\"\- : \"Payment complete.\",\n \"type\": \"authorized\"\n },\n\- \ \"paid\": true,\n \"payment_intent\": \"pi_1F5BsOIUmJaD6Oqvmh5vBJIA\"\- ,\n \"payment_method\": \"pm_1F5BsOIUmJaD6OqvM6mSN7La\",\n \"\- payment_method_details\": {\n \"card\": {\n \"brand\"\- : \"visa\",\n \"checks\": {\n \"address_line1_check\"\- : null,\n \"address_postal_code_check\": null,\n \- \ \"cvc_check\": null\n },\n \"country\": \"PL\",\n\- \ \"exp_month\": 8,\n \"exp_year\": 2020,\n \- \ \"fingerprint\": \"aleqpF0PMAATcfmb\",\n \"funding\": \"credit\"\- ,\n \"last4\": \"0005\",\n \"three_d_secure\": null,\n\- \ \"wallet\": null\n },\n \"type\": \"card\"\n\- \ },\n \"receipt_email\": null,\n \"receipt_number\"\- : null,\n \"receipt_url\": \"https://pay.stripe.com/receipts/acct_1EzlmjIUmJaD6Oqv/ch_1F5BsOIUmJaD6OqvbM6tKDjc/rcpt_FaMbz3hC4CA0NuWiuFFISgfPltn2h4U\"\- ,\n \"refunded\": false,\n \"refunds\": {\n \"object\"\- : \"list\",\n \"data\": [\n\n ],\n \"has_more\"\- : false,\n \"total_count\": 0,\n \"url\": \"/v1/charges/ch_1F5BsOIUmJaD6OqvbM6tKDjc/refunds\"\- \n },\n \"review\": null,\n \"shipping\": null,\n \- \ \"source\": null,\n \"source_transfer\": null,\n \"statement_descriptor\"\- : null,\n \"statement_descriptor_suffix\": null,\n \"status\"\- : \"succeeded\",\n \"transfer_data\": null,\n \"transfer_group\"\- : null\n }\n ],\n \"has_more\": false,\n \"total_count\": 1,\n\- \ \"url\": \"/v1/charges?payment_intent=pi_1F5BsOIUmJaD6Oqvmh5vBJIA\"\n\- \ },\n \"client_secret\": \"pi_1F5BsOIUmJaD6Oqvmh5vBJIA_secret_bpJHb3g4rDKbYxIlWakCkartF\"\- ,\n \"confirmation_method\": \"manual\",\n \"created\": 1565271716,\n \"\- currency\": \"usd\",\n \"customer\": null,\n \"description\": null,\n \"\- invoice\": null,\n \"last_payment_error\": null,\n \"livemode\": false,\n\- \ \"metadata\": {\n },\n \"next_action\": null,\n \"on_behalf_of\": null,\n\- \ \"payment_method\": \"pm_1F5BsOIUmJaD6OqvM6mSN7La\",\n \"payment_method_options\"\- : {\n \"card\": {\n \"request_three_d_secure\": \"automatic\"\n \- \ }\n },\n \"payment_method_types\": [\n \"card\"\n ],\n \"receipt_email\"\- : null,\n \"review\": null,\n \"setup_future_usage\": null,\n \"shipping\"\- : null,\n \"source\": null,\n \"statement_descriptor\": null,\n \"statement_descriptor_suffix\"\- : null,\n \"status\": \"succeeded\",\n \"transfer_data\": null,\n \"transfer_group\"\- : null\n}\n"- headers:- Connection:- - keep-alive- Content-Length:- - '3995'- Content-Type:- - application/json- Date:- - Thu, 08 Aug 2019 13:41:57 GMT- Server:- - nginx- Strict-Transport-Security:- - max-age=31556926; includeSubDomains; preload- access-control-allow-credentials:- - 'true'- access-control-allow-methods:- - GET, POST, HEAD, OPTIONS, DELETE- access-control-allow-origin:- - '*'- access-control-expose-headers:- - Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required- access-control-max-age:- - '300'- cache-control:- - no-cache, no-store- idempotency-key:- - b03a30c0-feeb-442c-99d4-042d1763d0a6- original-request:- - req_Yp2Xralp4YSSas- request-id:- - req_Yp2Xralp4YSSas+ - req_dOzyCSUkqzrkKTstripe-version:- '2019-05-16'status:diff --git a/tests/gateway/stripe/test_stripe.py b/tests/gateway/stripe/test_stripe.pyindex 15e7918637..d767dbe3fe 100644--- a/tests/gateway/stripe/test_stripe.py+++ b/tests/gateway/stripe/test_stripe.py@@ -21,10 +21,13 @@ TRANSACTION_AMOUNT = Decimal(42.42)TRANSACTION_REFUND_AMOUNT = Decimal(24.24)TRANSACTION_CURRENCY = "USD"PAYMENT_METHOD_CARD_SIMPLE = "pm_card_pl"+CARD_SIMPLE_DETAILS = CreditCardInfo(+ last_4="0005", exp_year=2020, exp_month=8, brand="visa"+)PAYMENT_METHOD_CARD_3D_SECURE = "pm_card_threeDSecure2Required"# Set to True if recording new cassette with sandbox using credentials in env-RECORD = False+RECORD = True@pytest.fixture()@@ -77,6 +80,7 @@ def test_authorize(sandbox_gateway_config, stripe_payment):assert isclose(response.amount, TRANSACTION_AMOUNT)assert response.currency == TRANSACTION_CURRENCYassert response.is_success is True+ assert response.card_info == CARD_SIMPLE_DETAILSassert not response.action_required@@ -180,6 +184,7 @@ def test_capture(stripe_authorized_payment, sandbox_gateway_config):assert response.is_successassert isclose(response.amount, TRANSACTION_AMOUNT)assert response.currency == TRANSACTION_CURRENCY+ assert response.card_info == CARD_SIMPLE_DETAILS@pytest.mark.integration