Merge pull request #12074 from filipefurtad0/vcr_credit_card_clone_destroyer_spec

[Stripe, VCR] Updates credit_card_cloner_spec.rb
This commit is contained in:
Maikel
2024-01-30 11:24:04 +11:00
committed by GitHub
4 changed files with 2531 additions and 44 deletions

View File

@@ -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 <HIDDEN_KEY>
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 <HIDDEN_KEY>
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 <HIDDEN_KEY>
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 <HIDDEN_KEY>
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 <HIDDEN_KEY>
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

View File

@@ -0,0 +1,661 @@
---
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 <HIDDEN-STRIPE_SECRET_TEST_API_KEY>
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:
- Thu, 25 Jan 2024 18:15:25 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:
- 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 <HIDDEN-STRIPE_SECRET_TEST_API_KEY>
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:
- '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:
- e6d81e18-0a21-4970-925c-d2934bf80914
Original-Request:
- req_el99nPdh6DgbX6
Request-Id:
- req_el99nPdh6DgbX6
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_1OcXSTQK2Bh9Qahe",
"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": 1706206526,
"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_1OcXSTQK2Bh9Qahe/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:27 GMT
- request:
method: get
uri: https://api.stripe.com/v1/payment_methods/pm_1OcXSTKuuB1fWySn5Ri5Zqfi
body:
encoding: US-ASCII
string: ''
headers:
User-Agent:
- Stripe/v1 RubyBindings/10.6.0
Authorization:
- Bearer <HIDDEN-STRIPE_SECRET_TEST_API_KEY>
Content-Type:
- application/x-www-form-urlencoded
X-Stripe-Client-Telemetry:
- '{"last_request_metrics":{"request_id":"req_el99nPdh6DgbX6","request_duration_ms":1994}}'
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:
- '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_ks2EKp9Z9EMNb4
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:27 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 <HIDDEN-STRIPE_SECRET_TEST_API_KEY>
Content-Type:
- application/x-www-form-urlencoded
X-Stripe-Client-Telemetry:
- '{"last_request_metrics":{"request_id":"req_ks2EKp9Z9EMNb4","request_duration_ms":401}}'
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_1OcXSTQK2Bh9Qahe
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:28 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_2BStYe8os69wxh
Stripe-Account:
- acct_1OcXSTQK2Bh9Qahe
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:28 GMT
- request:
method: post
uri: https://api.stripe.com/v1/payment_methods
body:
encoding: UTF-8
string: payment_method=pm_1OcXSTKuuB1fWySn5Ri5Zqfi
headers:
User-Agent:
- Stripe/v1 RubyBindings/10.6.0
Authorization:
- Bearer <HIDDEN-STRIPE_SECRET_TEST_API_KEY>
Content-Type:
- application/x-www-form-urlencoded
X-Stripe-Client-Telemetry:
- '{"last_request_metrics":{"request_id":"req_2BStYe8os69wxh","request_duration_ms":304}}'
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_1OcXSTQK2Bh9Qahe
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:28 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:
- 46a9aa38-6e45-44ea-8175-1dd33870b676
Original-Request:
- req_wr8dUxwCyfU1jE
Request-Id:
- req_wr8dUxwCyfU1jE
Stripe-Account:
- acct_1OcXSTQK2Bh9Qahe
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_1OcXSWQK2Bh9QahelUGjee6K",
"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": 1706206528,
"customer": null,
"livemode": false,
"metadata": {},
"type": "card"
}
recorded_at: Thu, 25 Jan 2024 18:15:28 GMT
recorded_with: VCR 6.2.0

View File

@@ -5,76 +5,81 @@ require 'stripe/credit_card_cloner'
module Stripe
describe CreditCardCloner do
describe "#find_or_clone" do
include StripeStubs
let!(:user) { create(:user, email: "apple.customer@example.com") }
let!(:enterprise) { create(:enterprise) }
let(:credit_card) { create(:credit_card, user: create(:user)) }
let(:stripe_account_id) { "abc123" }
let(:secret) { ENV.fetch('STRIPE_SECRET_TEST_API_KEY', nil) }
let(:cloner) { Stripe::CreditCardCloner.new(credit_card, stripe_account_id) }
describe "#find_or_clone", :vcr, :stripe_version do
before { Stripe.api_key = secret }
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(:customer_id) { ENV.fetch('STRIPE_CUSTOMER', nil) }
let(:payment_method_response_body) {
JSON.generate(id: new_payment_method_id)
let(:stripe_account_id) { ENV.fetch('STRIPE_ACCOUNT', nil) }
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: 'apple.producer@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).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
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(new_customer_id).to match(/cus_/)
expect(customer_id).not_to eq new_customer_id
end
end
end