solidus_stripe 4.4.0 → 5.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +102 -41
- data/.gitignore +3 -0
- data/.rubocop.yml +94 -4
- data/.yardopts +1 -0
- data/CHANGELOG.md +1 -265
- data/Gemfile +10 -30
- data/LICENSE +2 -2
- data/Procfile.dev +3 -0
- data/README.md +185 -213
- data/Rakefile +7 -6
- data/app/assets/javascripts/spree/backend/solidus_stripe.js +2 -0
- data/app/assets/stylesheets/spree/backend/solidus_stripe.css +4 -0
- data/app/controllers/solidus_stripe/intents_controller.rb +36 -52
- data/app/controllers/solidus_stripe/webhooks_controller.rb +28 -0
- data/app/models/concerns/solidus_stripe/log_entries.rb +31 -0
- data/app/models/solidus_stripe/customer.rb +21 -0
- data/app/models/solidus_stripe/gateway.rb +229 -0
- data/app/models/solidus_stripe/payment_intent.rb +124 -0
- data/app/models/solidus_stripe/payment_method.rb +106 -0
- data/app/models/solidus_stripe/payment_source.rb +31 -0
- data/app/models/solidus_stripe/slug_entry.rb +20 -0
- data/app/models/solidus_stripe.rb +7 -0
- data/app/subscribers/solidus_stripe/webhook/charge_subscriber.rb +28 -0
- data/app/subscribers/solidus_stripe/webhook/payment_intent_subscriber.rb +112 -0
- data/app/views/spree/admin/payments/source_forms/_stripe.html.erb +29 -0
- data/app/views/spree/admin/payments/source_forms/existing_payment/_stripe.html.erb +19 -0
- data/app/views/spree/admin/payments/source_forms/existing_payment/stripe/_card.html.erb +8 -0
- data/app/views/spree/admin/payments/source_forms/existing_payment/stripe/_default.html.erb +7 -0
- data/app/views/spree/admin/payments/source_views/_stripe.html.erb +15 -0
- data/app/views/spree/api/payments/source_views/_stripe.json.jbuilder +8 -0
- data/bin/dev +13 -0
- data/bin/dummy-app +29 -0
- data/bin/rails +38 -3
- data/bin/rails-dummy-app +3 -0
- data/bin/rails-engine +1 -11
- data/bin/rails-new +55 -0
- data/bin/rails-sandbox +1 -14
- data/bin/rspec +10 -0
- data/bin/sandbox +12 -74
- data/bin/setup +1 -0
- data/bin/update-migrations +56 -0
- data/codecov.yml +12 -0
- data/config/locales/en.yml +16 -1
- data/config/routes.rb +5 -11
- data/coverage.rb +42 -0
- data/db/migrate/20230109183332_create_solidus_stripe_payment_sources.rb +10 -0
- data/db/migrate/20230306105520_create_solidus_stripe_payment_intents.rb +14 -0
- data/db/migrate/20230308122414_create_solidus_stripe_slug_entries.rb +12 -0
- data/db/migrate/20230313150008_create_solidus_stripe_customers.rb +15 -0
- data/db/seeds.rb +6 -24
- data/lib/generators/solidus_stripe/install/install_generator.rb +121 -14
- data/lib/generators/solidus_stripe/install/templates/app/assets/stylesheets/spree/frontend/solidus_stripe.css +13 -0
- data/lib/generators/solidus_stripe/install/templates/app/javascript/controllers/solidus_stripe_confirm_controller.js +39 -0
- data/lib/generators/solidus_stripe/install/templates/app/javascript/controllers/solidus_stripe_payment_controller.js +89 -0
- data/lib/generators/solidus_stripe/install/templates/app/views/checkouts/existing_payment/_stripe.html.erb +21 -0
- data/lib/generators/solidus_stripe/install/templates/app/views/checkouts/existing_payment/stripe/_card.html.erb +8 -0
- data/lib/generators/solidus_stripe/install/templates/app/views/checkouts/existing_payment/stripe/_default.html.erb +7 -0
- data/lib/generators/solidus_stripe/install/templates/app/views/checkouts/payment/_stripe.html.erb +74 -0
- data/lib/generators/solidus_stripe/install/templates/app/views/orders/payment_info/_stripe.html.erb +32 -0
- data/lib/generators/solidus_stripe/install/templates/config/initializers/solidus_stripe.rb +31 -0
- data/lib/solidus_stripe/configuration.rb +24 -3
- data/lib/solidus_stripe/engine.rb +19 -6
- data/lib/solidus_stripe/money_to_stripe_amount_converter.rb +109 -0
- data/lib/solidus_stripe/refunds_synchronizer.rb +98 -0
- data/lib/solidus_stripe/seeds.rb +19 -0
- data/lib/solidus_stripe/testing_support/factories.rb +153 -0
- data/lib/solidus_stripe/version.rb +1 -1
- data/lib/solidus_stripe/webhook/event.rb +91 -0
- data/lib/solidus_stripe.rb +0 -2
- data/solidus_stripe.gemspec +29 -6
- data/spec/lib/solidus_stripe/configuration_spec.rb +21 -0
- data/spec/lib/solidus_stripe/money_to_stripe_amount_converter_spec.rb +133 -0
- data/spec/lib/solidus_stripe/refunds_synchronizer_spec.rb +238 -0
- data/spec/lib/solidus_stripe/seeds_spec.rb +43 -0
- data/spec/lib/solidus_stripe/webhook/event_spec.rb +134 -0
- data/spec/models/concerns/solidus_stripe/log_entries_spec.rb +54 -0
- data/spec/models/solidus_stripe/customer_spec.rb +47 -0
- data/spec/models/solidus_stripe/gateway_spec.rb +281 -0
- data/spec/models/solidus_stripe/payment_intent_spec.rb +78 -0
- data/spec/models/solidus_stripe/payment_method_spec.rb +137 -0
- data/spec/models/solidus_stripe/payment_source_spec.rb +25 -0
- data/spec/requests/solidus_stripe/intents_controller_spec.rb +29 -0
- data/spec/requests/solidus_stripe/webhooks_controller/charge/refunded_spec.rb +31 -0
- data/spec/requests/solidus_stripe/webhooks_controller/payment_intent/canceled_spec.rb +23 -0
- data/spec/requests/solidus_stripe/webhooks_controller/payment_intent/payment_failed_spec.rb +23 -0
- data/spec/requests/solidus_stripe/webhooks_controller/payment_intent/succeeded_spec.rb +29 -0
- data/spec/requests/solidus_stripe/webhooks_controller_spec.rb +56 -0
- data/spec/solidus_stripe_spec_helper.rb +10 -0
- data/spec/subscribers/solidus_stripe/webhook/charge_subscriber_spec.rb +33 -0
- data/spec/subscribers/solidus_stripe/webhook/payment_intent_subscriber_spec.rb +297 -0
- data/spec/support/solidus_stripe/backend_test_helper.rb +185 -0
- data/spec/support/solidus_stripe/checkout_test_helper.rb +365 -0
- data/spec/support/solidus_stripe/factories.rb +5 -0
- data/spec/support/solidus_stripe/webhook/data_fixtures.rb +106 -0
- data/spec/support/solidus_stripe/webhook/event_with_context_factory.rb +82 -0
- data/spec/support/solidus_stripe/webhook/request_helper.rb +32 -0
- data/spec/system/backend/solidus_stripe/orders/payments_spec.rb +145 -0
- data/spec/system/frontend/.keep +0 -0
- data/spec/system/frontend/solidus_stripe/checkout_spec.rb +206 -0
- data/tmp/.keep +0 -0
- metadata +196 -75
- data/.rubocop_todo.yml +0 -298
- data/.travis.yml +0 -28
- data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-cart-page-checkout.js +0 -122
- data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-elements.js +0 -148
- data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-init.js +0 -20
- data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-payment-intents.js +0 -84
- data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-payment-request-button-shared.js +0 -160
- data/app/assets/javascripts/spree/frontend/solidus_stripe/stripe-payment.js +0 -16
- data/app/assets/javascripts/spree/frontend/solidus_stripe.js +0 -6
- data/app/controllers/solidus_stripe/payment_request_controller.rb +0 -52
- data/app/controllers/spree/stripe_controller.rb +0 -13
- data/app/decorators/models/spree/order_update_attributes_decorator.rb +0 -39
- data/app/decorators/models/spree/payment_decorator.rb +0 -11
- data/app/decorators/models/spree/refund_decorator.rb +0 -9
- data/app/models/solidus_stripe/address_from_params_service.rb +0 -72
- data/app/models/solidus_stripe/create_intents_payment_service.rb +0 -114
- data/app/models/solidus_stripe/prepare_order_for_payment_service.rb +0 -46
- data/app/models/solidus_stripe/shipping_rates_service.rb +0 -46
- data/app/models/spree/payment_method/stripe_credit_card.rb +0 -230
- data/bin/r +0 -13
- data/bin/sandbox_rails +0 -18
- data/db/migrate/20181010123508_update_stripe_payment_method_type_to_credit_card.rb +0 -21
- data/lib/assets/stylesheets/spree/frontend/solidus_stripe.scss +0 -11
- data/lib/solidus_stripe/testing_support/card_input_helper.rb +0 -34
- data/lib/tasks/solidus_stripe/db/seed.rake +0 -14
- data/lib/views/api/spree/api/payments/source_views/_stripe.json.jbuilder +0 -3
- data/lib/views/backend/spree/admin/log_entries/_stripe.html.erb +0 -28
- data/lib/views/backend/spree/admin/payments/source_forms/_stripe.html.erb +0 -1
- data/lib/views/backend/spree/admin/payments/source_views/_stripe.html.erb +0 -1
- data/lib/views/frontend/spree/checkout/existing_payment/_stripe.html.erb +0 -1
- data/lib/views/frontend/spree/checkout/payment/_stripe.html.erb +0 -8
- data/lib/views/frontend/spree/checkout/payment/v2/_javascript.html.erb +0 -78
- data/lib/views/frontend/spree/checkout/payment/v3/_elements.html.erb +0 -1
- data/lib/views/frontend/spree/checkout/payment/v3/_form_elements.html.erb +0 -40
- data/lib/views/frontend/spree/checkout/payment/v3/_intents.html.erb +0 -1
- data/lib/views/frontend/spree/checkout/payment/v3/_stripe.html.erb +0 -2
- data/lib/views/frontend/spree/orders/_stripe_payment_request_button.html.erb +0 -14
- data/spec/features/stripe_checkout_spec.rb +0 -486
- data/spec/models/solidus_stripe/address_from_params_service_spec.rb +0 -87
- data/spec/models/solidus_stripe/create_intents_payment_service_spec.rb +0 -127
- data/spec/models/solidus_stripe/prepare_order_for_payment_service_spec.rb +0 -65
- data/spec/models/solidus_stripe/shipping_rates_service_spec.rb +0 -54
- data/spec/models/spree/payment_method/stripe_credit_card_spec.rb +0 -350
- data/spec/requests/payment_requests_spec.rb +0 -152
- data/spec/spec_helper.rb +0 -37
- data/spec/support/solidus_address_helper.rb +0 -15
@@ -0,0 +1,145 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'solidus_stripe_spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe 'SolidusStripe Orders Payments', :js do
|
6
|
+
include SolidusStripe::BackendTestHelper
|
7
|
+
include Devise::Test::IntegrationHelpers
|
8
|
+
stub_authorization!
|
9
|
+
|
10
|
+
let(:user) { create(:admin_user) }
|
11
|
+
|
12
|
+
context 'with successful payment operations' do
|
13
|
+
it 'navigates to the payments page' do
|
14
|
+
payment = create_authorized_payment
|
15
|
+
visit_payments_page
|
16
|
+
|
17
|
+
click_on 'Payments'
|
18
|
+
expect(page).to have_content(payment.number)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'displays log entries for a payment' do
|
22
|
+
payment = create(:solidus_stripe_payment, :captured, order: order, payment_method: payment_method)
|
23
|
+
|
24
|
+
visit_payment_page(payment)
|
25
|
+
|
26
|
+
expects_page_to_display_log_messages(["PaymentIntent was confirmed and captured successfully"])
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'successfully captures an authorized payment' do
|
30
|
+
payment = create_authorized_payment
|
31
|
+
visit_payments_page
|
32
|
+
|
33
|
+
capture_payment
|
34
|
+
|
35
|
+
expect(page).to have_content('Payment Updated')
|
36
|
+
expect(payment.reload.state).to eq('completed')
|
37
|
+
expect(payment.capture_events.first.amount).to eq(payment.amount)
|
38
|
+
expects_payment_to_have_correct_capture_amount_on_stripe(payment, payment.amount)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'successfully captures a partial amount of an authorized payment' do
|
42
|
+
payment = create_authorized_payment
|
43
|
+
partial_capture_amount = payment.amount - 10
|
44
|
+
|
45
|
+
visit_payments_page
|
46
|
+
|
47
|
+
capture_partial_payment_amount(payment, partial_capture_amount)
|
48
|
+
|
49
|
+
expect(page).to have_content('Payment Updated')
|
50
|
+
expect(payment.reload.state).to eq('completed')
|
51
|
+
expect(payment.capture_events.first.amount).to eq(payment.amount)
|
52
|
+
expects_payment_to_have_correct_capture_amount_on_stripe(payment, partial_capture_amount)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'voids a payment from an order' do
|
56
|
+
payment = create_authorized_payment
|
57
|
+
visit_payments_page
|
58
|
+
|
59
|
+
void_payment
|
60
|
+
|
61
|
+
expect(page).to have_content('Payment Updated')
|
62
|
+
expect(payment.reload.state).to eq('void')
|
63
|
+
expects_payment_to_be_voided_on_stripe(payment)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'refunds a payment from an order' do
|
67
|
+
payment = create_captured_payment
|
68
|
+
visit_payments_page
|
69
|
+
|
70
|
+
refund_payment
|
71
|
+
|
72
|
+
expect(page).to have_content('Refund has been successfully created!')
|
73
|
+
expect(payment).to be_fully_refunded
|
74
|
+
expects_payment_to_be_refunded_on_stripe(payment, payment.amount)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'partially refunds a payment from an order' do
|
78
|
+
payment = create_captured_payment
|
79
|
+
visit_payments_page
|
80
|
+
|
81
|
+
refund_reason = create(:refund_reason)
|
82
|
+
partial_refund_amount = 25
|
83
|
+
partially_refund_payment(refund_reason, partial_refund_amount)
|
84
|
+
|
85
|
+
expect(page).to have_content('Refund has been successfully created!')
|
86
|
+
expect(payment.reload.state).to eq('completed')
|
87
|
+
expect(payment.refunds.first.amount).to eq(partial_refund_amount)
|
88
|
+
expects_payment_to_be_refunded_on_stripe(payment, partial_refund_amount)
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'cancels an order with captured payment' do
|
92
|
+
payment = create_captured_payment
|
93
|
+
|
94
|
+
sign_in user
|
95
|
+
visit_payments_page
|
96
|
+
|
97
|
+
cancel_order
|
98
|
+
|
99
|
+
expect(page).to have_content('Order canceled')
|
100
|
+
expect(payment.reload.state).to eq('completed')
|
101
|
+
expects_payment_to_be_refunded_on_stripe(payment, payment.amount)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'cancels an order with authorized payment' do
|
105
|
+
payment = create_authorized_payment
|
106
|
+
|
107
|
+
sign_in user
|
108
|
+
visit_payments_page
|
109
|
+
|
110
|
+
cancel_order
|
111
|
+
|
112
|
+
expect(page).to have_content('Order canceled')
|
113
|
+
expect(payment.reload.state).to eq('void')
|
114
|
+
expects_payment_to_be_voided_on_stripe(payment)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'creates new authorized payment and captures it with existing source successfully' do
|
118
|
+
create_payment_method
|
119
|
+
create_order_with_existing_payment_source
|
120
|
+
complete_order_with_existing_payment_source
|
121
|
+
visit_payments_page
|
122
|
+
capture_payment
|
123
|
+
payment = last_valid_payment
|
124
|
+
|
125
|
+
expect(page).to have_content('Payment Updated')
|
126
|
+
expect(payment.reload.state).to eq('completed')
|
127
|
+
expect(payment.capture_events.first.amount).to eq(payment.amount)
|
128
|
+
expects_payment_to_have_correct_capture_amount_on_stripe(payment, payment.amount)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'with failed payment operations' do
|
133
|
+
it 'fails to capture a payment due to incomplete 3D Secure authentication' do
|
134
|
+
payment = create_authorized_payment(card_number: '4000000000003220')
|
135
|
+
visit_payments_page
|
136
|
+
|
137
|
+
capture_payment
|
138
|
+
|
139
|
+
expect(page).to have_content(
|
140
|
+
'This PaymentIntent could not be captured because it has a status of requires_action.'
|
141
|
+
)
|
142
|
+
expect(payment.reload.state).to eq('failed')
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
File without changes
|
@@ -0,0 +1,206 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'solidus_stripe_spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe 'SolidusStripe Checkout', :js do
|
6
|
+
include SolidusStripe::CheckoutTestHelper
|
7
|
+
|
8
|
+
# To learn more about setup_future_usage in different contexts with Stripe Payment Intents:
|
9
|
+
# https://stripe.com/docs/payments/payment-intents#future-usage
|
10
|
+
['', 'on_session', 'off_session'].each do |setup_future_usage|
|
11
|
+
context "with Stripe Payment Intents and setup_future_usage=#{setup_future_usage}" do
|
12
|
+
before { create_payment_method(setup_future_usage: setup_future_usage) }
|
13
|
+
|
14
|
+
it 'creates a payment intent and successfully processes payment' do
|
15
|
+
successfully_creates_a_payment_intent(user: create(:user))
|
16
|
+
|
17
|
+
capture_last_valid_payment
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with a guest user' do
|
21
|
+
it 'creates a payment intent and successfully processes payment' do
|
22
|
+
successfully_creates_a_payment_intent
|
23
|
+
|
24
|
+
capture_last_valid_payment
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when auto-capture is enabled' do
|
31
|
+
it 'creates a payment intent and automatically processes payment' do
|
32
|
+
create_payment_method(auto_capture: true)
|
33
|
+
|
34
|
+
successfully_creates_a_payment_intent(user: create(:user), auto_capture: true)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'with a registered user' do
|
39
|
+
it 'successfully processes payment using available store credits' do
|
40
|
+
create(:store_credit_payment_method)
|
41
|
+
create_payment_method
|
42
|
+
user = create(:user)
|
43
|
+
store_credit_amount = 5
|
44
|
+
create(:store_credit, user: user, amount: store_credit_amount)
|
45
|
+
|
46
|
+
successfully_creates_a_payment_intent(user: user)
|
47
|
+
|
48
|
+
expects_to_have_specific_authorized_amount_on_stripe(current_order.total - store_credit_amount)
|
49
|
+
end
|
50
|
+
|
51
|
+
['on_session', 'off_session'].each do |setup_future_usage|
|
52
|
+
context "when setup_future_usage is set with '#{setup_future_usage}'" do
|
53
|
+
before { create_payment_method(setup_future_usage: setup_future_usage) }
|
54
|
+
|
55
|
+
it "successfully reuses a previously saved card from the user's wallet" do
|
56
|
+
user = create(:user)
|
57
|
+
successfully_creates_a_payment_intent(user: user)
|
58
|
+
|
59
|
+
visit_payment_step(user: user)
|
60
|
+
find_existing_payment_radio(user.wallet_payment_sources.first.id).choose
|
61
|
+
submit_payment
|
62
|
+
complete_order
|
63
|
+
payment_intent_is_created_with_required_capture
|
64
|
+
capture_last_valid_payment
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when setup_future_usage is not set' do
|
70
|
+
it 'requires the user to enter their payment information for each new transaction' do
|
71
|
+
create_payment_method(setup_future_usage: '')
|
72
|
+
user = create(:user)
|
73
|
+
|
74
|
+
successfully_creates_a_payment_intent(user: user)
|
75
|
+
|
76
|
+
visit_payment_step(user: user)
|
77
|
+
|
78
|
+
expects_page_to_not_display_wallet_payment_sources
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'with non-card Stripe payment methods' do
|
84
|
+
before do
|
85
|
+
stub_spree_preferences(currency: 'EUR')
|
86
|
+
create_payment_method(setup_future_usage: 'off_session', auto_capture: true)
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'creates a payment intent and successfully processes sepa_debit payment' do
|
90
|
+
visit_payment_step(user: create(:user))
|
91
|
+
choose_new_stripe_payment
|
92
|
+
choose_stripe_payment_method(payment_method_type: "sepa_debit")
|
93
|
+
fills_in_stripe_input 'iban', with: 'DE89370400440532013000'
|
94
|
+
|
95
|
+
submit_payment
|
96
|
+
complete_order
|
97
|
+
|
98
|
+
expects_payment_to_be_processing
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'with declined cards' do
|
103
|
+
it 'reject transactions with cards declined at intent creation or invalid fields and return an appropriate response' do # rubocop:disable Layout/LineLength
|
104
|
+
create_payment_method
|
105
|
+
visit_payment_step(user: create(:user))
|
106
|
+
choose_new_stripe_payment
|
107
|
+
|
108
|
+
# Refer to https://stripe.com/docs/testing#invalid-data for more
|
109
|
+
# information on generating test data with invalid values.
|
110
|
+
invalid_data_are_notified
|
111
|
+
|
112
|
+
# Generic error field messages that appear when the Stripe form
|
113
|
+
# has incomplete data for cards
|
114
|
+
incomplete_cards_are_notified
|
115
|
+
|
116
|
+
# Check the Stripe documentation for more information on
|
117
|
+
# how to test declined payments:
|
118
|
+
# https://stripe.com/docs/testing#declined-payments
|
119
|
+
declined_cards_at_intent_creation_are_notified
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'with 3D Secure cards' do
|
123
|
+
it 'reject transaction with failed authentication and return an appropriate response' do
|
124
|
+
create_payment_method
|
125
|
+
visit_payment_step(user: create(:user))
|
126
|
+
choose_new_stripe_payment
|
127
|
+
fill_in_stripe_country('United States')
|
128
|
+
|
129
|
+
# This 3D Secure card requires authentication for all transactions,
|
130
|
+
# regardless of its setup.
|
131
|
+
# Please refer to the Stripe documentation for more information:
|
132
|
+
# https://stripe.com/docs/testing#authentication-and-setup
|
133
|
+
fill_stripe_form(number: '4000002760003184')
|
134
|
+
submit_payment
|
135
|
+
|
136
|
+
check_terms_of_service
|
137
|
+
confirm_order
|
138
|
+
authorize_3d_secure_payment(authenticate: false)
|
139
|
+
|
140
|
+
expects_page_and_order_to_be_in_payment_step
|
141
|
+
expect(page).to have_content(
|
142
|
+
"We are unable to authenticate your payment method. " \
|
143
|
+
"Please choose a different payment method and try again.",
|
144
|
+
wait: 15
|
145
|
+
)
|
146
|
+
|
147
|
+
fill_in_stripe_country('United States')
|
148
|
+
clear_stripe_form
|
149
|
+
|
150
|
+
# This test script is using 3D Secure 2 authentication, which must be
|
151
|
+
# completed for the payment to be successful.
|
152
|
+
# Please refer to the Stripe documentation for more information:
|
153
|
+
# https://stripe.com/docs/testing#three-ds-cards
|
154
|
+
fill_stripe_form(number: '4000000000003220')
|
155
|
+
submit_payment
|
156
|
+
check_terms_of_service
|
157
|
+
confirm_order
|
158
|
+
authorize_3d_secure_2_payment(authenticate: false)
|
159
|
+
|
160
|
+
expects_page_and_order_to_be_in_payment_step
|
161
|
+
expect(page).to have_content(
|
162
|
+
"We are unable to authenticate your payment method. " \
|
163
|
+
"Please choose a different payment method and try again.",
|
164
|
+
wait: 15
|
165
|
+
)
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'processes the transaction with successful authentication' do
|
169
|
+
user = create(:user)
|
170
|
+
|
171
|
+
create_payment_method(setup_future_usage: '')
|
172
|
+
visit_payment_step(user: user)
|
173
|
+
choose_new_stripe_payment
|
174
|
+
fill_in_stripe_country('United States')
|
175
|
+
|
176
|
+
# This 3D Secure card requires authentication for all transactions,
|
177
|
+
# regardless of its setup.
|
178
|
+
# Please refer to the Stripe documentation for more information:
|
179
|
+
# https://stripe.com/docs/testing#authentication-and-setup
|
180
|
+
fill_stripe_form(number: '4000002760003184')
|
181
|
+
submit_payment
|
182
|
+
check_terms_of_service
|
183
|
+
confirm_order
|
184
|
+
authorize_3d_secure_payment(authenticate: true)
|
185
|
+
expect(page).to have_content('Your order has been processed successfully')
|
186
|
+
payment_intent_is_created_with_required_capture
|
187
|
+
|
188
|
+
visit_payment_step(user: user)
|
189
|
+
choose_new_stripe_payment
|
190
|
+
fill_in_stripe_country('United States')
|
191
|
+
|
192
|
+
# This test script is using 3D Secure 2 authentication, which must be
|
193
|
+
# completed for the payment to be successful.
|
194
|
+
# Please refer to the Stripe documentation for more information:
|
195
|
+
# https://stripe.com/docs/testing#three-ds-cards
|
196
|
+
fill_stripe_form(number: '4000000000003220')
|
197
|
+
submit_payment
|
198
|
+
check_terms_of_service
|
199
|
+
confirm_order
|
200
|
+
authorize_3d_secure_2_payment(authenticate: true)
|
201
|
+
expect(page).to have_content('Your order has been processed successfully')
|
202
|
+
payment_intent_is_created_with_required_capture
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
data/tmp/.keep
ADDED
File without changes
|