From 0f41d900dfee6c4a5f963aeed5e8d2886afdaa54 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Tue, 12 Dec 2023 12:01:19 +0000 Subject: [PATCH] DRYes card and payment intent let groups Fixes typo on capture_amount declaration --- ...t_intent_state_is_not_requires_capture.yml | 56 +++--- .../_purchase/completes_the_purchase.yml | 159 ++++++++---------- ..._error_message_to_help_developer_debug.yml | 62 +++---- spec/models/spree/gateway/stripe_sca_spec.rb | 82 +++------ 4 files changed, 153 insertions(+), 206 deletions(-) diff --git a/spec/fixtures/vcr_cassettes/Stripe-v10.2.0/Spree_Gateway_StripeSCA/_error_message/when_payment_intent_state_is_not_in_requires_capture_state/does_not_succeed_if_payment_intent_state_is_not_requires_capture.yml b/spec/fixtures/vcr_cassettes/Stripe-v10.2.0/Spree_Gateway_StripeSCA/_error_message/when_payment_intent_state_is_not_in_requires_capture_state/does_not_succeed_if_payment_intent_state_is_not_requires_capture.yml index 1aa3b0820a..16106fdb85 100644 --- a/spec/fixtures/vcr_cassettes/Stripe-v10.2.0/Spree_Gateway_StripeSCA/_error_message/when_payment_intent_state_is_not_in_requires_capture_state/does_not_succeed_if_payment_intent_state_is_not_requires_capture.yml +++ b/spec/fixtures/vcr_cassettes/Stripe-v10.2.0/Spree_Gateway_StripeSCA/_error_message/when_payment_intent_state_is_not_in_requires_capture_state/does_not_succeed_if_payment_intent_state_is_not_requires_capture.yml @@ -14,7 +14,7 @@ http_interactions: Content-Type: - application/x-www-form-urlencoded X-Stripe-Client-Telemetry: - - '{"last_request_metrics":{"request_id":"req_yPW1h61ihGksLY","request_duration_ms":1020}}' + - '{"last_request_metrics":{"request_id":"req_kEuP9BShlEJBEh","request_duration_ms":1066}}' Stripe-Version: - '2023-10-16' X-Stripe-Client-User-Agent: @@ -34,7 +34,7 @@ http_interactions: Server: - nginx Date: - - Mon, 11 Dec 2023 21:50:55 GMT + - Tue, 12 Dec 2023 13:16:41 GMT Content-Type: - application/json Content-Length: @@ -59,11 +59,11 @@ http_interactions: default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' Idempotency-Key: - - db697186-403f-48de-9453-7dcbe705363e + - 31802e28-8d9a-4a22-a684-db641e5edb91 Original-Request: - - req_LqTDQPa09gORLx + - req_ycRJsY0xEobgbQ Request-Id: - - req_LqTDQPa09gORLx + - req_ycRJsY0xEobgbQ Stripe-Should-Retry: - 'false' Stripe-Version: @@ -78,7 +78,7 @@ http_interactions: encoding: UTF-8 string: |- { - "id": "pm_1OMHNKKuuB1fWySnXahBsdmJ", + "id": "pm_1OMVpFKuuB1fWySnMHJj4rV0", "object": "payment_method", "billing_details": { "address": { @@ -118,19 +118,19 @@ http_interactions: }, "wallet": null }, - "created": 1702331455, + "created": 1702387001, "customer": null, "livemode": false, "metadata": {}, "type": "card" } - recorded_at: Mon, 11 Dec 2023 21:50:55 GMT + recorded_at: Tue, 12 Dec 2023 13:16:42 GMT - request: method: post uri: https://api.stripe.com/v1/payment_intents body: encoding: UTF-8 - string: amount=1000¤cy=aud&payment_method=pm_1OMHNKKuuB1fWySnXahBsdmJ&payment_method_types[0]=card&capture_method=manual + string: amount=1000¤cy=aud&payment_method=pm_1OMVpFKuuB1fWySnMHJj4rV0&payment_method_types[0]=card&capture_method=manual headers: User-Agent: - Stripe/v1 RubyBindings/10.2.0 @@ -139,7 +139,7 @@ http_interactions: Content-Type: - application/x-www-form-urlencoded X-Stripe-Client-Telemetry: - - '{"last_request_metrics":{"request_id":"req_LqTDQPa09gORLx","request_duration_ms":473}}' + - '{"last_request_metrics":{"request_id":"req_ycRJsY0xEobgbQ","request_duration_ms":651}}' Stripe-Version: - '2023-10-16' X-Stripe-Client-User-Agent: @@ -159,7 +159,7 @@ http_interactions: Server: - nginx Date: - - Mon, 11 Dec 2023 21:50:55 GMT + - Tue, 12 Dec 2023 13:16:42 GMT Content-Type: - application/json Content-Length: @@ -184,11 +184,11 @@ http_interactions: default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' Idempotency-Key: - - 45d1ef7b-9056-4248-ade7-518867d7b378 + - 4c2ec975-dcac-4183-94be-5cc42388abaa Original-Request: - - req_tneQMoYlODp4Ut + - req_7jzbnRugdmJUxG Request-Id: - - req_tneQMoYlODp4Ut + - req_7jzbnRugdmJUxG Stripe-Should-Retry: - 'false' Stripe-Version: @@ -203,7 +203,7 @@ http_interactions: encoding: UTF-8 string: |- { - "id": "pi_3OMHNLKuuB1fWySn2AwSg35E", + "id": "pi_3OMVpGKuuB1fWySn1V3lr4qv", "object": "payment_intent", "amount": 1000, "amount_capturable": 0, @@ -217,9 +217,9 @@ http_interactions: "canceled_at": null, "cancellation_reason": null, "capture_method": "manual", - "client_secret": "pi_3OMHNLKuuB1fWySn2AwSg35E_secret_Rc0C8yuSK7ZSxhhway0UwKhhm", + "client_secret": "pi_3OMVpGKuuB1fWySn1V3lr4qv_secret_mv7HDgsiBtwrCKWIgPM81tNmQ", "confirmation_method": "automatic", - "created": 1702331455, + "created": 1702387002, "currency": "aud", "customer": null, "description": null, @@ -230,7 +230,7 @@ http_interactions: "metadata": {}, "next_action": null, "on_behalf_of": null, - "payment_method": "pm_1OMHNKKuuB1fWySnXahBsdmJ", + "payment_method": "pm_1OMVpFKuuB1fWySnMHJj4rV0", "payment_method_configuration_details": null, "payment_method_options": { "card": { @@ -255,10 +255,10 @@ http_interactions: "transfer_data": null, "transfer_group": null } - recorded_at: Mon, 11 Dec 2023 21:50:55 GMT + recorded_at: Tue, 12 Dec 2023 13:16:42 GMT - request: method: get - uri: https://api.stripe.com/v1/payment_intents/pi_3OMHNLKuuB1fWySn2AwSg35E + uri: https://api.stripe.com/v1/payment_intents/pi_3OMVpGKuuB1fWySn1V3lr4qv body: encoding: US-ASCII string: '' @@ -270,7 +270,7 @@ http_interactions: Content-Type: - application/x-www-form-urlencoded X-Stripe-Client-Telemetry: - - '{"last_request_metrics":{"request_id":"req_tneQMoYlODp4Ut","request_duration_ms":407}}' + - '{"last_request_metrics":{"request_id":"req_7jzbnRugdmJUxG","request_duration_ms":423}}' Stripe-Version: - '2023-10-16' X-Stripe-Client-User-Agent: @@ -290,7 +290,7 @@ http_interactions: Server: - nginx Date: - - Mon, 11 Dec 2023 21:50:57 GMT + - Tue, 12 Dec 2023 13:16:42 GMT Content-Type: - application/json Content-Length: @@ -316,7 +316,7 @@ http_interactions: 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' Request-Id: - - req_XG2JlCPei8f4NV + - req_5eOQLL9A6WDALS Stripe-Version: - '2023-10-16' Vary: @@ -329,7 +329,7 @@ http_interactions: encoding: UTF-8 string: |- { - "id": "pi_3OMHNLKuuB1fWySn2AwSg35E", + "id": "pi_3OMVpGKuuB1fWySn1V3lr4qv", "object": "payment_intent", "amount": 1000, "amount_capturable": 0, @@ -343,9 +343,9 @@ http_interactions: "canceled_at": null, "cancellation_reason": null, "capture_method": "manual", - "client_secret": "pi_3OMHNLKuuB1fWySn2AwSg35E_secret_Rc0C8yuSK7ZSxhhway0UwKhhm", + "client_secret": "pi_3OMVpGKuuB1fWySn1V3lr4qv_secret_mv7HDgsiBtwrCKWIgPM81tNmQ", "confirmation_method": "automatic", - "created": 1702331455, + "created": 1702387002, "currency": "aud", "customer": null, "description": null, @@ -356,7 +356,7 @@ http_interactions: "metadata": {}, "next_action": null, "on_behalf_of": null, - "payment_method": "pm_1OMHNKKuuB1fWySnXahBsdmJ", + "payment_method": "pm_1OMVpFKuuB1fWySnMHJj4rV0", "payment_method_configuration_details": null, "payment_method_options": { "card": { @@ -381,5 +381,5 @@ http_interactions: "transfer_data": null, "transfer_group": null } - recorded_at: Mon, 11 Dec 2023 21:50:58 GMT + recorded_at: Tue, 12 Dec 2023 13:16:42 GMT recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Stripe-v10.2.0/Spree_Gateway_StripeSCA/_purchase/completes_the_purchase.yml b/spec/fixtures/vcr_cassettes/Stripe-v10.2.0/Spree_Gateway_StripeSCA/_purchase/completes_the_purchase.yml index d8029a7f0e..812c48c3a7 100644 --- a/spec/fixtures/vcr_cassettes/Stripe-v10.2.0/Spree_Gateway_StripeSCA/_purchase/completes_the_purchase.yml +++ b/spec/fixtures/vcr_cassettes/Stripe-v10.2.0/Spree_Gateway_StripeSCA/_purchase/completes_the_purchase.yml @@ -32,7 +32,7 @@ http_interactions: Server: - nginx Date: - - Mon, 11 Dec 2023 21:50:45 GMT + - Tue, 12 Dec 2023 13:16:29 GMT Content-Type: - application/json Content-Length: @@ -57,11 +57,11 @@ http_interactions: default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' Idempotency-Key: - - fab25397-66dc-4f60-8d61-3cb6f971cbd4 + - 0e3af981-5d45-47a8-8df4-f5a4cf65e6a2 Original-Request: - - req_FLU1yYk8sZamRa + - req_a3ZY1GPrHId050 Request-Id: - - req_FLU1yYk8sZamRa + - req_a3ZY1GPrHId050 Stripe-Should-Retry: - 'false' Stripe-Version: @@ -76,7 +76,7 @@ http_interactions: encoding: UTF-8 string: |- { - "id": "pm_1OMHNAKuuB1fWySn3cnBHQQP", + "id": "pm_1OMVp3KuuB1fWySnSK98tJrM", "object": "payment_method", "billing_details": { "address": { @@ -116,19 +116,19 @@ http_interactions: }, "wallet": null }, - "created": 1702331445, + "created": 1702386989, "customer": null, "livemode": false, "metadata": {}, "type": "card" } - recorded_at: Mon, 11 Dec 2023 21:50:45 GMT + recorded_at: Tue, 12 Dec 2023 13:16:29 GMT - request: method: post uri: https://api.stripe.com/v1/payment_intents body: encoding: UTF-8 - string: amount=1000¤cy=aud&payment_method=pm_1OMHNAKuuB1fWySn3cnBHQQP&payment_method_types[0]=card&capture_method=manual + string: amount=1000¤cy=aud&payment_method=pm_1OMVp3KuuB1fWySnSK98tJrM&payment_method_types[0]=card&capture_method=manual headers: User-Agent: - Stripe/v1 RubyBindings/10.2.0 @@ -137,7 +137,7 @@ http_interactions: Content-Type: - application/x-www-form-urlencoded X-Stripe-Client-Telemetry: - - '{"last_request_metrics":{"request_id":"req_FLU1yYk8sZamRa","request_duration_ms":780}}' + - '{"last_request_metrics":{"request_id":"req_a3ZY1GPrHId050","request_duration_ms":728}}' Stripe-Version: - '2023-10-16' X-Stripe-Client-User-Agent: @@ -157,7 +157,7 @@ http_interactions: Server: - nginx Date: - - Mon, 11 Dec 2023 21:50:45 GMT + - Tue, 12 Dec 2023 13:16:30 GMT Content-Type: - application/json Content-Length: @@ -182,11 +182,11 @@ http_interactions: default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' Idempotency-Key: - - bf584387-be9e-41e4-b68e-6a67bf247609 + - ab30b417-ce24-41d8-bbd1-2353ea63aaa4 Original-Request: - - req_yZ6n7FCPagLueX + - req_p7U3IYlR3bX9WW Request-Id: - - req_yZ6n7FCPagLueX + - req_p7U3IYlR3bX9WW Stripe-Should-Retry: - 'false' Stripe-Version: @@ -201,7 +201,7 @@ http_interactions: encoding: UTF-8 string: |- { - "id": "pi_3OMHNBKuuB1fWySn0FeJ0eva", + "id": "pi_3OMVp4KuuB1fWySn01foecB2", "object": "payment_intent", "amount": 1000, "amount_capturable": 0, @@ -215,9 +215,9 @@ http_interactions: "canceled_at": null, "cancellation_reason": null, "capture_method": "manual", - "client_secret": "pi_3OMHNBKuuB1fWySn0FeJ0eva_secret_GiprxonohIUvx3wCtswBzMwZN", + "client_secret": "pi_3OMVp4KuuB1fWySn01foecB2_secret_bJt23IgqwzKzKbjrEVe5bbDw6", "confirmation_method": "automatic", - "created": 1702331445, + "created": 1702386990, "currency": "aud", "customer": null, "description": null, @@ -228,7 +228,7 @@ http_interactions: "metadata": {}, "next_action": null, "on_behalf_of": null, - "payment_method": "pm_1OMHNAKuuB1fWySn3cnBHQQP", + "payment_method": "pm_1OMVp3KuuB1fWySnSK98tJrM", "payment_method_configuration_details": null, "payment_method_options": { "card": { @@ -253,10 +253,10 @@ http_interactions: "transfer_data": null, "transfer_group": null } - recorded_at: Mon, 11 Dec 2023 21:50:45 GMT + recorded_at: Tue, 12 Dec 2023 13:16:30 GMT - request: method: post - uri: https://api.stripe.com/v1/payment_intents/pi_3OMHNBKuuB1fWySn0FeJ0eva/confirm + uri: https://api.stripe.com/v1/payment_intents/pi_3OMVp4KuuB1fWySn01foecB2/confirm body: encoding: US-ASCII string: '' @@ -268,7 +268,7 @@ http_interactions: Content-Type: - application/x-www-form-urlencoded X-Stripe-Client-Telemetry: - - '{"last_request_metrics":{"request_id":"req_yZ6n7FCPagLueX","request_duration_ms":610}}' + - '{"last_request_metrics":{"request_id":"req_p7U3IYlR3bX9WW","request_duration_ms":713}}' Stripe-Version: - '2023-10-16' X-Stripe-Client-User-Agent: @@ -288,7 +288,7 @@ http_interactions: Server: - nginx Date: - - Mon, 11 Dec 2023 21:50:46 GMT + - Tue, 12 Dec 2023 13:16:31 GMT Content-Type: - application/json Content-Length: @@ -314,11 +314,11 @@ http_interactions: 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' Idempotency-Key: - - 384e14c9-8af4-4834-b89b-65e61985ba47 + - 06b4730a-4174-430c-89fd-acafe2a33b23 Original-Request: - - req_9ThsIdXtzA4sZE + - req_U3DvUitYuieWsD Request-Id: - - req_9ThsIdXtzA4sZE + - req_U3DvUitYuieWsD Stripe-Should-Retry: - 'false' Stripe-Version: @@ -333,7 +333,7 @@ http_interactions: encoding: UTF-8 string: |- { - "id": "pi_3OMHNBKuuB1fWySn0FeJ0eva", + "id": "pi_3OMVp4KuuB1fWySn01foecB2", "object": "payment_intent", "amount": 1000, "amount_capturable": 1000, @@ -347,20 +347,20 @@ http_interactions: "canceled_at": null, "cancellation_reason": null, "capture_method": "manual", - "client_secret": "pi_3OMHNBKuuB1fWySn0FeJ0eva_secret_GiprxonohIUvx3wCtswBzMwZN", + "client_secret": "pi_3OMVp4KuuB1fWySn01foecB2_secret_bJt23IgqwzKzKbjrEVe5bbDw6", "confirmation_method": "automatic", - "created": 1702331445, + "created": 1702386990, "currency": "aud", "customer": null, "description": null, "invoice": null, "last_payment_error": null, - "latest_charge": "ch_3OMHNBKuuB1fWySn0xy3HD2l", + "latest_charge": "ch_3OMVp4KuuB1fWySn0YT4k7zE", "livemode": false, "metadata": {}, "next_action": null, "on_behalf_of": null, - "payment_method": "pm_1OMHNAKuuB1fWySn3cnBHQQP", + "payment_method": "pm_1OMVp3KuuB1fWySnSK98tJrM", "payment_method_configuration_details": null, "payment_method_options": { "card": { @@ -385,10 +385,10 @@ http_interactions: "transfer_data": null, "transfer_group": null } - recorded_at: Mon, 11 Dec 2023 21:50:47 GMT + recorded_at: Tue, 12 Dec 2023 13:16:31 GMT - request: method: get - uri: https://api.stripe.com/v1/payment_intents/pi_3OMHNBKuuB1fWySn0FeJ0eva + uri: https://api.stripe.com/v1/payment_intents/pi_3OMVp4KuuB1fWySn01foecB2 body: encoding: US-ASCII string: '' @@ -400,7 +400,7 @@ http_interactions: Content-Type: - application/x-www-form-urlencoded X-Stripe-Client-Telemetry: - - '{"last_request_metrics":{"request_id":"req_9ThsIdXtzA4sZE","request_duration_ms":1021}}' + - '{"last_request_metrics":{"request_id":"req_U3DvUitYuieWsD","request_duration_ms":1066}}' Stripe-Version: - '2023-10-16' X-Stripe-Client-User-Agent: @@ -420,7 +420,7 @@ http_interactions: Server: - nginx Date: - - Mon, 11 Dec 2023 21:50:49 GMT + - Tue, 12 Dec 2023 13:16:34 GMT Content-Type: - application/json Content-Length: @@ -446,7 +446,7 @@ http_interactions: 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' Request-Id: - - req_AY1AvcFROeAfTp + - req_2hI8JKOwY7kSNH Stripe-Version: - '2023-10-16' Vary: @@ -459,7 +459,7 @@ http_interactions: encoding: UTF-8 string: |- { - "id": "pi_3OMHNBKuuB1fWySn0FeJ0eva", + "id": "pi_3OMVp4KuuB1fWySn01foecB2", "object": "payment_intent", "amount": 1000, "amount_capturable": 1000, @@ -473,20 +473,20 @@ http_interactions: "canceled_at": null, "cancellation_reason": null, "capture_method": "manual", - "client_secret": "pi_3OMHNBKuuB1fWySn0FeJ0eva_secret_GiprxonohIUvx3wCtswBzMwZN", + "client_secret": "pi_3OMVp4KuuB1fWySn01foecB2_secret_bJt23IgqwzKzKbjrEVe5bbDw6", "confirmation_method": "automatic", - "created": 1702331445, + "created": 1702386990, "currency": "aud", "customer": null, "description": null, "invoice": null, "last_payment_error": null, - "latest_charge": "ch_3OMHNBKuuB1fWySn0xy3HD2l", + "latest_charge": "ch_3OMVp4KuuB1fWySn0YT4k7zE", "livemode": false, "metadata": {}, "next_action": null, "on_behalf_of": null, - "payment_method": "pm_1OMHNAKuuB1fWySn3cnBHQQP", + "payment_method": "pm_1OMVp3KuuB1fWySnSK98tJrM", "payment_method_configuration_details": null, "payment_method_options": { "card": { @@ -511,13 +511,13 @@ http_interactions: "transfer_data": null, "transfer_group": null } - recorded_at: Mon, 11 Dec 2023 21:50:49 GMT + recorded_at: Tue, 12 Dec 2023 13:16:34 GMT - request: method: post - uri: https://api.stripe.com/v1/payment_intents/pi_3OMHNBKuuB1fWySn0FeJ0eva/capture + uri: https://api.stripe.com/v1/payment_intents/pi_3OMVp4KuuB1fWySn01foecB2/capture body: encoding: UTF-8 - string: amount_to_capture=100 + string: amount_to_capture=1000 headers: Content-Type: - application/x-www-form-urlencoded @@ -545,11 +545,11 @@ http_interactions: Server: - nginx Date: - - Mon, 11 Dec 2023 21:50:51 GMT + - Tue, 12 Dec 2023 13:16:36 GMT Content-Type: - application/json Content-Length: - - '5895' + - '5092' Connection: - close Access-Control-Allow-Credentials: @@ -571,11 +571,11 @@ http_interactions: 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' Idempotency-Key: - - efea335a-33bf-447d-b78f-230e525e4949 + - b362b837-8ebb-4369-beb4-e8a02d02c590 Original-Request: - - req_R14YpeW4IlTstq + - req_ZRw3vk5NZdPl51 Request-Id: - - req_R14YpeW4IlTstq + - req_ZRw3vk5NZdPl51 Stripe-Should-Retry: - 'false' Stripe-Version: @@ -590,14 +590,14 @@ http_interactions: encoding: UTF-8 string: |- { - "id": "pi_3OMHNBKuuB1fWySn0FeJ0eva", + "id": "pi_3OMVp4KuuB1fWySn01foecB2", "object": "payment_intent", "amount": 1000, "amount_capturable": 0, "amount_details": { "tip": {} }, - "amount_received": 100, + "amount_received": 1000, "application": null, "application_fee_amount": null, "automatic_payment_methods": null, @@ -608,15 +608,15 @@ http_interactions: "object": "list", "data": [ { - "id": "ch_3OMHNBKuuB1fWySn0xy3HD2l", + "id": "ch_3OMVp4KuuB1fWySn0YT4k7zE", "object": "charge", "amount": 1000, - "amount_captured": 100, - "amount_refunded": 900, + "amount_captured": 1000, + "amount_refunded": 0, "application": null, "application_fee": null, "application_fee_amount": null, - "balance_transaction": "txn_3OMHNBKuuB1fWySn0pt5PJmY", + "balance_transaction": "txn_3OMVp4KuuB1fWySn0E6LUvdB", "billing_details": { "address": { "city": null, @@ -632,7 +632,7 @@ http_interactions: }, "calculated_statement_descriptor": "OFNOFNOFN", "captured": true, - "created": 1702331446, + "created": 1702386991, "currency": "aud", "customer": null, "description": null, @@ -652,18 +652,18 @@ http_interactions: "network_status": "approved_by_network", "reason": null, "risk_level": "normal", - "risk_score": 27, + "risk_score": 3, "seller_message": "Payment complete.", "type": "authorized" }, "paid": true, - "payment_intent": "pi_3OMHNBKuuB1fWySn0FeJ0eva", - "payment_method": "pm_1OMHNAKuuB1fWySn3cnBHQQP", + "payment_intent": "pi_3OMVp4KuuB1fWySn01foecB2", + "payment_method": "pm_1OMVp3KuuB1fWySnSK98tJrM", "payment_method_details": { "card": { "amount_authorized": 1000, "brand": "visa", - "capture_before": 1702936246, + "capture_before": 1702991791, "checks": { "address_line1_check": null, "address_postal_code_check": null, @@ -701,37 +701,14 @@ http_interactions: }, "receipt_email": null, "receipt_number": null, - "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xRmlxRXNLdXVCMWZXeVNuKLqI3qsGMgaLkjk5OjA6LBZEnFvUuRGg_EGGN1wJqtHkfq2TM1hFAIlkmFy2OJggp9G4-FS_qNSKwCRi", + "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xRmlxRXNLdXVCMWZXeVNuKLS64asGMgbwhD1CoTg6LBanMnQfUGRA4FPL3EBN7ZpQEoO0qNMiyQNtQRvkNHn-zA3EVQ2sn8sHhztn", "refunded": false, "refunds": { "object": "list", - "data": [ - { - "id": "re_3OMHNBKuuB1fWySn0hwLz9zP", - "object": "refund", - "amount": 900, - "balance_transaction": "txn_3OMHNBKuuB1fWySn0iYQuOne", - "charge": "ch_3OMHNBKuuB1fWySn0xy3HD2l", - "created": 1702331450, - "currency": "aud", - "destination_details": { - "card": { - "type": "reversal" - }, - "type": "card" - }, - "metadata": {}, - "payment_intent": "pi_3OMHNBKuuB1fWySn0FeJ0eva", - "reason": null, - "receipt_number": null, - "source_transfer_reversal": null, - "status": "succeeded", - "transfer_reversal": null - } - ], + "data": [], "has_more": false, - "total_count": 1, - "url": "/v1/charges/ch_3OMHNBKuuB1fWySn0xy3HD2l/refunds" + "total_count": 0, + "url": "/v1/charges/ch_3OMVp4KuuB1fWySn0YT4k7zE/refunds" }, "review": null, "shipping": null, @@ -746,22 +723,22 @@ http_interactions: ], "has_more": false, "total_count": 1, - "url": "/v1/charges?payment_intent=pi_3OMHNBKuuB1fWySn0FeJ0eva" + "url": "/v1/charges?payment_intent=pi_3OMVp4KuuB1fWySn01foecB2" }, - "client_secret": "pi_3OMHNBKuuB1fWySn0FeJ0eva_secret_GiprxonohIUvx3wCtswBzMwZN", + "client_secret": "pi_3OMVp4KuuB1fWySn01foecB2_secret_bJt23IgqwzKzKbjrEVe5bbDw6", "confirmation_method": "automatic", - "created": 1702331445, + "created": 1702386990, "currency": "aud", "customer": null, "description": null, "invoice": null, "last_payment_error": null, - "latest_charge": "ch_3OMHNBKuuB1fWySn0xy3HD2l", + "latest_charge": "ch_3OMVp4KuuB1fWySn0YT4k7zE", "livemode": false, "metadata": {}, "next_action": null, "on_behalf_of": null, - "payment_method": "pm_1OMHNAKuuB1fWySn3cnBHQQP", + "payment_method": "pm_1OMVp3KuuB1fWySnSK98tJrM", "payment_method_configuration_details": null, "payment_method_options": { "card": { @@ -786,5 +763,5 @@ http_interactions: "transfer_data": null, "transfer_group": null } - recorded_at: Mon, 11 Dec 2023 21:50:51 GMT + recorded_at: Tue, 12 Dec 2023 13:16:36 GMT recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Stripe-v10.2.0/Spree_Gateway_StripeSCA/_purchase/provides_an_error_message_to_help_developer_debug.yml b/spec/fixtures/vcr_cassettes/Stripe-v10.2.0/Spree_Gateway_StripeSCA/_purchase/provides_an_error_message_to_help_developer_debug.yml index 244be6979a..b706bc215e 100644 --- a/spec/fixtures/vcr_cassettes/Stripe-v10.2.0/Spree_Gateway_StripeSCA/_purchase/provides_an_error_message_to_help_developer_debug.yml +++ b/spec/fixtures/vcr_cassettes/Stripe-v10.2.0/Spree_Gateway_StripeSCA/_purchase/provides_an_error_message_to_help_developer_debug.yml @@ -14,7 +14,7 @@ http_interactions: Content-Type: - application/x-www-form-urlencoded X-Stripe-Client-Telemetry: - - '{"last_request_metrics":{"request_id":"req_AY1AvcFROeAfTp","request_duration_ms":347}}' + - '{"last_request_metrics":{"request_id":"req_2hI8JKOwY7kSNH","request_duration_ms":434}}' Stripe-Version: - '2023-10-16' X-Stripe-Client-User-Agent: @@ -34,7 +34,7 @@ http_interactions: Server: - nginx Date: - - Mon, 11 Dec 2023 21:50:51 GMT + - Tue, 12 Dec 2023 13:16:36 GMT Content-Type: - application/json Content-Length: @@ -59,11 +59,11 @@ http_interactions: default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' Idempotency-Key: - - 47e4c0fb-44e8-4db6-97b0-d64112d4046d + - 4a150ad2-88fe-4533-a7bc-1fa073f32a9b Original-Request: - - req_RbBkJRyrViOJXY + - req_162AvbiORsNRF5 Request-Id: - - req_RbBkJRyrViOJXY + - req_162AvbiORsNRF5 Stripe-Should-Retry: - 'false' Stripe-Version: @@ -78,7 +78,7 @@ http_interactions: encoding: UTF-8 string: |- { - "id": "pm_1OMHNHKuuB1fWySn3IPVEgHw", + "id": "pm_1OMVpAKuuB1fWySnqhQjziYH", "object": "payment_method", "billing_details": { "address": { @@ -118,19 +118,19 @@ http_interactions: }, "wallet": null }, - "created": 1702331451, + "created": 1702386996, "customer": null, "livemode": false, "metadata": {}, "type": "card" } - recorded_at: Mon, 11 Dec 2023 21:50:51 GMT + recorded_at: Tue, 12 Dec 2023 13:16:37 GMT - request: method: post uri: https://api.stripe.com/v1/payment_intents body: encoding: UTF-8 - string: amount=1000¤cy=aud&payment_method=pm_1OMHNHKuuB1fWySn3IPVEgHw&payment_method_types[0]=card&capture_method=manual + string: amount=1000¤cy=aud&payment_method=pm_1OMVpAKuuB1fWySnqhQjziYH&payment_method_types[0]=card&capture_method=manual headers: User-Agent: - Stripe/v1 RubyBindings/10.2.0 @@ -139,7 +139,7 @@ http_interactions: Content-Type: - application/x-www-form-urlencoded X-Stripe-Client-Telemetry: - - '{"last_request_metrics":{"request_id":"req_RbBkJRyrViOJXY","request_duration_ms":478}}' + - '{"last_request_metrics":{"request_id":"req_162AvbiORsNRF5","request_duration_ms":639}}' Stripe-Version: - '2023-10-16' X-Stripe-Client-User-Agent: @@ -159,7 +159,7 @@ http_interactions: Server: - nginx Date: - - Mon, 11 Dec 2023 21:50:52 GMT + - Tue, 12 Dec 2023 13:16:37 GMT Content-Type: - application/json Content-Length: @@ -184,11 +184,11 @@ http_interactions: default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' Idempotency-Key: - - 50fc3198-f2d6-4727-b516-731726442667 + - 491db942-7198-4ee3-8423-a903b73b87ac Original-Request: - - req_HjHfVysPjs01jM + - req_f9tvJ0rgpXxio1 Request-Id: - - req_HjHfVysPjs01jM + - req_f9tvJ0rgpXxio1 Stripe-Should-Retry: - 'false' Stripe-Version: @@ -203,7 +203,7 @@ http_interactions: encoding: UTF-8 string: |- { - "id": "pi_3OMHNHKuuB1fWySn1oPNtGzx", + "id": "pi_3OMVpBKuuB1fWySn0QfFlIV8", "object": "payment_intent", "amount": 1000, "amount_capturable": 0, @@ -217,9 +217,9 @@ http_interactions: "canceled_at": null, "cancellation_reason": null, "capture_method": "manual", - "client_secret": "pi_3OMHNHKuuB1fWySn1oPNtGzx_secret_i1rN6p1XtyEpiGRt24Jwpkzkp", + "client_secret": "pi_3OMVpBKuuB1fWySn0QfFlIV8_secret_bUDMPJVVChVdfO3y49EbdwwxL", "confirmation_method": "automatic", - "created": 1702331451, + "created": 1702386997, "currency": "aud", "customer": null, "description": null, @@ -230,7 +230,7 @@ http_interactions: "metadata": {}, "next_action": null, "on_behalf_of": null, - "payment_method": "pm_1OMHNHKuuB1fWySn3IPVEgHw", + "payment_method": "pm_1OMVpAKuuB1fWySnqhQjziYH", "payment_method_configuration_details": null, "payment_method_options": { "card": { @@ -255,10 +255,10 @@ http_interactions: "transfer_data": null, "transfer_group": null } - recorded_at: Mon, 11 Dec 2023 21:50:52 GMT + recorded_at: Tue, 12 Dec 2023 13:16:37 GMT - request: method: post - uri: https://api.stripe.com/v1/payment_intents/pi_3OMHNHKuuB1fWySn1oPNtGzx/confirm + uri: https://api.stripe.com/v1/payment_intents/pi_3OMVpBKuuB1fWySn0QfFlIV8/confirm body: encoding: US-ASCII string: '' @@ -270,7 +270,7 @@ http_interactions: Content-Type: - application/x-www-form-urlencoded X-Stripe-Client-Telemetry: - - '{"last_request_metrics":{"request_id":"req_HjHfVysPjs01jM","request_duration_ms":406}}' + - '{"last_request_metrics":{"request_id":"req_f9tvJ0rgpXxio1","request_duration_ms":406}}' Stripe-Version: - '2023-10-16' X-Stripe-Client-User-Agent: @@ -290,7 +290,7 @@ http_interactions: Server: - nginx Date: - - Mon, 11 Dec 2023 21:50:53 GMT + - Tue, 12 Dec 2023 13:16:38 GMT Content-Type: - application/json Content-Length: @@ -316,11 +316,11 @@ http_interactions: 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' Idempotency-Key: - - 37c3e7b7-e6e5-40c7-912d-c377bf35f461 + - f34fdfb3-c2c1-423f-b39f-3e4692e0ec24 Original-Request: - - req_yPW1h61ihGksLY + - req_kEuP9BShlEJBEh Request-Id: - - req_yPW1h61ihGksLY + - req_kEuP9BShlEJBEh Stripe-Should-Retry: - 'false' Stripe-Version: @@ -335,7 +335,7 @@ http_interactions: encoding: UTF-8 string: |- { - "id": "pi_3OMHNHKuuB1fWySn1oPNtGzx", + "id": "pi_3OMVpBKuuB1fWySn0QfFlIV8", "object": "payment_intent", "amount": 1000, "amount_capturable": 1000, @@ -349,20 +349,20 @@ http_interactions: "canceled_at": null, "cancellation_reason": null, "capture_method": "manual", - "client_secret": "pi_3OMHNHKuuB1fWySn1oPNtGzx_secret_i1rN6p1XtyEpiGRt24Jwpkzkp", + "client_secret": "pi_3OMVpBKuuB1fWySn0QfFlIV8_secret_bUDMPJVVChVdfO3y49EbdwwxL", "confirmation_method": "automatic", - "created": 1702331451, + "created": 1702386997, "currency": "aud", "customer": null, "description": null, "invoice": null, "last_payment_error": null, - "latest_charge": "ch_3OMHNHKuuB1fWySn1fcp4UKj", + "latest_charge": "ch_3OMVpBKuuB1fWySn01HyMd2n", "livemode": false, "metadata": {}, "next_action": null, "on_behalf_of": null, - "payment_method": "pm_1OMHNHKuuB1fWySn3IPVEgHw", + "payment_method": "pm_1OMVpAKuuB1fWySnqhQjziYH", "payment_method_configuration_details": null, "payment_method_options": { "card": { @@ -387,5 +387,5 @@ http_interactions: "transfer_data": null, "transfer_group": null } - recorded_at: Mon, 11 Dec 2023 21:50:53 GMT + recorded_at: Tue, 12 Dec 2023 13:16:38 GMT recorded_with: VCR 6.2.0 diff --git a/spec/models/spree/gateway/stripe_sca_spec.rb b/spec/models/spree/gateway/stripe_sca_spec.rb index 252639cdd5..645733134c 100644 --- a/spec/models/spree/gateway/stripe_sca_spec.rb +++ b/spec/models/spree/gateway/stripe_sca_spec.rb @@ -26,34 +26,33 @@ describe Spree::Gateway::StripeSCA, type: :model do { order_id: order.number } } + before { Stripe.api_key = secret } + + let(:pm_card) do + Stripe::PaymentMethod.create({ + type: 'card', + card: { + number: '4242424242424242', + exp_month: 12, + exp_year: year_valid, + cvc: '314', + }, + }) + end + let(:payment_intent) do + Stripe::PaymentIntent.create({ + amount: 1000, # given in AUD cents + currency: 'aud', # AUD to match order currency + payment_method: pm_card, + payment_method_types: ['card'], + capture_method: 'manual', + }) + end + describe "#purchase", :vcr, :stripe_version do - before { Stripe.api_key = secret } - - let!(:pm_card) do - Stripe::PaymentMethod.create({ - type: 'card', - card: { - number: '4242424242424242', - exp_month: 12, - exp_year: year_valid, - cvc: '314', - }, - }) - end - let!(:payment_intent) do - Stripe::PaymentIntent.create({ - amount: 1000, # given in AUD cents - currency: 'aud', # AUD to match order currency - payment_method: pm_card, - payment_method_types: ['card'], - capture_method: 'manual', - }) - end - # Stripe acepts amounts as positive integers representing how much to charge # in the smallest currency unit - let(:capture_amount) { order.total.to_i * 10 } - let(:response) { subject.purchase(capture_amount, credit_card, gateway_options) } + let(:capture_amount) { order.total.to_i * 100 } # order total is 10 AUD before do # confirms the payment @@ -63,13 +62,7 @@ describe Spree::Gateway::StripeSCA, type: :model do it "completes the purchase" do payment - expect { - response.to - change( - Stripe::PaymentIntent.retrieve(payment_intent.id).status - ).from("requires_capture").to("suceeded") - } - + response = subject.purchase(capture_amount, credit_card, gateway_options) expect(response.success?).to eq true end @@ -81,30 +74,7 @@ describe Spree::Gateway::StripeSCA, type: :model do end end - context "#error message", :vcr, :stripe_version do - before { Stripe.api_key = secret } - - let!(:pm_card) do - Stripe::PaymentMethod.create({ - type: 'card', - card: { - number: '4242424242424242', - exp_month: 12, - exp_year: year_valid, - cvc: '314', - }, - }) - end - let!(:payment_intent) do - Stripe::PaymentIntent.create({ - amount: 1000, # given in AUD cents - currency: 'aud', # AUD to match order currency - payment_method: pm_card, - payment_method_types: ['card'], - capture_method: 'manual', - }) - end - + describe "#error message", :vcr, :stripe_version do context "when payment intent state is not in 'requires_capture' state" do before do payment