From baef7de663bcc2d657d9d7063186b3dbe3566a8a Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Tue, 23 Jan 2024 12:23:59 +0000 Subject: [PATCH 1/3] Replaces stubs with real accounts and card ids The second example on this sepec is commented out, and will be addressed on the following commit Sets user email We need to set an email for the user we're creating; if we don't, then each time we run the spec, a new user will be created with a random email - as per user factory. This will translate in a (slightly) different HTTP request each time the spec is ran, and will cause a VCR recording error as new cassettes cannot be recorded in under the CI. Re-recordes cassette after rebase --- .../clones_the_payment_method_only.yml | 659 ++++++++++++++++++ .../clones_the_payment_method_only.yml | 659 ++++++++++++++++++ spec/lib/stripe/credit_card_cloner_spec.rb | 74 +- 3 files changed, 1355 insertions(+), 37 deletions(-) create mode 100644 spec/fixtures/vcr_cassettes/Stripe-v10.3.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_card_without_a_customer_one_time_usage_card_/clones_the_payment_method_only.yml create mode 100644 spec/fixtures/vcr_cassettes/Stripe-v10.6.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_card_without_a_customer_one_time_usage_card_/clones_the_payment_method_only.yml diff --git a/spec/fixtures/vcr_cassettes/Stripe-v10.3.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_card_without_a_customer_one_time_usage_card_/clones_the_payment_method_only.yml b/spec/fixtures/vcr_cassettes/Stripe-v10.3.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_card_without_a_customer_one_time_usage_card_/clones_the_payment_method_only.yml new file mode 100644 index 0000000000..81ce9818ae --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Stripe-v10.3.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_card_without_a_customer_one_time_usage_card_/clones_the_payment_method_only.yml @@ -0,0 +1,659 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.stripe.com/v1/accounts + body: + encoding: UTF-8 + string: type=standard&country=AU&email=jumping.jack%40example.com + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.3.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.3.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Tue, 23 Jan 2024 16:23:55 GMT + Content-Type: + - application/json + Content-Length: + - '2916' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Faccounts; block-all-mixed-content; + 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: + - b7f8337e-7418-47e7-896b-a01d7e53f450 + Original-Request: + - req_ETps93mntx0Hji + Request-Id: + - req_ETps93mntx0Hji + Stripe-Should-Retry: + - 'false' + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "acct_1ObmlRQRhBsuAoMF", + "object": "account", + "business_profile": { + "mcc": null, + "name": null, + "product_description": null, + "support_address": null, + "support_email": null, + "support_phone": null, + "support_url": null, + "url": null + }, + "business_type": null, + "capabilities": {}, + "charges_enabled": false, + "controller": { + "is_controller": true, + "type": "application" + }, + "country": "AU", + "created": 1706027034, + "default_currency": "aud", + "details_submitted": false, + "email": "jumping.jack@example.com", + "external_accounts": { + "object": "list", + "data": [], + "has_more": false, + "total_count": 0, + "url": "/v1/accounts/acct_1ObmlRQRhBsuAoMF/external_accounts" + }, + "future_requirements": { + "alternatives": [], + "current_deadline": null, + "currently_due": [], + "disabled_reason": null, + "errors": [], + "eventually_due": [], + "past_due": [], + "pending_verification": [] + }, + "metadata": {}, + "payouts_enabled": false, + "requirements": { + "alternatives": [], + "current_deadline": null, + "currently_due": [ + "business_profile.product_description", + "business_profile.support_phone", + "business_profile.url", + "external_account", + "tos_acceptance.date", + "tos_acceptance.ip" + ], + "disabled_reason": "requirements.past_due", + "errors": [], + "eventually_due": [ + "business_profile.product_description", + "business_profile.support_phone", + "business_profile.url", + "external_account", + "tos_acceptance.date", + "tos_acceptance.ip" + ], + "past_due": [ + "external_account", + "tos_acceptance.date", + "tos_acceptance.ip" + ], + "pending_verification": [] + }, + "settings": { + "bacs_debit_payments": { + "display_name": null, + "service_user_number": null + }, + "branding": { + "icon": null, + "logo": null, + "primary_color": null, + "secondary_color": null + }, + "card_issuing": { + "tos_acceptance": { + "date": null, + "ip": null + } + }, + "card_payments": { + "decline_on": { + "avs_failure": false, + "cvc_failure": false + }, + "statement_descriptor_prefix": null, + "statement_descriptor_prefix_kana": null, + "statement_descriptor_prefix_kanji": null + }, + "dashboard": { + "display_name": null, + "timezone": "Etc/UTC" + }, + "payments": { + "statement_descriptor": null, + "statement_descriptor_kana": null, + "statement_descriptor_kanji": null + }, + "payouts": { + "debit_negative_balances": true, + "schedule": { + "delay_days": 2, + "interval": "daily" + }, + "statement_descriptor": null + }, + "sepa_debit_payments": {} + }, + "tos_acceptance": { + "date": null, + "ip": null, + "user_agent": null + }, + "type": "standard" + } + recorded_at: Tue, 23 Jan 2024 16:23:55 GMT +- request: + method: post + uri: https://api.stripe.com/v1/payment_methods + body: + encoding: UTF-8 + string: type=card&card[number]=4242424242424242&card[exp_month]=8&card[exp_year]=2026&card[cvc]=314 + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.3.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_ETps93mntx0Hji","request_duration_ms":1924}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.3.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Tue, 23 Jan 2024 16:23:55 GMT + Content-Type: + - application/json + Content-Length: + - '930' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_methods; block-all-mixed-content; + 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: + - f365ffc1-ce6c-4692-9cc1-adc6fc462c72 + Original-Request: + - req_fWgeyCgbxGQaGe + Request-Id: + - req_fWgeyCgbxGQaGe + Stripe-Should-Retry: + - 'false' + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "pm_1ObmlTKuuB1fWySnPG0TmSeT", + "object": "payment_method", + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": null, + "phone": null + }, + "card": { + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "unchecked" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2026, + "fingerprint": "6E6tgVjx6U65iHFV", + "funding": "credit", + "generated_from": null, + "last4": "4242", + "networks": { + "available": [ + "visa" + ], + "preferred": null + }, + "three_d_secure_usage": { + "supported": true + }, + "wallet": null + }, + "created": 1706027035, + "customer": null, + "livemode": false, + "metadata": {}, + "type": "card" + } + recorded_at: Tue, 23 Jan 2024 16:23:55 GMT +- request: + method: get + uri: https://api.stripe.com/v1/payment_methods/pm_1ObmlTKuuB1fWySnPG0TmSeT + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.3.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_fWgeyCgbxGQaGe","request_duration_ms":568}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.3.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Tue, 23 Jan 2024 16:23:55 GMT + Content-Type: + - application/json + Content-Length: + - '930' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_methods%2F%3Apayment_method; + block-all-mixed-content; default-src 'none'; base-uri 'none'; form-action + 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; + style-src 'self' + Request-Id: + - req_aGxstt0cKMvnS7 + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "pm_1ObmlTKuuB1fWySnPG0TmSeT", + "object": "payment_method", + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": null, + "phone": null + }, + "card": { + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "unchecked" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2026, + "fingerprint": "6E6tgVjx6U65iHFV", + "funding": "credit", + "generated_from": null, + "last4": "4242", + "networks": { + "available": [ + "visa" + ], + "preferred": null + }, + "three_d_secure_usage": { + "supported": true + }, + "wallet": null + }, + "created": 1706027035, + "customer": null, + "livemode": false, + "metadata": {}, + "type": "card" + } + recorded_at: Tue, 23 Jan 2024 16:23:56 GMT +- request: + method: get + uri: https://api.stripe.com/v1/customers?email=jumping.jane@example.com&limit=100 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.3.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_aGxstt0cKMvnS7","request_duration_ms":256}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.3.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Stripe-Account: + - acct_1ObmlRQRhBsuAoMF + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Tue, 23 Jan 2024 16:23:56 GMT + Content-Type: + - application/json + Content-Length: + - '83' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fcustomers; block-all-mixed-content; + default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; + img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' + Request-Id: + - req_ldrBEz4VKjd4on + Stripe-Account: + - acct_1ObmlRQRhBsuAoMF + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "object": "list", + "data": [], + "has_more": false, + "url": "/v1/customers" + } + recorded_at: Tue, 23 Jan 2024 16:23:56 GMT +- request: + method: post + uri: https://api.stripe.com/v1/payment_methods + body: + encoding: UTF-8 + string: payment_method=pm_1ObmlTKuuB1fWySnPG0TmSeT + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.3.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_ldrBEz4VKjd4on","request_duration_ms":270}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.3.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Stripe-Account: + - acct_1ObmlRQRhBsuAoMF + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Tue, 23 Jan 2024 16:23:56 GMT + Content-Type: + - application/json + Content-Length: + - '930' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_methods; block-all-mixed-content; + 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: + - 4ae80a5e-73f5-43b0-a389-cf48d73a005e + Original-Request: + - req_PsTG3WUYVeOUSW + Request-Id: + - req_PsTG3WUYVeOUSW + Stripe-Account: + - acct_1ObmlRQRhBsuAoMF + Stripe-Should-Retry: + - 'false' + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "pm_1ObmlUQRhBsuAoMFqUKGOj9C", + "object": "payment_method", + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": null, + "phone": null + }, + "card": { + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "unchecked" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2026, + "fingerprint": "6E6tgVjx6U65iHFV", + "funding": "credit", + "generated_from": null, + "last4": "4242", + "networks": { + "available": [ + "visa" + ], + "preferred": null + }, + "three_d_secure_usage": { + "supported": true + }, + "wallet": null + }, + "created": 1706027036, + "customer": null, + "livemode": false, + "metadata": {}, + "type": "card" + } + recorded_at: Tue, 23 Jan 2024 16:23:56 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Stripe-v10.6.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_card_without_a_customer_one_time_usage_card_/clones_the_payment_method_only.yml b/spec/fixtures/vcr_cassettes/Stripe-v10.6.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_card_without_a_customer_one_time_usage_card_/clones_the_payment_method_only.yml new file mode 100644 index 0000000000..aff61dd099 --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Stripe-v10.6.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_card_without_a_customer_one_time_usage_card_/clones_the_payment_method_only.yml @@ -0,0 +1,659 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.stripe.com/v1/accounts + body: + encoding: UTF-8 + string: type=standard&country=AU&email=jumping.jack%40example.com + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Tue, 23 Jan 2024 19:23:21 GMT + Content-Type: + - application/json + Content-Length: + - '2916' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Faccounts; block-all-mixed-content; + 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: + - 8f1b3850-a1dd-4f73-b686-1e4878660618 + Original-Request: + - req_ArKeOfud2NglOr + Request-Id: + - req_ArKeOfud2NglOr + Stripe-Should-Retry: + - 'false' + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "acct_1ObpZ5QMosbTbGGp", + "object": "account", + "business_profile": { + "mcc": null, + "name": null, + "product_description": null, + "support_address": null, + "support_email": null, + "support_phone": null, + "support_url": null, + "url": null + }, + "business_type": null, + "capabilities": {}, + "charges_enabled": false, + "controller": { + "is_controller": true, + "type": "application" + }, + "country": "AU", + "created": 1706037800, + "default_currency": "aud", + "details_submitted": false, + "email": "jumping.jack@example.com", + "external_accounts": { + "object": "list", + "data": [], + "has_more": false, + "total_count": 0, + "url": "/v1/accounts/acct_1ObpZ5QMosbTbGGp/external_accounts" + }, + "future_requirements": { + "alternatives": [], + "current_deadline": null, + "currently_due": [], + "disabled_reason": null, + "errors": [], + "eventually_due": [], + "past_due": [], + "pending_verification": [] + }, + "metadata": {}, + "payouts_enabled": false, + "requirements": { + "alternatives": [], + "current_deadline": null, + "currently_due": [ + "business_profile.product_description", + "business_profile.support_phone", + "business_profile.url", + "external_account", + "tos_acceptance.date", + "tos_acceptance.ip" + ], + "disabled_reason": "requirements.past_due", + "errors": [], + "eventually_due": [ + "business_profile.product_description", + "business_profile.support_phone", + "business_profile.url", + "external_account", + "tos_acceptance.date", + "tos_acceptance.ip" + ], + "past_due": [ + "external_account", + "tos_acceptance.date", + "tos_acceptance.ip" + ], + "pending_verification": [] + }, + "settings": { + "bacs_debit_payments": { + "display_name": null, + "service_user_number": null + }, + "branding": { + "icon": null, + "logo": null, + "primary_color": null, + "secondary_color": null + }, + "card_issuing": { + "tos_acceptance": { + "date": null, + "ip": null + } + }, + "card_payments": { + "decline_on": { + "avs_failure": false, + "cvc_failure": false + }, + "statement_descriptor_prefix": null, + "statement_descriptor_prefix_kana": null, + "statement_descriptor_prefix_kanji": null + }, + "dashboard": { + "display_name": null, + "timezone": "Etc/UTC" + }, + "payments": { + "statement_descriptor": null, + "statement_descriptor_kana": null, + "statement_descriptor_kanji": null + }, + "payouts": { + "debit_negative_balances": true, + "schedule": { + "delay_days": 2, + "interval": "daily" + }, + "statement_descriptor": null + }, + "sepa_debit_payments": {} + }, + "tos_acceptance": { + "date": null, + "ip": null, + "user_agent": null + }, + "type": "standard" + } + recorded_at: Tue, 23 Jan 2024 19:23:20 GMT +- request: + method: post + uri: https://api.stripe.com/v1/payment_methods + body: + encoding: UTF-8 + string: type=card&card[number]=4242424242424242&card[exp_month]=8&card[exp_year]=2026&card[cvc]=314 + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_ArKeOfud2NglOr","request_duration_ms":1929}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Tue, 23 Jan 2024 19:23:21 GMT + Content-Type: + - application/json + Content-Length: + - '930' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_methods; block-all-mixed-content; + 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: + - 7d5381be-93c7-434e-b812-d8dcc93632da + Original-Request: + - req_rbQOoGTa5UrjC7 + Request-Id: + - req_rbQOoGTa5UrjC7 + Stripe-Should-Retry: + - 'false' + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "pm_1ObpZ7KuuB1fWySnrmcoZUIL", + "object": "payment_method", + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": null, + "phone": null + }, + "card": { + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "unchecked" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2026, + "fingerprint": "6E6tgVjx6U65iHFV", + "funding": "credit", + "generated_from": null, + "last4": "4242", + "networks": { + "available": [ + "visa" + ], + "preferred": null + }, + "three_d_secure_usage": { + "supported": true + }, + "wallet": null + }, + "created": 1706037801, + "customer": null, + "livemode": false, + "metadata": {}, + "type": "card" + } + recorded_at: Tue, 23 Jan 2024 19:23:21 GMT +- request: + method: get + uri: https://api.stripe.com/v1/payment_methods/pm_1ObpZ7KuuB1fWySnrmcoZUIL + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_rbQOoGTa5UrjC7","request_duration_ms":550}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Tue, 23 Jan 2024 19:23:21 GMT + Content-Type: + - application/json + Content-Length: + - '930' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_methods%2F%3Apayment_method; + block-all-mixed-content; default-src 'none'; base-uri 'none'; form-action + 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; + style-src 'self' + Request-Id: + - req_tD2jNZUIi37ala + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "pm_1ObpZ7KuuB1fWySnrmcoZUIL", + "object": "payment_method", + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": null, + "phone": null + }, + "card": { + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "unchecked" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2026, + "fingerprint": "6E6tgVjx6U65iHFV", + "funding": "credit", + "generated_from": null, + "last4": "4242", + "networks": { + "available": [ + "visa" + ], + "preferred": null + }, + "three_d_secure_usage": { + "supported": true + }, + "wallet": null + }, + "created": 1706037801, + "customer": null, + "livemode": false, + "metadata": {}, + "type": "card" + } + recorded_at: Tue, 23 Jan 2024 19:23:21 GMT +- request: + method: get + uri: https://api.stripe.com/v1/customers?email=jumping.jane@example.com&limit=100 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_tD2jNZUIi37ala","request_duration_ms":283}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Stripe-Account: + - acct_1ObpZ5QMosbTbGGp + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Tue, 23 Jan 2024 19:23:22 GMT + Content-Type: + - application/json + Content-Length: + - '83' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fcustomers; block-all-mixed-content; + default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; + img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' + Request-Id: + - req_nSE8yTXOiTaswf + Stripe-Account: + - acct_1ObpZ5QMosbTbGGp + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "object": "list", + "data": [], + "has_more": false, + "url": "/v1/customers" + } + recorded_at: Tue, 23 Jan 2024 19:23:21 GMT +- request: + method: post + uri: https://api.stripe.com/v1/payment_methods + body: + encoding: UTF-8 + string: payment_method=pm_1ObpZ7KuuB1fWySnrmcoZUIL + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_nSE8yTXOiTaswf","request_duration_ms":267}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Stripe-Account: + - acct_1ObpZ5QMosbTbGGp + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Tue, 23 Jan 2024 19:23:22 GMT + Content-Type: + - application/json + Content-Length: + - '930' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_methods; block-all-mixed-content; + 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: + - 160a8b03-ea8b-47f3-bb3a-a4e69b1b581b + Original-Request: + - req_v24HYtitixMxPc + Request-Id: + - req_v24HYtitixMxPc + Stripe-Account: + - acct_1ObpZ5QMosbTbGGp + Stripe-Should-Retry: + - 'false' + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "pm_1ObpZ8QMosbTbGGpr6Iu8ClG", + "object": "payment_method", + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": null, + "phone": null + }, + "card": { + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "unchecked" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2026, + "fingerprint": "6E6tgVjx6U65iHFV", + "funding": "credit", + "generated_from": null, + "last4": "4242", + "networks": { + "available": [ + "visa" + ], + "preferred": null + }, + "three_d_secure_usage": { + "supported": true + }, + "wallet": null + }, + "created": 1706037802, + "customer": null, + "livemode": false, + "metadata": {}, + "type": "card" + } + recorded_at: Tue, 23 Jan 2024 19:23:22 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/lib/stripe/credit_card_cloner_spec.rb b/spec/lib/stripe/credit_card_cloner_spec.rb index 1e80849873..3037846f1d 100644 --- a/spec/lib/stripe/credit_card_cloner_spec.rb +++ b/spec/lib/stripe/credit_card_cloner_spec.rb @@ -5,62 +5,62 @@ require 'stripe/credit_card_cloner' module Stripe describe CreditCardCloner do - describe "#find_or_clone" do + let!(:user) { create(:user, email: "jumping.jane@example.com") } + let!(:enterprise) { create(:enterprise) } + + let(:secret) { ENV.fetch('STRIPE_SECRET_TEST_API_KEY', nil) } + + describe "#find_or_clone", :vcr, :stripe_version do include StripeStubs - let(:credit_card) { create(:credit_card, user: create(:user)) } - let(:stripe_account_id) { "abc123" } + before { Stripe.api_key = secret } - let(:cloner) { Stripe::CreditCardCloner.new(credit_card, stripe_account_id) } + let!(:customer_id) { ENV.fetch('STRIPE_CUSTOMER', nil) } - let(:customer_id) { "cus_A123" } - let(:payment_method_id) { "pm_1234" } - let(:new_customer_id) { "cus_A456" } - let(:new_payment_method_id) { "pm_456" } - let(:payment_method_response_mock) { { status: 200, body: payment_method_response_body } } + let!(:stripe_account_id) { ENV.fetch('STRIPE_ACCOUNT', nil) } - let(:payment_method_response_body) { - JSON.generate(id: new_payment_method_id) + let!(:stripe_account) { + create(:stripe_account, enterprise:, stripe_user_id: stripe_account_id) } - before do - Stripe.api_key = "sk_test_12345" + let(:credit_card) { create(:credit_card, gateway_payment_profile_id: pm_card.id, user:) } - stub_customers_post_request email: credit_card.user.email, - response: { customer_id: new_customer_id }, - stripe_account_header: true + let(:pm_card) { + Stripe::PaymentMethod.create( + { + type: 'card', + card: { + number: '4242424242424242', + exp_month: 8, + exp_year: 2026, + cvc: '314', + }, + }, + ) + } - stub_retrieve_payment_method_request(payment_method_id) - stub_list_customers_request(email: credit_card.user.email, response: {}) - stub_get_customer_payment_methods_request(customer: "cus_A456", response: {}) - stub_add_metadata_request(payment_method: "pm_456", response: {}) - - stub_request(:post, - "https://api.stripe.com/v1/payment_methods/#{new_payment_method_id}/attach") - .with(body: { customer: new_customer_id }, - headers: { 'Stripe-Account' => stripe_account_id }) - .to_return(payment_method_response_mock) - - credit_card.update_attribute :gateway_payment_profile_id, payment_method_id + let!(:connected_account) do + Stripe::Account.create({ + type: 'standard', + country: 'AU', + email: 'jumping.jack@example.com' + }) end + let!(:cloner) { Stripe::CreditCardCloner.new(credit_card, connected_account.id) } + context "when called with a card without a customer (one time usage card)" do - before do - stub_request(:post, "https://api.stripe.com/v1/payment_methods") - .with(body: { payment_method: payment_method_id }, - headers: { 'Stripe-Account' => stripe_account_id }) - .to_return(payment_method_response_mock) - end + let!(:payment_method_id) { pm_card.id } it "clones the payment method only" do - customer_id, payment_method_id = cloner.find_or_clone + customer_id, new_payment_method_id = cloner.find_or_clone - expect(payment_method_id).to eq new_payment_method_id + expect(payment_method_id).not_to eq new_payment_method_id expect(customer_id).to eq nil end end - context "when called with a valid customer and payment_method" do + xcontext "when called with a valid customer and payment_method" do before do stub_request(:post, "https://api.stripe.com/v1/payment_methods") .with(body: { customer: customer_id, payment_method: payment_method_id }, From 3e734f1e6b942ba8e3a8476d6df5d2115182dec4 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 24 Jan 2024 13:21:11 +0000 Subject: [PATCH 2/3] Attaches customer to payment method and clones payment method Improves naming of actors; improves assertions --- .../clones_the_payment_method_only.yml | 326 ++--- ...th_the_payment_method_and_the_customer.yml | 1162 +++++++++++++++++ spec/lib/stripe/credit_card_cloner_spec.rb | 40 +- 3 files changed, 1350 insertions(+), 178 deletions(-) create mode 100644 spec/fixtures/vcr_cassettes/Stripe-v10.6.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_valid_customer_and_payment_method/clones_both_the_payment_method_and_the_customer.yml diff --git a/spec/fixtures/vcr_cassettes/Stripe-v10.6.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_card_without_a_customer_one_time_usage_card_/clones_the_payment_method_only.yml b/spec/fixtures/vcr_cassettes/Stripe-v10.6.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_card_without_a_customer_one_time_usage_card_/clones_the_payment_method_only.yml index aff61dd099..8d31b0f5d8 100644 --- a/spec/fixtures/vcr_cassettes/Stripe-v10.6.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_card_without_a_customer_one_time_usage_card_/clones_the_payment_method_only.yml +++ b/spec/fixtures/vcr_cassettes/Stripe-v10.6.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_card_without_a_customer_one_time_usage_card_/clones_the_payment_method_only.yml @@ -2,10 +2,10 @@ http_interactions: - request: method: post - uri: https://api.stripe.com/v1/accounts + uri: https://api.stripe.com/v1/payment_methods body: encoding: UTF-8 - string: type=standard&country=AU&email=jumping.jack%40example.com + string: type=card&card[number]=4242424242424242&card[exp_month]=8&card[exp_year]=2026&card[cvc]=314 headers: User-Agent: - Stripe/v1 RubyBindings/10.6.0 @@ -32,11 +32,136 @@ http_interactions: Server: - nginx Date: - - Tue, 23 Jan 2024 19:23:21 GMT + - Thu, 25 Jan 2024 18:15:25 GMT Content-Type: - application/json Content-Length: - - '2916' + - '930' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_methods; block-all-mixed-content; + 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: + - 6856a62e-df28-4b1d-94f6-1c8f414ed395 + Original-Request: + - req_c3s0KF7b8dOapp + Request-Id: + - req_c3s0KF7b8dOapp + Stripe-Should-Retry: + - 'false' + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "pm_1OcXSTKuuB1fWySn5Ri5Zqfi", + "object": "payment_method", + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": null, + "phone": null + }, + "card": { + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "unchecked" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2026, + "fingerprint": "6E6tgVjx6U65iHFV", + "funding": "credit", + "generated_from": null, + "last4": "4242", + "networks": { + "available": [ + "visa" + ], + "preferred": null + }, + "three_d_secure_usage": { + "supported": true + }, + "wallet": null + }, + "created": 1706206525, + "customer": null, + "livemode": false, + "metadata": {}, + "type": "card" + } + recorded_at: Thu, 25 Jan 2024 18:15:25 GMT +- request: + method: post + uri: https://api.stripe.com/v1/accounts + body: + encoding: UTF-8 + string: type=standard&country=AU&email=apple.producer%40example.com + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_c3s0KF7b8dOapp","request_duration_ms":666}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Thu, 25 Jan 2024 18:15:27 GMT + Content-Type: + - application/json + Content-Length: + - '2982' Connection: - keep-alive Access-Control-Allow-Credentials: @@ -57,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: - - 8f1b3850-a1dd-4f73-b686-1e4878660618 + - e6d81e18-0a21-4970-925c-d2934bf80914 Original-Request: - - req_ArKeOfud2NglOr + - req_el99nPdh6DgbX6 Request-Id: - - req_ArKeOfud2NglOr + - req_el99nPdh6DgbX6 Stripe-Should-Retry: - 'false' Stripe-Version: @@ -76,9 +201,11 @@ http_interactions: encoding: UTF-8 string: |- { - "id": "acct_1ObpZ5QMosbTbGGp", + "id": "acct_1OcXSTQK2Bh9Qahe", "object": "account", "business_profile": { + "annual_revenue": null, + "estimated_worker_count": null, "mcc": null, "name": null, "product_description": null, @@ -96,16 +223,16 @@ http_interactions: "type": "application" }, "country": "AU", - "created": 1706037800, + "created": 1706206526, "default_currency": "aud", "details_submitted": false, - "email": "jumping.jack@example.com", + "email": "apple.producer@example.com", "external_accounts": { "object": "list", "data": [], "has_more": false, "total_count": 0, - "url": "/v1/accounts/acct_1ObpZ5QMosbTbGGp/external_accounts" + "url": "/v1/accounts/acct_1OcXSTQK2Bh9Qahe/external_accounts" }, "future_requirements": { "alternatives": [], @@ -199,135 +326,10 @@ http_interactions: }, "type": "standard" } - recorded_at: Tue, 23 Jan 2024 19:23:20 GMT -- request: - method: post - uri: https://api.stripe.com/v1/payment_methods - body: - encoding: UTF-8 - string: type=card&card[number]=4242424242424242&card[exp_month]=8&card[exp_year]=2026&card[cvc]=314 - headers: - User-Agent: - - Stripe/v1 RubyBindings/10.6.0 - Authorization: - - Bearer - Content-Type: - - application/x-www-form-urlencoded - X-Stripe-Client-Telemetry: - - '{"last_request_metrics":{"request_id":"req_ArKeOfud2NglOr","request_duration_ms":1929}}' - Stripe-Version: - - '2023-10-16' - X-Stripe-Client-User-Agent: - - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux - version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 - (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) - #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - response: - status: - code: 200 - message: OK - headers: - Server: - - nginx - Date: - - Tue, 23 Jan 2024 19:23:21 GMT - Content-Type: - - application/json - Content-Length: - - '930' - Connection: - - keep-alive - Access-Control-Allow-Credentials: - - 'true' - Access-Control-Allow-Methods: - - GET,HEAD,PUT,PATCH,POST,DELETE - Access-Control-Allow-Origin: - - "*" - Access-Control-Expose-Headers: - - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, - X-Stripe-Privileged-Session-Required - Access-Control-Max-Age: - - '300' - Cache-Control: - - no-cache, no-store - Content-Security-Policy: - - report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_methods; block-all-mixed-content; - 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: - - 7d5381be-93c7-434e-b812-d8dcc93632da - Original-Request: - - req_rbQOoGTa5UrjC7 - Request-Id: - - req_rbQOoGTa5UrjC7 - Stripe-Should-Retry: - - 'false' - Stripe-Version: - - '2023-10-16' - Vary: - - Origin - X-Stripe-Routing-Context-Priority-Tier: - - api-testmode - Strict-Transport-Security: - - max-age=63072000; includeSubDomains; preload - body: - encoding: UTF-8 - string: |- - { - "id": "pm_1ObpZ7KuuB1fWySnrmcoZUIL", - "object": "payment_method", - "billing_details": { - "address": { - "city": null, - "country": null, - "line1": null, - "line2": null, - "postal_code": null, - "state": null - }, - "email": null, - "name": null, - "phone": null - }, - "card": { - "brand": "visa", - "checks": { - "address_line1_check": null, - "address_postal_code_check": null, - "cvc_check": "unchecked" - }, - "country": "US", - "exp_month": 8, - "exp_year": 2026, - "fingerprint": "6E6tgVjx6U65iHFV", - "funding": "credit", - "generated_from": null, - "last4": "4242", - "networks": { - "available": [ - "visa" - ], - "preferred": null - }, - "three_d_secure_usage": { - "supported": true - }, - "wallet": null - }, - "created": 1706037801, - "customer": null, - "livemode": false, - "metadata": {}, - "type": "card" - } - recorded_at: Tue, 23 Jan 2024 19:23:21 GMT + recorded_at: Thu, 25 Jan 2024 18:15:27 GMT - request: method: get - uri: https://api.stripe.com/v1/payment_methods/pm_1ObpZ7KuuB1fWySnrmcoZUIL + uri: https://api.stripe.com/v1/payment_methods/pm_1OcXSTKuuB1fWySn5Ri5Zqfi body: encoding: US-ASCII string: '' @@ -339,7 +341,7 @@ http_interactions: Content-Type: - application/x-www-form-urlencoded X-Stripe-Client-Telemetry: - - '{"last_request_metrics":{"request_id":"req_rbQOoGTa5UrjC7","request_duration_ms":550}}' + - '{"last_request_metrics":{"request_id":"req_el99nPdh6DgbX6","request_duration_ms":1994}}' Stripe-Version: - '2023-10-16' X-Stripe-Client-User-Agent: @@ -359,7 +361,7 @@ http_interactions: Server: - nginx Date: - - Tue, 23 Jan 2024 19:23:21 GMT + - Thu, 25 Jan 2024 18:15:27 GMT Content-Type: - application/json Content-Length: @@ -385,7 +387,7 @@ http_interactions: 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' Request-Id: - - req_tD2jNZUIi37ala + - req_ks2EKp9Z9EMNb4 Stripe-Version: - '2023-10-16' Vary: @@ -398,7 +400,7 @@ http_interactions: encoding: UTF-8 string: |- { - "id": "pm_1ObpZ7KuuB1fWySnrmcoZUIL", + "id": "pm_1OcXSTKuuB1fWySn5Ri5Zqfi", "object": "payment_method", "billing_details": { "address": { @@ -438,16 +440,16 @@ http_interactions: }, "wallet": null }, - "created": 1706037801, + "created": 1706206525, "customer": null, "livemode": false, "metadata": {}, "type": "card" } - recorded_at: Tue, 23 Jan 2024 19:23:21 GMT + recorded_at: Thu, 25 Jan 2024 18:15:27 GMT - request: method: get - uri: https://api.stripe.com/v1/customers?email=jumping.jane@example.com&limit=100 + uri: https://api.stripe.com/v1/customers?email=apple.customer@example.com&limit=100 body: encoding: US-ASCII string: '' @@ -459,7 +461,7 @@ http_interactions: Content-Type: - application/x-www-form-urlencoded X-Stripe-Client-Telemetry: - - '{"last_request_metrics":{"request_id":"req_tD2jNZUIi37ala","request_duration_ms":283}}' + - '{"last_request_metrics":{"request_id":"req_ks2EKp9Z9EMNb4","request_duration_ms":401}}' Stripe-Version: - '2023-10-16' X-Stripe-Client-User-Agent: @@ -468,7 +470,7 @@ http_interactions: (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' Stripe-Account: - - acct_1ObpZ5QMosbTbGGp + - acct_1OcXSTQK2Bh9Qahe Accept-Encoding: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 Accept: @@ -481,7 +483,7 @@ http_interactions: Server: - nginx Date: - - Tue, 23 Jan 2024 19:23:22 GMT + - Thu, 25 Jan 2024 18:15:28 GMT Content-Type: - application/json Content-Length: @@ -506,9 +508,9 @@ 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' Request-Id: - - req_nSE8yTXOiTaswf + - req_2BStYe8os69wxh Stripe-Account: - - acct_1ObpZ5QMosbTbGGp + - acct_1OcXSTQK2Bh9Qahe Stripe-Version: - '2023-10-16' Vary: @@ -526,13 +528,13 @@ http_interactions: "has_more": false, "url": "/v1/customers" } - recorded_at: Tue, 23 Jan 2024 19:23:21 GMT + recorded_at: Thu, 25 Jan 2024 18:15:28 GMT - request: method: post uri: https://api.stripe.com/v1/payment_methods body: encoding: UTF-8 - string: payment_method=pm_1ObpZ7KuuB1fWySnrmcoZUIL + string: payment_method=pm_1OcXSTKuuB1fWySn5Ri5Zqfi headers: User-Agent: - Stripe/v1 RubyBindings/10.6.0 @@ -541,7 +543,7 @@ http_interactions: Content-Type: - application/x-www-form-urlencoded X-Stripe-Client-Telemetry: - - '{"last_request_metrics":{"request_id":"req_nSE8yTXOiTaswf","request_duration_ms":267}}' + - '{"last_request_metrics":{"request_id":"req_2BStYe8os69wxh","request_duration_ms":304}}' Stripe-Version: - '2023-10-16' X-Stripe-Client-User-Agent: @@ -550,7 +552,7 @@ http_interactions: (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' Stripe-Account: - - acct_1ObpZ5QMosbTbGGp + - acct_1OcXSTQK2Bh9Qahe Accept-Encoding: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 Accept: @@ -563,7 +565,7 @@ http_interactions: Server: - nginx Date: - - Tue, 23 Jan 2024 19:23:22 GMT + - Thu, 25 Jan 2024 18:15:28 GMT Content-Type: - application/json Content-Length: @@ -588,13 +590,13 @@ 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: - - 160a8b03-ea8b-47f3-bb3a-a4e69b1b581b + - 46a9aa38-6e45-44ea-8175-1dd33870b676 Original-Request: - - req_v24HYtitixMxPc + - req_wr8dUxwCyfU1jE Request-Id: - - req_v24HYtitixMxPc + - req_wr8dUxwCyfU1jE Stripe-Account: - - acct_1ObpZ5QMosbTbGGp + - acct_1OcXSTQK2Bh9Qahe Stripe-Should-Retry: - 'false' Stripe-Version: @@ -609,7 +611,7 @@ http_interactions: encoding: UTF-8 string: |- { - "id": "pm_1ObpZ8QMosbTbGGpr6Iu8ClG", + "id": "pm_1OcXSWQK2Bh9QahelUGjee6K", "object": "payment_method", "billing_details": { "address": { @@ -649,11 +651,11 @@ http_interactions: }, "wallet": null }, - "created": 1706037802, + "created": 1706206528, "customer": null, "livemode": false, "metadata": {}, "type": "card" } - recorded_at: Tue, 23 Jan 2024 19:23:22 GMT + recorded_at: Thu, 25 Jan 2024 18:15:28 GMT recorded_with: VCR 6.2.0 diff --git a/spec/fixtures/vcr_cassettes/Stripe-v10.6.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_valid_customer_and_payment_method/clones_both_the_payment_method_and_the_customer.yml b/spec/fixtures/vcr_cassettes/Stripe-v10.6.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_valid_customer_and_payment_method/clones_both_the_payment_method_and_the_customer.yml new file mode 100644 index 0000000000..2fd5dc0a6b --- /dev/null +++ b/spec/fixtures/vcr_cassettes/Stripe-v10.6.0/Stripe_CreditCardCloner/_find_or_clone/when_called_with_a_valid_customer_and_payment_method/clones_both_the_payment_method_and_the_customer.yml @@ -0,0 +1,1162 @@ +--- +http_interactions: +- request: + method: post + uri: https://api.stripe.com/v1/payment_methods + body: + encoding: UTF-8 + string: type=card&card[number]=4242424242424242&card[exp_month]=8&card[exp_year]=2026&card[cvc]=314 + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_wr8dUxwCyfU1jE","request_duration_ms":408}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Thu, 25 Jan 2024 18:15:29 GMT + Content-Type: + - application/json + Content-Length: + - '930' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_methods; block-all-mixed-content; + 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: + - 8e664527-2224-45f6-91b5-87be23f04ed6 + Original-Request: + - req_AxXfntcstV1n76 + Request-Id: + - req_AxXfntcstV1n76 + Stripe-Should-Retry: + - 'false' + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "pm_1OcXSWKuuB1fWySnU9TPdXrK", + "object": "payment_method", + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": null, + "phone": null + }, + "card": { + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "unchecked" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2026, + "fingerprint": "6E6tgVjx6U65iHFV", + "funding": "credit", + "generated_from": null, + "last4": "4242", + "networks": { + "available": [ + "visa" + ], + "preferred": null + }, + "three_d_secure_usage": { + "supported": true + }, + "wallet": null + }, + "created": 1706206529, + "customer": null, + "livemode": false, + "metadata": {}, + "type": "card" + } + recorded_at: Thu, 25 Jan 2024 18:15:29 GMT +- request: + method: post + uri: https://api.stripe.com/v1/payment_methods/pm_1OcXSWKuuB1fWySnU9TPdXrK/attach + body: + encoding: UTF-8 + string: customer= + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_AxXfntcstV1n76","request_duration_ms":530}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Thu, 25 Jan 2024 18:15:29 GMT + Content-Type: + - application/json + Content-Length: + - '941' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_methods%2F%3Apayment_method%2Fattach; + block-all-mixed-content; 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: + - 1e976b47-0c50-460c-8f1d-b90437981a01 + Original-Request: + - req_yYPPR4rgjOokVi + Request-Id: + - req_yYPPR4rgjOokVi + Stripe-Should-Retry: + - 'false' + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "pm_1OcXSWKuuB1fWySnU9TPdXrK", + "object": "payment_method", + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": null, + "phone": null + }, + "card": { + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "pass" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2026, + "fingerprint": "6E6tgVjx6U65iHFV", + "funding": "credit", + "generated_from": null, + "last4": "4242", + "networks": { + "available": [ + "visa" + ], + "preferred": null + }, + "three_d_secure_usage": { + "supported": true + }, + "wallet": null + }, + "created": 1706206529, + "customer": "", + "livemode": false, + "metadata": {}, + "type": "card" + } + recorded_at: Thu, 25 Jan 2024 18:15:30 GMT +- request: + method: post + uri: https://api.stripe.com/v1/accounts + body: + encoding: UTF-8 + string: type=standard&country=AU&email=apple.producer%40example.com + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_yYPPR4rgjOokVi","request_duration_ms":675}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Thu, 25 Jan 2024 18:15:31 GMT + Content-Type: + - application/json + Content-Length: + - '2982' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Faccounts; block-all-mixed-content; + 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: + - 14a8cace-8481-4073-b337-adb82d94ccac + Original-Request: + - req_XvaccQdKqzsqii + Request-Id: + - req_XvaccQdKqzsqii + Stripe-Should-Retry: + - 'false' + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "acct_1OcXSYQSOpno0XNZ", + "object": "account", + "business_profile": { + "annual_revenue": null, + "estimated_worker_count": null, + "mcc": null, + "name": null, + "product_description": null, + "support_address": null, + "support_email": null, + "support_phone": null, + "support_url": null, + "url": null + }, + "business_type": null, + "capabilities": {}, + "charges_enabled": false, + "controller": { + "is_controller": true, + "type": "application" + }, + "country": "AU", + "created": 1706206530, + "default_currency": "aud", + "details_submitted": false, + "email": "apple.producer@example.com", + "external_accounts": { + "object": "list", + "data": [], + "has_more": false, + "total_count": 0, + "url": "/v1/accounts/acct_1OcXSYQSOpno0XNZ/external_accounts" + }, + "future_requirements": { + "alternatives": [], + "current_deadline": null, + "currently_due": [], + "disabled_reason": null, + "errors": [], + "eventually_due": [], + "past_due": [], + "pending_verification": [] + }, + "metadata": {}, + "payouts_enabled": false, + "requirements": { + "alternatives": [], + "current_deadline": null, + "currently_due": [ + "business_profile.product_description", + "business_profile.support_phone", + "business_profile.url", + "external_account", + "tos_acceptance.date", + "tos_acceptance.ip" + ], + "disabled_reason": "requirements.past_due", + "errors": [], + "eventually_due": [ + "business_profile.product_description", + "business_profile.support_phone", + "business_profile.url", + "external_account", + "tos_acceptance.date", + "tos_acceptance.ip" + ], + "past_due": [ + "external_account", + "tos_acceptance.date", + "tos_acceptance.ip" + ], + "pending_verification": [] + }, + "settings": { + "bacs_debit_payments": { + "display_name": null, + "service_user_number": null + }, + "branding": { + "icon": null, + "logo": null, + "primary_color": null, + "secondary_color": null + }, + "card_issuing": { + "tos_acceptance": { + "date": null, + "ip": null + } + }, + "card_payments": { + "decline_on": { + "avs_failure": false, + "cvc_failure": false + }, + "statement_descriptor_prefix": null, + "statement_descriptor_prefix_kana": null, + "statement_descriptor_prefix_kanji": null + }, + "dashboard": { + "display_name": null, + "timezone": "Etc/UTC" + }, + "payments": { + "statement_descriptor": null, + "statement_descriptor_kana": null, + "statement_descriptor_kanji": null + }, + "payouts": { + "debit_negative_balances": true, + "schedule": { + "delay_days": 2, + "interval": "daily" + }, + "statement_descriptor": null + }, + "sepa_debit_payments": {} + }, + "tos_acceptance": { + "date": null, + "ip": null, + "user_agent": null + }, + "type": "standard" + } + recorded_at: Thu, 25 Jan 2024 18:15:31 GMT +- request: + method: get + uri: https://api.stripe.com/v1/payment_methods/pm_1OcXSWKuuB1fWySnU9TPdXrK + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_XvaccQdKqzsqii","request_duration_ms":1837}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Thu, 25 Jan 2024 18:15:32 GMT + Content-Type: + - application/json + Content-Length: + - '941' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_methods%2F%3Apayment_method; + block-all-mixed-content; default-src 'none'; base-uri 'none'; form-action + 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; + style-src 'self' + Request-Id: + - req_4Qi1p0DLEo07Y8 + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "pm_1OcXSWKuuB1fWySnU9TPdXrK", + "object": "payment_method", + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": null, + "phone": null + }, + "card": { + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "pass" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2026, + "fingerprint": "6E6tgVjx6U65iHFV", + "funding": "credit", + "generated_from": null, + "last4": "4242", + "networks": { + "available": [ + "visa" + ], + "preferred": null + }, + "three_d_secure_usage": { + "supported": true + }, + "wallet": null + }, + "created": 1706206529, + "customer": "", + "livemode": false, + "metadata": {}, + "type": "card" + } + recorded_at: Thu, 25 Jan 2024 18:15:32 GMT +- request: + method: get + uri: https://api.stripe.com/v1/customers?email=apple.customer@example.com&limit=100 + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_4Qi1p0DLEo07Y8","request_duration_ms":514}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Stripe-Account: + - acct_1OcXSYQSOpno0XNZ + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Thu, 25 Jan 2024 18:15:32 GMT + Content-Type: + - application/json + Content-Length: + - '83' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fcustomers; block-all-mixed-content; + default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; + img-src 'self'; script-src 'self' 'report-sample'; style-src 'self' + Request-Id: + - req_ZNCC8iTU9pFuXZ + Stripe-Account: + - acct_1OcXSYQSOpno0XNZ + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "object": "list", + "data": [], + "has_more": false, + "url": "/v1/customers" + } + recorded_at: Thu, 25 Jan 2024 18:15:32 GMT +- request: + method: post + uri: https://api.stripe.com/v1/payment_methods + body: + encoding: UTF-8 + string: customer=&payment_method=pm_1OcXSWKuuB1fWySnU9TPdXrK + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_ZNCC8iTU9pFuXZ","request_duration_ms":405}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Stripe-Account: + - acct_1OcXSYQSOpno0XNZ + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Thu, 25 Jan 2024 18:15:33 GMT + Content-Type: + - application/json + Content-Length: + - '925' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_methods; block-all-mixed-content; + 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: + - 26a2d263-4fa0-4869-9153-7ee847d35429 + Original-Request: + - req_98MFeQhyrMODZh + Request-Id: + - req_98MFeQhyrMODZh + Stripe-Account: + - acct_1OcXSYQSOpno0XNZ + Stripe-Should-Retry: + - 'false' + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "pm_1OcXSbQSOpno0XNZCzFreEOk", + "object": "payment_method", + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": null, + "phone": null + }, + "card": { + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "pass" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2026, + "fingerprint": "6E6tgVjx6U65iHFV", + "funding": "credit", + "generated_from": null, + "last4": "4242", + "networks": { + "available": [ + "visa" + ], + "preferred": null + }, + "three_d_secure_usage": { + "supported": true + }, + "wallet": null + }, + "created": 1706206533, + "customer": null, + "livemode": false, + "metadata": {}, + "type": "card" + } + recorded_at: Thu, 25 Jan 2024 18:15:33 GMT +- request: + method: post + uri: https://api.stripe.com/v1/customers + body: + encoding: UTF-8 + string: email=apple.customer%40example.com + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_98MFeQhyrMODZh","request_duration_ms":408}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Stripe-Account: + - acct_1OcXSYQSOpno0XNZ + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Thu, 25 Jan 2024 18:15:33 GMT + Content-Type: + - application/json + Content-Length: + - '638' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fcustomers; block-all-mixed-content; + 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: + - cfa38fd4-d44e-4743-9f4a-d060bee3c257 + Original-Request: + - req_Iwwlzbg0adUir5 + Request-Id: + - req_Iwwlzbg0adUir5 + Stripe-Account: + - acct_1OcXSYQSOpno0XNZ + Stripe-Should-Retry: + - 'false' + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "cus_PRQJKJJwbmFUIF", + "object": "customer", + "address": null, + "balance": 0, + "created": 1706206533, + "currency": null, + "default_source": null, + "delinquent": false, + "description": null, + "discount": null, + "email": "apple.customer@example.com", + "invoice_prefix": "938FC140", + "invoice_settings": { + "custom_fields": null, + "default_payment_method": null, + "footer": null, + "rendering_options": null + }, + "livemode": false, + "metadata": {}, + "name": null, + "next_invoice_sequence": 1, + "phone": null, + "preferred_locales": [], + "shipping": null, + "tax_exempt": "none", + "test_clock": null + } + recorded_at: Thu, 25 Jan 2024 18:15:33 GMT +- request: + method: post + uri: https://api.stripe.com/v1/payment_methods/pm_1OcXSbQSOpno0XNZCzFreEOk/attach + body: + encoding: UTF-8 + string: customer=cus_PRQJKJJwbmFUIF + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_Iwwlzbg0adUir5","request_duration_ms":406}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Stripe-Account: + - acct_1OcXSYQSOpno0XNZ + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Thu, 25 Jan 2024 18:15:33 GMT + Content-Type: + - application/json + Content-Length: + - '941' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_methods%2F%3Apayment_method%2Fattach; + block-all-mixed-content; 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: + - 1f315539-0f13-4297-980c-33dae754f6bb + Original-Request: + - req_DtpE7GkEWS5j9V + Request-Id: + - req_DtpE7GkEWS5j9V + Stripe-Account: + - acct_1OcXSYQSOpno0XNZ + Stripe-Should-Retry: + - 'false' + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "pm_1OcXSbQSOpno0XNZCzFreEOk", + "object": "payment_method", + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": null, + "phone": null + }, + "card": { + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "pass" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2026, + "fingerprint": "6E6tgVjx6U65iHFV", + "funding": "credit", + "generated_from": null, + "last4": "4242", + "networks": { + "available": [ + "visa" + ], + "preferred": null + }, + "three_d_secure_usage": { + "supported": true + }, + "wallet": null + }, + "created": 1706206533, + "customer": "cus_PRQJKJJwbmFUIF", + "livemode": false, + "metadata": {}, + "type": "card" + } + recorded_at: Thu, 25 Jan 2024 18:15:34 GMT +- request: + method: post + uri: https://api.stripe.com/v1/payment_methods/pm_1OcXSbQSOpno0XNZCzFreEOk + body: + encoding: UTF-8 + string: metadata[ofn-clone]=true + headers: + User-Agent: + - Stripe/v1 RubyBindings/10.6.0 + Authorization: + - Bearer + Content-Type: + - application/x-www-form-urlencoded + X-Stripe-Client-Telemetry: + - '{"last_request_metrics":{"request_id":"req_DtpE7GkEWS5j9V","request_duration_ms":356}}' + Stripe-Version: + - '2023-10-16' + X-Stripe-Client-User-Agent: + - '{"bindings_version":"10.6.0","lang":"ruby","lang_version":"3.1.4 p223 (2023-03-30)","platform":"x86_64-linux","engine":"ruby","publisher":"stripe","uname":"Linux + version 6.5.0-14-generic (buildd@lcy02-amd64-110) (x86_64-linux-gnu-gcc-12 + (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) + #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2","hostname":"ff-LAT"}' + Stripe-Account: + - acct_1OcXSYQSOpno0XNZ + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Thu, 25 Jan 2024 18:15:34 GMT + Content-Type: + - application/json + Content-Length: + - '968' + Connection: + - keep-alive + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Allow-Methods: + - GET,HEAD,PUT,PATCH,POST,DELETE + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, + X-Stripe-Privileged-Session-Required + Access-Control-Max-Age: + - '300' + Cache-Control: + - no-cache, no-store + Content-Security-Policy: + - report-uri https://q.stripe.com/csp-report?p=v1%2Fpayment_methods%2F%3Apayment_method; + block-all-mixed-content; 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: + - e2d99c9c-cf18-441a-b46f-0a583985eed0 + Original-Request: + - req_lBYKHXaWzr5Pw6 + Request-Id: + - req_lBYKHXaWzr5Pw6 + Stripe-Account: + - acct_1OcXSYQSOpno0XNZ + Stripe-Should-Retry: + - 'false' + Stripe-Version: + - '2023-10-16' + Vary: + - Origin + X-Stripe-Routing-Context-Priority-Tier: + - api-testmode + Strict-Transport-Security: + - max-age=63072000; includeSubDomains; preload + body: + encoding: UTF-8 + string: |- + { + "id": "pm_1OcXSbQSOpno0XNZCzFreEOk", + "object": "payment_method", + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": null, + "phone": null + }, + "card": { + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "pass" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2026, + "fingerprint": "6E6tgVjx6U65iHFV", + "funding": "credit", + "generated_from": null, + "last4": "4242", + "networks": { + "available": [ + "visa" + ], + "preferred": null + }, + "three_d_secure_usage": { + "supported": true + }, + "wallet": null + }, + "created": 1706206533, + "customer": "cus_PRQJKJJwbmFUIF", + "livemode": false, + "metadata": { + "ofn-clone": "true" + }, + "type": "card" + } + recorded_at: Thu, 25 Jan 2024 18:15:34 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/lib/stripe/credit_card_cloner_spec.rb b/spec/lib/stripe/credit_card_cloner_spec.rb index 3037846f1d..70667a4115 100644 --- a/spec/lib/stripe/credit_card_cloner_spec.rb +++ b/spec/lib/stripe/credit_card_cloner_spec.rb @@ -5,7 +5,7 @@ require 'stripe/credit_card_cloner' module Stripe describe CreditCardCloner do - let!(:user) { create(:user, email: "jumping.jane@example.com") } + let!(:user) { create(:user, email: "apple.customer@example.com") } let!(:enterprise) { create(:enterprise) } let(:secret) { ENV.fetch('STRIPE_SECRET_TEST_API_KEY', nil) } @@ -15,11 +15,11 @@ module Stripe before { Stripe.api_key = secret } - let!(:customer_id) { ENV.fetch('STRIPE_CUSTOMER', nil) } + let(:customer_id) { ENV.fetch('STRIPE_CUSTOMER', nil) } - let!(:stripe_account_id) { ENV.fetch('STRIPE_ACCOUNT', nil) } + let(:stripe_account_id) { ENV.fetch('STRIPE_ACCOUNT', nil) } - let!(:stripe_account) { + let(:stripe_account) { create(:stripe_account, enterprise:, stripe_user_id: stripe_account_id) } @@ -39,42 +39,50 @@ module Stripe ) } - let!(:connected_account) do + let(:connected_account) do Stripe::Account.create({ type: 'standard', country: 'AU', - email: 'jumping.jack@example.com' + email: 'apple.producer@example.com' }) end - let!(:cloner) { Stripe::CreditCardCloner.new(credit_card, connected_account.id) } + let(:cloner) { Stripe::CreditCardCloner.new(credit_card, connected_account.id) } context "when called with a card without a customer (one time usage card)" do - let!(:payment_method_id) { pm_card.id } + let(:payment_method_id) { pm_card.id } it "clones the payment method only" do customer_id, new_payment_method_id = cloner.find_or_clone + expect(payment_method_id).to match(/pm_/) + expect(new_payment_method_id).to match(/pm_/) expect(payment_method_id).not_to eq new_payment_method_id expect(customer_id).to eq nil end end - xcontext "when called with a valid customer and payment_method" do + context "when called with a valid customer and payment_method" do + let(:payment_method_id) { pm_card.id } + before do - stub_request(:post, "https://api.stripe.com/v1/payment_methods") - .with(body: { customer: customer_id, payment_method: payment_method_id }, - headers: { 'Stripe-Account' => stripe_account_id }) - .to_return(payment_method_response_mock) + Stripe::PaymentMethod.attach( + payment_method_id, + { customer: customer_id }, + ) credit_card.update_attribute :gateway_customer_profile_id, customer_id end it "clones both the payment method and the customer" do - customer_id, payment_method_id = cloner.find_or_clone + new_customer_id, new_payment_method_id = cloner.find_or_clone - expect(payment_method_id).to eq new_payment_method_id - expect(customer_id).to eq new_customer_id + expect(payment_method_id).to match(/pm_/) + expect(new_payment_method_id).to match(/pm_/) + expect(payment_method_id).not_to eq new_payment_method_id + expect(customer_id).to match(/cus_/) + expect(new_customer_id).to match(/cus_/) + expect(customer_id).not_to eq new_customer_id end end end From d2bb53da5b1f0d291c323d2f3f311ce6cc3a086f Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Thu, 25 Jan 2024 18:28:52 +0000 Subject: [PATCH 3/3] Removes assertion on bogus_customer When running the CI we actually assert on the bogus credentials, which breaks the spec Removes unecessary StripeStubs inclusion --- spec/lib/stripe/credit_card_cloner_spec.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/spec/lib/stripe/credit_card_cloner_spec.rb b/spec/lib/stripe/credit_card_cloner_spec.rb index 70667a4115..88e0094018 100644 --- a/spec/lib/stripe/credit_card_cloner_spec.rb +++ b/spec/lib/stripe/credit_card_cloner_spec.rb @@ -11,8 +11,6 @@ module Stripe let(:secret) { ENV.fetch('STRIPE_SECRET_TEST_API_KEY', nil) } describe "#find_or_clone", :vcr, :stripe_version do - include StripeStubs - before { Stripe.api_key = secret } let(:customer_id) { ENV.fetch('STRIPE_CUSTOMER', nil) } @@ -80,7 +78,6 @@ module Stripe expect(payment_method_id).to match(/pm_/) expect(new_payment_method_id).to match(/pm_/) expect(payment_method_id).not_to eq new_payment_method_id - expect(customer_id).to match(/cus_/) expect(new_customer_id).to match(/cus_/) expect(customer_id).not_to eq new_customer_id end