solidus_stripe 5.0.0.alpha.1 → 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 +15 -8
- data/README.md +94 -52
- data/app/models/solidus_stripe/gateway.rb +21 -23
- data/app/models/solidus_stripe/payment_intent.rb +27 -14
- data/app/subscribers/solidus_stripe/webhook/charge_subscriber.rb +3 -3
- data/app/subscribers/solidus_stripe/webhook/payment_intent_subscriber.rb +5 -5
- data/app/views/spree/admin/payments/source_forms/existing_payment/_stripe.html.erb +6 -1
- data/db/migrate/20230306105520_create_solidus_stripe_payment_intents.rb +6 -2
- data/db/migrate/20230308122414_create_solidus_stripe_slug_entries.rb +12 -0
- data/db/migrate/20230313150008_create_solidus_stripe_customers.rb +2 -3
- data/lib/generators/solidus_stripe/install/templates/app/javascript/controllers/solidus_stripe_payment_controller.js +3 -3
- data/lib/generators/solidus_stripe/install/templates/app/views/checkouts/existing_payment/_stripe.html.erb +6 -1
- data/lib/generators/solidus_stripe/install/templates/app/views/checkouts/payment/_stripe.html.erb +49 -14
- data/lib/generators/solidus_stripe/install/templates/app/views/orders/payment_info/_stripe.html.erb +15 -3
- data/lib/solidus_stripe/refunds_synchronizer.rb +26 -24
- data/lib/solidus_stripe/testing_support/factories.rb +18 -18
- data/lib/solidus_stripe/version.rb +1 -1
- data/lib/solidus_stripe/webhook/event.rb +6 -5
- data/spec/lib/solidus_stripe/refunds_synchronizer_spec.rb +47 -47
- data/spec/lib/solidus_stripe/webhook/event_spec.rb +10 -10
- data/spec/models/solidus_stripe/customer_spec.rb +3 -3
- data/spec/models/solidus_stripe/gateway_spec.rb +52 -54
- data/spec/models/solidus_stripe/payment_intent_spec.rb +62 -1
- data/spec/models/solidus_stripe/payment_method_spec.rb +16 -16
- data/spec/models/solidus_stripe/payment_source_spec.rb +3 -3
- data/spec/requests/solidus_stripe/intents_controller_spec.rb +2 -2
- data/spec/requests/solidus_stripe/webhooks_controller/charge/refunded_spec.rb +1 -1
- data/spec/requests/solidus_stripe/webhooks_controller/payment_intent/canceled_spec.rb +1 -1
- data/spec/requests/solidus_stripe/webhooks_controller/payment_intent/payment_failed_spec.rb +1 -1
- data/spec/requests/solidus_stripe/webhooks_controller/payment_intent/succeeded_spec.rb +1 -1
- data/spec/requests/solidus_stripe/webhooks_controller_spec.rb +8 -4
- data/spec/subscribers/solidus_stripe/webhook/charge_subscriber_spec.rb +1 -1
- data/spec/subscribers/solidus_stripe/webhook/payment_intent_subscriber_spec.rb +12 -12
- data/spec/support/solidus_stripe/backend_test_helper.rb +17 -42
- data/spec/support/solidus_stripe/checkout_test_helper.rb +27 -1
- data/spec/support/solidus_stripe/webhook/event_with_context_factory.rb +1 -1
- data/spec/system/backend/solidus_stripe/orders/payments_spec.rb +47 -21
- data/spec/system/frontend/solidus_stripe/checkout_spec.rb +19 -0
- metadata +3 -8
- data/db/migrate/20230303154931_create_solidus_stripe_setup_intent.rb +0 -10
- data/db/migrate/20230308122414_create_solidus_stripe_webhook_endpoints.rb +0 -10
- data/db/migrate/20230310152615_add_payment_method_reference_to_stripe_intents.rb +0 -6
- data/db/migrate/20230310171444_normalize_stripe_intent_id_attributes.rb +0 -6
- data/db/migrate/20230323154931_drop_solidus_stripe_setup_intent.rb +0 -13
- data/db/migrate/20230403094916_rename_webhook_endpoint_to_payment_method_slug_entries.rb +0 -5
@@ -6,7 +6,7 @@ RSpec.describe SolidusStripe::Webhook::PaymentIntentSubscriber do
|
|
6
6
|
describe "#capture_payment" do
|
7
7
|
context "when a full capture is performed" do
|
8
8
|
it "completes a pending payment" do
|
9
|
-
payment_method = create(:
|
9
|
+
payment_method = create(:solidus_stripe_payment_method)
|
10
10
|
stripe_payment_intent = Stripe::PaymentIntent.construct_from(
|
11
11
|
id: "pi_123",
|
12
12
|
amount: 1000,
|
@@ -30,7 +30,7 @@ RSpec.describe SolidusStripe::Webhook::PaymentIntentSubscriber do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "adds a log entry to the payment" do
|
33
|
-
payment_method = create(:
|
33
|
+
payment_method = create(:solidus_stripe_payment_method)
|
34
34
|
stripe_payment_intent = Stripe::PaymentIntent.construct_from(
|
35
35
|
id: "pi_123",
|
36
36
|
amount: 1000,
|
@@ -61,7 +61,7 @@ RSpec.describe SolidusStripe::Webhook::PaymentIntentSubscriber do
|
|
61
61
|
context "when a partial capture is performed" do
|
62
62
|
it "completes a pending payment" do
|
63
63
|
SolidusStripe::Seeds.refund_reasons
|
64
|
-
payment_method = create(:
|
64
|
+
payment_method = create(:solidus_stripe_payment_method)
|
65
65
|
stripe_payment_intent = Stripe::PaymentIntent.construct_from(
|
66
66
|
id: "pi_123",
|
67
67
|
amount: 1000,
|
@@ -91,7 +91,7 @@ RSpec.describe SolidusStripe::Webhook::PaymentIntentSubscriber do
|
|
91
91
|
|
92
92
|
it "synchronizes refunds" do
|
93
93
|
SolidusStripe::Seeds.refund_reasons
|
94
|
-
payment_method = create(:
|
94
|
+
payment_method = create(:solidus_stripe_payment_method)
|
95
95
|
stripe_payment_intent = Stripe::PaymentIntent.construct_from(
|
96
96
|
id: "pi_123",
|
97
97
|
amount: 1000,
|
@@ -121,7 +121,7 @@ RSpec.describe SolidusStripe::Webhook::PaymentIntentSubscriber do
|
|
121
121
|
|
122
122
|
it "adds a log entry for the captured payment" do
|
123
123
|
SolidusStripe::Seeds.refund_reasons
|
124
|
-
payment_method = create(:
|
124
|
+
payment_method = create(:solidus_stripe_payment_method)
|
125
125
|
stripe_payment_intent = Stripe::PaymentIntent.construct_from(
|
126
126
|
id: "pi_123",
|
127
127
|
amount: 1000,
|
@@ -154,7 +154,7 @@ RSpec.describe SolidusStripe::Webhook::PaymentIntentSubscriber do
|
|
154
154
|
end
|
155
155
|
|
156
156
|
it "does nothing if the payment is already completed" do
|
157
|
-
payment_method = create(:
|
157
|
+
payment_method = create(:solidus_stripe_payment_method)
|
158
158
|
stripe_payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123")
|
159
159
|
payment = create(:payment,
|
160
160
|
payment_method: payment_method,
|
@@ -175,7 +175,7 @@ RSpec.describe SolidusStripe::Webhook::PaymentIntentSubscriber do
|
|
175
175
|
|
176
176
|
describe "#fail_payment" do
|
177
177
|
it "fails a pending payment" do
|
178
|
-
payment_method = create(:
|
178
|
+
payment_method = create(:solidus_stripe_payment_method)
|
179
179
|
stripe_payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123")
|
180
180
|
payment = create(:payment,
|
181
181
|
payment_method: payment_method,
|
@@ -193,7 +193,7 @@ RSpec.describe SolidusStripe::Webhook::PaymentIntentSubscriber do
|
|
193
193
|
end
|
194
194
|
|
195
195
|
it "adds a log entry to the payment" do
|
196
|
-
payment_method = create(:
|
196
|
+
payment_method = create(:solidus_stripe_payment_method)
|
197
197
|
stripe_payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123")
|
198
198
|
payment = create(:payment,
|
199
199
|
payment_method: payment_method,
|
@@ -215,7 +215,7 @@ RSpec.describe SolidusStripe::Webhook::PaymentIntentSubscriber do
|
|
215
215
|
end
|
216
216
|
|
217
217
|
it "does nothing if the payment is already failed" do
|
218
|
-
payment_method = create(:
|
218
|
+
payment_method = create(:solidus_stripe_payment_method)
|
219
219
|
stripe_payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123")
|
220
220
|
payment = create(:payment,
|
221
221
|
payment_method: payment_method,
|
@@ -236,7 +236,7 @@ RSpec.describe SolidusStripe::Webhook::PaymentIntentSubscriber do
|
|
236
236
|
|
237
237
|
describe "#void_payment" do
|
238
238
|
it "voids a pending payment" do
|
239
|
-
payment_method = create(:
|
239
|
+
payment_method = create(:solidus_stripe_payment_method)
|
240
240
|
stripe_payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", cancellation_reason: "duplicate")
|
241
241
|
payment = create(:payment,
|
242
242
|
payment_method: payment_method,
|
@@ -254,7 +254,7 @@ RSpec.describe SolidusStripe::Webhook::PaymentIntentSubscriber do
|
|
254
254
|
end
|
255
255
|
|
256
256
|
it "adds a log entry to the payment" do
|
257
|
-
payment_method = create(:
|
257
|
+
payment_method = create(:solidus_stripe_payment_method)
|
258
258
|
stripe_payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", cancellation_reason: "duplicate")
|
259
259
|
payment = create(:payment,
|
260
260
|
payment_method: payment_method,
|
@@ -276,7 +276,7 @@ RSpec.describe SolidusStripe::Webhook::PaymentIntentSubscriber do
|
|
276
276
|
end
|
277
277
|
|
278
278
|
it "does nothing if the payment is already voided" do
|
279
|
-
payment_method = create(:
|
279
|
+
payment_method = create(:solidus_stripe_payment_method)
|
280
280
|
stripe_payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", cancellation_reason: "duplicate")
|
281
281
|
payment = create(:payment,
|
282
282
|
payment_method: payment_method,
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module SolidusStripe::BackendTestHelper
|
4
4
|
def create_payment_method(setup_future_usage: 'off_session', auto_capture: false)
|
5
5
|
@payment_method = create(
|
6
|
-
:
|
6
|
+
:solidus_stripe_payment_method,
|
7
7
|
preferred_setup_future_usage: setup_future_usage,
|
8
8
|
auto_capture: auto_capture
|
9
9
|
)
|
@@ -77,12 +77,12 @@ module SolidusStripe::BackendTestHelper
|
|
77
77
|
|
78
78
|
def create_authorized_payment(opts = {})
|
79
79
|
stripe_payment_method = create_stripe_payment_method(opts[:card_number] || '4242424242424242')
|
80
|
-
|
80
|
+
stripe_payment_intent = create_stripe_payment_intent(stripe_payment_method.id)
|
81
81
|
|
82
|
-
create(:
|
82
|
+
create(:solidus_stripe_payment,
|
83
83
|
:authorized,
|
84
84
|
order: order,
|
85
|
-
response_code:
|
85
|
+
response_code: stripe_payment_intent.id,
|
86
86
|
stripe_payment_method_id: stripe_payment_method.id,
|
87
87
|
payment_method: payment_method)
|
88
88
|
end
|
@@ -132,6 +132,18 @@ module SolidusStripe::BackendTestHelper
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
+
def capture_partial_payment_amount(payment, amount)
|
136
|
+
within_row(1) do
|
137
|
+
click_icon(:edit)
|
138
|
+
fill_in('amount', with: amount)
|
139
|
+
click_icon(:ok)
|
140
|
+
expect(page).to have_selector('td.amount span', text: amount.to_money.format)
|
141
|
+
expect(payment.reload.amount).to eq(amount)
|
142
|
+
end
|
143
|
+
|
144
|
+
capture_payment
|
145
|
+
end
|
146
|
+
|
135
147
|
def void_payment
|
136
148
|
click_icon(:void)
|
137
149
|
end
|
@@ -149,43 +161,6 @@ module SolidusStripe::BackendTestHelper
|
|
149
161
|
|
150
162
|
# Helper methods for checking expected outcomes and states
|
151
163
|
|
152
|
-
def expects_page_to_display_successfully_captured_payment(payment)
|
153
|
-
expect(page).to have_content('Payment Updated')
|
154
|
-
expect(payment.reload.state).to eq('completed')
|
155
|
-
expect(payment.capture_events.first.amount).to eq(payment.amount)
|
156
|
-
end
|
157
|
-
|
158
|
-
def expects_page_to_display_successfully_refunded_payment(payment)
|
159
|
-
expect(page).to have_content('Refund has been successfully created!')
|
160
|
-
expect(payment).to be_fully_refunded
|
161
|
-
end
|
162
|
-
|
163
|
-
def expects_page_to_display_successfully_partially_refunded_payment(payment, amount)
|
164
|
-
expect(page).to have_content('Refund has been successfully created!')
|
165
|
-
expect(payment.reload.state).to eq('completed')
|
166
|
-
expect(payment.refunds.first.amount).to eq(amount)
|
167
|
-
end
|
168
|
-
|
169
|
-
def expects_page_to_display_successfully_voided_payment(payment)
|
170
|
-
expect(page).to have_content('Payment Updated')
|
171
|
-
expect(payment.reload.state).to eq('void')
|
172
|
-
end
|
173
|
-
|
174
|
-
def expects_page_to_display_successfully_canceled_order_payment(payment)
|
175
|
-
expect(page).to have_content('Order canceled')
|
176
|
-
expect(payment.reload.state).to eq('void')
|
177
|
-
end
|
178
|
-
|
179
|
-
def expects_page_to_display_capture_fail_message(payment, message)
|
180
|
-
expect(page).to have_content(message)
|
181
|
-
expect(payment.reload.state).to eq('failed')
|
182
|
-
end
|
183
|
-
|
184
|
-
def expects_page_to_display_payment(payment)
|
185
|
-
click_on 'Payments'
|
186
|
-
expect(page).to have_content(payment.number)
|
187
|
-
end
|
188
|
-
|
189
164
|
def expects_page_to_display_log_messages(log_messages = [])
|
190
165
|
expect(page).to have_content('Log Entries')
|
191
166
|
log_messages.each do |log_message|
|
@@ -205,6 +180,6 @@ module SolidusStripe::BackendTestHelper
|
|
205
180
|
|
206
181
|
def expects_payment_to_have_correct_capture_amount_on_stripe(payment, amount)
|
207
182
|
stripe_payment_intent = fetch_stripe_payment_intent(payment)
|
208
|
-
expect(stripe_payment_intent.amount_received).to eq(amount
|
183
|
+
expect(stripe_payment_intent.amount_received).to eq(amount.to_money.fractional)
|
209
184
|
end
|
210
185
|
end
|
@@ -25,7 +25,7 @@ module SolidusStripe::CheckoutTestHelper
|
|
25
25
|
|
26
26
|
def create_payment_method(setup_future_usage: 'off_session', auto_capture: false)
|
27
27
|
@payment_method = create(
|
28
|
-
:
|
28
|
+
:solidus_stripe_payment_method,
|
29
29
|
preferred_setup_future_usage: setup_future_usage,
|
30
30
|
auto_capture: auto_capture
|
31
31
|
)
|
@@ -188,6 +188,28 @@ module SolidusStripe::CheckoutTestHelper
|
|
188
188
|
choose(option: payment_method.id)
|
189
189
|
end
|
190
190
|
|
191
|
+
def choose_stripe_payment_method(payment_method_type: 'card')
|
192
|
+
using_wait_time(10) do
|
193
|
+
within_frame(find_stripe_iframe) do
|
194
|
+
# Stripe doesn't display payment methods in the same order.
|
195
|
+
# The payment method order is based on the most used in that
|
196
|
+
# context (and other parameters).
|
197
|
+
# For this reason, if the payment method tab is not visible,
|
198
|
+
# it will be selected from the dedicated additional Stripe
|
199
|
+
# payment methods "select" rendered in the Stripe payment form.
|
200
|
+
#
|
201
|
+
# https://stripe.com/docs/payments/customize-payment-element#payment-method-order
|
202
|
+
if has_css?("##{payment_method_type}-tab")
|
203
|
+
find("##{payment_method_type}-tab").click
|
204
|
+
else
|
205
|
+
find(
|
206
|
+
".p-AdditionalPaymentMethods-menu option[value='#{payment_method_type}']"
|
207
|
+
).select_option
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
191
213
|
def submit_payment
|
192
214
|
click_button("Save and Continue")
|
193
215
|
end
|
@@ -216,6 +238,10 @@ module SolidusStripe::CheckoutTestHelper
|
|
216
238
|
expect(last_stripe_payment.state).to eq('failed')
|
217
239
|
end
|
218
240
|
|
241
|
+
def expects_payment_to_be_processing
|
242
|
+
expect(last_stripe_payment.state).to eq('processing')
|
243
|
+
end
|
244
|
+
|
219
245
|
def expects_page_to_not_display_wallet_payment_sources
|
220
246
|
expect(page).to have_no_selector("[name='order[wallet_payment_source_id]']")
|
221
247
|
end
|
@@ -4,41 +4,62 @@ require 'solidus_stripe_spec_helper'
|
|
4
4
|
|
5
5
|
RSpec.describe 'SolidusStripe Orders Payments', :js do
|
6
6
|
include SolidusStripe::BackendTestHelper
|
7
|
+
include Devise::Test::IntegrationHelpers
|
7
8
|
stub_authorization!
|
8
9
|
|
10
|
+
let(:user) { create(:admin_user) }
|
11
|
+
|
9
12
|
context 'with successful payment operations' do
|
10
13
|
it 'navigates to the payments page' do
|
11
14
|
payment = create_authorized_payment
|
12
15
|
visit_payments_page
|
13
16
|
|
14
|
-
|
17
|
+
click_on 'Payments'
|
18
|
+
expect(page).to have_content(payment.number)
|
15
19
|
end
|
16
20
|
|
17
21
|
it 'displays log entries for a payment' do
|
18
|
-
payment = create(:
|
22
|
+
payment = create(:solidus_stripe_payment, :captured, order: order, payment_method: payment_method)
|
19
23
|
|
20
24
|
visit_payment_page(payment)
|
21
25
|
|
22
26
|
expects_page_to_display_log_messages(["PaymentIntent was confirmed and captured successfully"])
|
23
27
|
end
|
24
28
|
|
25
|
-
it 'captures an authorized payment
|
29
|
+
it 'successfully captures an authorized payment' do
|
26
30
|
payment = create_authorized_payment
|
27
31
|
visit_payments_page
|
28
32
|
|
29
33
|
capture_payment
|
30
34
|
|
31
|
-
|
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)
|
32
38
|
expects_payment_to_have_correct_capture_amount_on_stripe(payment, payment.amount)
|
33
39
|
end
|
34
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
|
+
|
35
55
|
it 'voids a payment from an order' do
|
36
56
|
payment = create_authorized_payment
|
37
57
|
visit_payments_page
|
38
58
|
|
39
59
|
void_payment
|
40
60
|
|
41
|
-
|
61
|
+
expect(page).to have_content('Payment Updated')
|
62
|
+
expect(payment.reload.state).to eq('void')
|
42
63
|
expects_payment_to_be_voided_on_stripe(payment)
|
43
64
|
end
|
44
65
|
|
@@ -48,7 +69,8 @@ RSpec.describe 'SolidusStripe Orders Payments', :js do
|
|
48
69
|
|
49
70
|
refund_payment
|
50
71
|
|
51
|
-
|
72
|
+
expect(page).to have_content('Refund has been successfully created!')
|
73
|
+
expect(payment).to be_fully_refunded
|
52
74
|
expects_payment_to_be_refunded_on_stripe(payment, payment.amount)
|
53
75
|
end
|
54
76
|
|
@@ -60,35 +82,35 @@ RSpec.describe 'SolidusStripe Orders Payments', :js do
|
|
60
82
|
partial_refund_amount = 25
|
61
83
|
partially_refund_payment(refund_reason, partial_refund_amount)
|
62
84
|
|
63
|
-
|
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)
|
64
88
|
expects_payment_to_be_refunded_on_stripe(payment, partial_refund_amount)
|
65
89
|
end
|
66
90
|
|
67
91
|
it 'cancels an order with captured payment' do
|
68
92
|
payment = create_captured_payment
|
93
|
+
|
94
|
+
sign_in user
|
69
95
|
visit_payments_page
|
70
96
|
|
71
97
|
cancel_order
|
72
98
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
expects_page_to_display_successfully_canceled_order_payment(payment)
|
77
|
-
expects_payment_to_be_voided_on_stripe(payment)
|
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)
|
78
102
|
end
|
79
103
|
|
80
104
|
it 'cancels an order with authorized payment' do
|
81
105
|
payment = create_authorized_payment
|
106
|
+
|
107
|
+
sign_in user
|
82
108
|
visit_payments_page
|
83
109
|
|
84
110
|
cancel_order
|
85
111
|
|
86
|
-
|
87
|
-
|
88
|
-
# with locating the user who canceled the order.
|
89
|
-
pending "needs to implement try_void method to handle voiding payments on order cancellation"
|
90
|
-
|
91
|
-
expects_page_to_display_successfully_canceled_order_payment(payment)
|
112
|
+
expect(page).to have_content('Order canceled')
|
113
|
+
expect(payment.reload.state).to eq('void')
|
92
114
|
expects_payment_to_be_voided_on_stripe(payment)
|
93
115
|
end
|
94
116
|
|
@@ -100,7 +122,9 @@ RSpec.describe 'SolidusStripe Orders Payments', :js do
|
|
100
122
|
capture_payment
|
101
123
|
payment = last_valid_payment
|
102
124
|
|
103
|
-
|
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)
|
104
128
|
expects_payment_to_have_correct_capture_amount_on_stripe(payment, payment.amount)
|
105
129
|
end
|
106
130
|
end
|
@@ -112,8 +136,10 @@ RSpec.describe 'SolidusStripe Orders Payments', :js do
|
|
112
136
|
|
113
137
|
capture_payment
|
114
138
|
|
115
|
-
|
116
|
-
'This PaymentIntent could not be captured because it has a status of requires_action.'
|
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')
|
117
143
|
end
|
118
144
|
end
|
119
145
|
end
|
@@ -80,6 +80,25 @@ RSpec.describe 'SolidusStripe Checkout', :js do
|
|
80
80
|
end
|
81
81
|
end
|
82
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
|
+
|
83
102
|
context 'with declined cards' do
|
84
103
|
it 'reject transactions with cards declined at intent creation or invalid fields and return an appropriate response' do # rubocop:disable Layout/LineLength
|
85
104
|
create_payment_method
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.0.
|
4
|
+
version: 5.0.0.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -200,14 +200,9 @@ files:
|
|
200
200
|
- config/routes.rb
|
201
201
|
- coverage.rb
|
202
202
|
- db/migrate/20230109183332_create_solidus_stripe_payment_sources.rb
|
203
|
-
- db/migrate/20230303154931_create_solidus_stripe_setup_intent.rb
|
204
203
|
- db/migrate/20230306105520_create_solidus_stripe_payment_intents.rb
|
205
|
-
- db/migrate/
|
206
|
-
- db/migrate/20230310152615_add_payment_method_reference_to_stripe_intents.rb
|
207
|
-
- db/migrate/20230310171444_normalize_stripe_intent_id_attributes.rb
|
204
|
+
- db/migrate/20230308122414_create_solidus_stripe_slug_entries.rb
|
208
205
|
- db/migrate/20230313150008_create_solidus_stripe_customers.rb
|
209
|
-
- db/migrate/20230323154931_drop_solidus_stripe_setup_intent.rb
|
210
|
-
- db/migrate/20230403094916_rename_webhook_endpoint_to_payment_method_slug_entries.rb
|
211
206
|
- db/seeds.rb
|
212
207
|
- lib/generators/solidus_stripe/install/install_generator.rb
|
213
208
|
- lib/generators/solidus_stripe/install/templates/app/assets/stylesheets/spree/frontend/solidus_stripe.css
|
@@ -1,10 +0,0 @@
|
|
1
|
-
class CreateSolidusStripeSetupIntent < ActiveRecord::Migration[7.0]
|
2
|
-
def change
|
3
|
-
create_table :solidus_stripe_setup_intents do |t|
|
4
|
-
t.string :stripe_setup_intent_id
|
5
|
-
t.references :order, null: false, foreign_key: { to_table: :spree_orders }
|
6
|
-
|
7
|
-
t.timestamps
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
class CreateSolidusStripeWebhookEndpoints < ActiveRecord::Migration[5.2]
|
2
|
-
def change
|
3
|
-
create_table :solidus_stripe_webhook_endpoints do |t|
|
4
|
-
t.references :payment_method, null: false, foreign_key: { to_table: :spree_payment_methods }
|
5
|
-
t.string :slug, null: false, index: { unique: true }
|
6
|
-
|
7
|
-
t.timestamps
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,6 +0,0 @@
|
|
1
|
-
class AddPaymentMethodReferenceToStripeIntents < ActiveRecord::Migration[7.0]
|
2
|
-
def change
|
3
|
-
add_reference :solidus_stripe_setup_intents, :payment_method, null: false, foreign_key: { to_table: :spree_payment_methods }
|
4
|
-
add_reference :solidus_stripe_payment_intents, :payment_method, null: false, foreign_key: { to_table: :spree_payment_methods }
|
5
|
-
end
|
6
|
-
end
|
@@ -1,6 +0,0 @@
|
|
1
|
-
class NormalizeStripeIntentIdAttributes < ActiveRecord::Migration[7.0]
|
2
|
-
def change
|
3
|
-
rename_column :solidus_stripe_payment_intents, :stripe_payment_intent_id, :stripe_intent_id
|
4
|
-
rename_column :solidus_stripe_setup_intents, :stripe_setup_intent_id, :stripe_intent_id
|
5
|
-
end
|
6
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class DropSolidusStripeSetupIntent < ActiveRecord::Migration[7.0]
|
2
|
-
def change
|
3
|
-
drop_table "solidus_stripe_setup_intents", force: :cascade do |t|
|
4
|
-
t.string "stripe_intent_id"
|
5
|
-
t.integer "order_id", null: false
|
6
|
-
t.datetime "created_at", null: false
|
7
|
-
t.datetime "updated_at", null: false
|
8
|
-
t.integer "payment_method_id", null: false
|
9
|
-
t.index ["order_id"], name: "index_solidus_stripe_setup_intents_on_order_id"
|
10
|
-
t.index ["payment_method_id"], name: "index_solidus_stripe_setup_intents_on_payment_method_id"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|