From ee674bbf601aea9649c10434f9f0dc9ca4001da4 Mon Sep 17 00:00:00 2001 From: Jason Emerick Date: Thu, 22 Aug 2019 12:52:24 -0400 Subject: [PATCH 1/3] auto add 3DS2 payment test numbers --- web.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/web.rb b/web.rb index fce305f..0ea3518 100644 --- a/web.rb +++ b/web.rb @@ -110,9 +110,25 @@ def authenticate! else begin @customer = create_customer() + + payment_methods = ['pm_card_threeDSecure2Required', 'pm_card_visa'] + + ['4000000000003220', '4000000000003238', '4000000000003246', '4000000000003253'].each { |cc_number| + pm = Stripe::PaymentMethod.create({ + type: 'card', + card: { + number: cc_number, + exp_month: 8, + exp_year: 2022, + cvc: '123', + }, + }) + payment_methods.push pm.id + } + # Attach some test cards to the customer for testing convenience. # See https://stripe.com/docs/testing#cards - ['pm_card_threeDSecure2Required', 'pm_card_visa'].each { |pm_id| + payment_methods.each { |pm_id| Stripe::PaymentMethod.attach( pm_id, { From 2e4645f9ae73c7e6f9f7b8a48ab6127c0c84dc07 Mon Sep 17 00:00:00 2001 From: Jason Emerick Date: Thu, 22 Aug 2019 14:01:25 -0400 Subject: [PATCH 2/3] remove other PMs, and 4242 to CC list --- web.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web.rb b/web.rb index 0ea3518..6b1c55a 100644 --- a/web.rb +++ b/web.rb @@ -111,9 +111,9 @@ def authenticate! begin @customer = create_customer() - payment_methods = ['pm_card_threeDSecure2Required', 'pm_card_visa'] + payment_methods = [] - ['4000000000003220', '4000000000003238', '4000000000003246', '4000000000003253'].each { |cc_number| + ['4000000000003220', '4000000000003238', '4000000000003246', '4000000000003253', '4242424242424242'].each { |cc_number| pm = Stripe::PaymentMethod.create({ type: 'card', card: { From b00b70a1b1845784eabf2dbe049c4dfb2d71c0c3 Mon Sep 17 00:00:00 2001 From: Jason Emerick Date: Thu, 22 Aug 2019 14:53:31 -0400 Subject: [PATCH 3/3] attach to customer at same time as creating payment method --- web.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/web.rb b/web.rb index 6b1c55a..a638733 100644 --- a/web.rb +++ b/web.rb @@ -111,10 +111,11 @@ def authenticate! begin @customer = create_customer() - payment_methods = [] - + # Attach some test cards to the customer for testing convenience. + # See https://stripe.com/docs/payments/3d-secure#three-ds-cards + # and https://stripe.com/docs/mobile/android/authentication#testing ['4000000000003220', '4000000000003238', '4000000000003246', '4000000000003253', '4242424242424242'].each { |cc_number| - pm = Stripe::PaymentMethod.create({ + payment_method = Stripe::PaymentMethod.create({ type: 'card', card: { number: cc_number, @@ -123,14 +124,9 @@ def authenticate! cvc: '123', }, }) - payment_methods.push pm.id - } - # Attach some test cards to the customer for testing convenience. - # See https://stripe.com/docs/testing#cards - payment_methods.each { |pm_id| Stripe::PaymentMethod.attach( - pm_id, + payment_method.id, { customer: @customer.id, }