stripe-ruby-mock 3.0.1 → 3.1.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +2 -5
- data/CHANGELOG.md +28 -15
- data/Gemfile +1 -0
- data/lib/stripe_mock.rb +4 -0
- data/lib/stripe_mock/api/client.rb +1 -1
- data/lib/stripe_mock/api/instance.rb +1 -1
- data/lib/stripe_mock/api/webhooks.rb +2 -0
- data/lib/stripe_mock/client.rb +2 -1
- data/lib/stripe_mock/data.rb +127 -25
- data/lib/stripe_mock/data/list.rb +31 -6
- data/lib/stripe_mock/instance.rb +7 -2
- data/lib/stripe_mock/request_handlers/account_links.rb +15 -0
- data/lib/stripe_mock/request_handlers/charges.rb +6 -4
- data/lib/stripe_mock/request_handlers/checkout_session.rb +16 -0
- data/lib/stripe_mock/request_handlers/customers.rb +22 -13
- data/lib/stripe_mock/request_handlers/ephemeral_key.rb +1 -1
- data/lib/stripe_mock/request_handlers/express_login_links.rb +15 -0
- data/lib/stripe_mock/request_handlers/helpers/subscription_helpers.rb +12 -7
- data/lib/stripe_mock/request_handlers/invoices.rb +4 -3
- data/lib/stripe_mock/request_handlers/payment_methods.rb +8 -5
- data/lib/stripe_mock/request_handlers/prices.rb +44 -0
- data/lib/stripe_mock/request_handlers/sources.rb +12 -6
- data/lib/stripe_mock/request_handlers/subscriptions.rb +29 -19
- data/lib/stripe_mock/request_handlers/tokens.rb +6 -4
- data/lib/stripe_mock/request_handlers/validators/param_validators.rb +32 -0
- data/lib/stripe_mock/test_strategies/base.rb +26 -0
- data/lib/stripe_mock/version.rb +1 -1
- data/lib/stripe_mock/webhook_fixtures/balance.available.json +6 -0
- data/lib/stripe_mock/webhook_fixtures/payment_intent.payment_failed.json +186 -0
- data/lib/stripe_mock/webhook_fixtures/payment_intent.succeeded.json +164 -0
- data/spec/instance_spec.rb +4 -6
- data/spec/list_spec.rb +23 -0
- data/spec/server_spec.rb +4 -2
- data/spec/shared_stripe_examples/account_link_examples.rb +16 -0
- data/spec/shared_stripe_examples/balance_examples.rb +6 -0
- data/spec/shared_stripe_examples/card_token_examples.rb +17 -21
- data/spec/shared_stripe_examples/checkout_examples.rb +20 -1
- data/spec/shared_stripe_examples/customer_examples.rb +11 -13
- data/spec/shared_stripe_examples/express_login_link_examples.rb +12 -0
- data/spec/shared_stripe_examples/invoice_examples.rb +8 -8
- data/spec/shared_stripe_examples/payment_method_examples.rb +332 -68
- data/spec/shared_stripe_examples/price_examples.rb +183 -0
- data/spec/shared_stripe_examples/subscription_examples.rb +115 -8
- data/spec/spec_helper.rb +4 -0
- data/spec/stripe_mock_spec.rb +2 -2
- data/spec/support/stripe_examples.rb +5 -1
- data/stripe-ruby-mock.gemspec +6 -1
- metadata +25 -11
@@ -25,6 +25,16 @@ shared_examples 'PaymentMethod API' do
|
|
25
25
|
cvc: 999
|
26
26
|
}
|
27
27
|
end
|
28
|
+
let(:sepa_debit_details) do
|
29
|
+
{
|
30
|
+
iban: 'DE89370400440532013000'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
let(:ideal_details) do
|
34
|
+
{
|
35
|
+
bank: 'bunq'
|
36
|
+
}
|
37
|
+
end
|
28
38
|
|
29
39
|
# post /v1/payment_methods
|
30
40
|
describe 'Create a PaymentMethod', live: true do
|
@@ -38,26 +48,77 @@ shared_examples 'PaymentMethod API' do
|
|
38
48
|
}
|
39
49
|
)
|
40
50
|
end
|
41
|
-
let(:type) { 'card' }
|
42
51
|
|
43
|
-
|
44
|
-
|
52
|
+
context 'with credit card' do
|
53
|
+
let(:type) { 'card' }
|
54
|
+
|
55
|
+
it 'creates a payment method with a valid id', live: false do
|
56
|
+
expect(payment_method.id).to match(/^test_pm/)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'creates a payment method with a billing address' do
|
60
|
+
expect(payment_method.billing_details.address.city).to eq('North New Portland')
|
61
|
+
expect(payment_method.billing_details.address.country).to eq('US')
|
62
|
+
expect(payment_method.billing_details.address.line1).to eq('2631 Bloomfield Way')
|
63
|
+
expect(payment_method.billing_details.address.line2).to eq('Apartment 5B')
|
64
|
+
expect(payment_method.billing_details.address.postal_code).to eq('05555')
|
65
|
+
expect(payment_method.billing_details.address.state).to eq('ME')
|
66
|
+
expect(payment_method.billing_details.email).to eq('john@example.com')
|
67
|
+
expect(payment_method.billing_details.name).to eq('John Doe')
|
68
|
+
expect(payment_method.billing_details.phone).to eq('555-555-5555')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'creates a payment method with metadata' do
|
72
|
+
expect(payment_method.metadata.order_id).to eq('123456789')
|
73
|
+
end
|
45
74
|
end
|
46
75
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
76
|
+
context 'with ideal' do
|
77
|
+
let(:type) { 'ideal' }
|
78
|
+
|
79
|
+
it 'creates a payment method with a valid id', live: false do
|
80
|
+
expect(payment_method.id).to match(/^test_pm/)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'creates a payment method with a billing address' do
|
84
|
+
expect(payment_method.billing_details.address.city).to eq('North New Portland')
|
85
|
+
expect(payment_method.billing_details.address.country).to eq('US')
|
86
|
+
expect(payment_method.billing_details.address.line1).to eq('2631 Bloomfield Way')
|
87
|
+
expect(payment_method.billing_details.address.line2).to eq('Apartment 5B')
|
88
|
+
expect(payment_method.billing_details.address.postal_code).to eq('05555')
|
89
|
+
expect(payment_method.billing_details.address.state).to eq('ME')
|
90
|
+
expect(payment_method.billing_details.email).to eq('john@example.com')
|
91
|
+
expect(payment_method.billing_details.name).to eq('John Doe')
|
92
|
+
expect(payment_method.billing_details.phone).to eq('555-555-5555')
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'creates a payment method with metadata' do
|
96
|
+
expect(payment_method.metadata.order_id).to eq('123456789')
|
97
|
+
end
|
57
98
|
end
|
58
99
|
|
59
|
-
|
60
|
-
|
100
|
+
context 'with sepa debit' do
|
101
|
+
let(:type) { 'sepa_debit' }
|
102
|
+
|
103
|
+
it 'creates a payment method with a valid id', live: false do
|
104
|
+
expect(payment_method.id).to match(/^test_pm/)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'creates a payment method with a billing address' do
|
108
|
+
expect(payment_method.billing_details.address.city).to eq('North New Portland')
|
109
|
+
expect(payment_method.billing_details.address.country).to eq('US')
|
110
|
+
expect(payment_method.billing_details.address.line1).to eq('2631 Bloomfield Way')
|
111
|
+
expect(payment_method.billing_details.address.line2).to eq('Apartment 5B')
|
112
|
+
expect(payment_method.billing_details.address.postal_code).to eq('05555')
|
113
|
+
expect(payment_method.billing_details.address.state).to eq('ME')
|
114
|
+
expect(payment_method.billing_details.email).to eq('john@example.com')
|
115
|
+
expect(payment_method.billing_details.name).to eq('John Doe')
|
116
|
+
expect(payment_method.billing_details.phone).to eq('555-555-5555')
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'creates a payment method with metadata' do
|
120
|
+
expect(payment_method.metadata.order_id).to eq('123456789')
|
121
|
+
end
|
61
122
|
end
|
62
123
|
|
63
124
|
context 'when type is invalid' do
|
@@ -71,16 +132,46 @@ shared_examples 'PaymentMethod API' do
|
|
71
132
|
|
72
133
|
# get /v1/payment_methods/:id
|
73
134
|
describe 'Retrieve a PaymentMethod', live: true do
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
135
|
+
context 'with credit card' do
|
136
|
+
it 'retrieves a given payment method' do
|
137
|
+
customer = Stripe::Customer.create
|
138
|
+
original = Stripe::PaymentMethod.create(type: 'card', card: card_details)
|
139
|
+
Stripe::PaymentMethod.attach(original.id, customer: customer.id)
|
78
140
|
|
79
|
-
|
141
|
+
payment_method = Stripe::PaymentMethod.retrieve(original.id)
|
80
142
|
|
81
|
-
|
82
|
-
|
83
|
-
|
143
|
+
expect(payment_method.id).to eq(original.id)
|
144
|
+
expect(payment_method.type).to eq(original.type)
|
145
|
+
expect(payment_method.customer).to eq(customer.id)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context 'with ideal' do
|
150
|
+
it 'retrieves a given payment method' do
|
151
|
+
customer = Stripe::Customer.create
|
152
|
+
original = Stripe::PaymentMethod.create(type: 'ideal', ideal: ideal_details)
|
153
|
+
Stripe::PaymentMethod.attach(original.id, customer: customer.id)
|
154
|
+
|
155
|
+
payment_method = Stripe::PaymentMethod.retrieve(original.id)
|
156
|
+
|
157
|
+
expect(payment_method.id).to eq(original.id)
|
158
|
+
expect(payment_method.type).to eq(original.type)
|
159
|
+
expect(payment_method.customer).to eq(customer.id)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
context 'with sepa debit' do
|
164
|
+
it 'retrieves a given payment method' do
|
165
|
+
customer = Stripe::Customer.create
|
166
|
+
original = Stripe::PaymentMethod.create(type: 'sepa_debit', sepa_debit: sepa_debit_details)
|
167
|
+
Stripe::PaymentMethod.attach(original.id, customer: customer.id)
|
168
|
+
|
169
|
+
payment_method = Stripe::PaymentMethod.retrieve(original.id)
|
170
|
+
|
171
|
+
expect(payment_method.id).to eq(original.id)
|
172
|
+
expect(payment_method.type).to eq(original.type)
|
173
|
+
expect(payment_method.customer).to eq(customer.id)
|
174
|
+
end
|
84
175
|
end
|
85
176
|
|
86
177
|
it "cannot retrieve a payment_method that doesn't exist" do
|
@@ -90,33 +181,85 @@ shared_examples 'PaymentMethod API' do
|
|
90
181
|
expect(e.http_status).to eq(404)
|
91
182
|
}
|
92
183
|
end
|
93
|
-
|
94
184
|
end
|
95
185
|
|
96
186
|
# get /v1/payment_methods
|
97
187
|
describe "List a Customer's PaymentMethods", live: true do
|
98
|
-
let(:
|
188
|
+
let(:customer1) { Stripe::Customer.create }
|
99
189
|
let(:customer2) { Stripe::Customer.create }
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
190
|
+
|
191
|
+
context 'with credit card' do
|
192
|
+
before do
|
193
|
+
3.times do
|
194
|
+
payment_method = Stripe::PaymentMethod.create(type: 'card', card: card_details)
|
195
|
+
Stripe::PaymentMethod.attach(payment_method.id, customer: customer1.id)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
it 'lists all payment methods' do
|
200
|
+
expect(Stripe::PaymentMethod.list(customer: customer1.id, type: 'card').count).to eq(3)
|
201
|
+
end
|
202
|
+
|
203
|
+
context 'when passing a limit' do
|
204
|
+
it 'only lists the limited number of payment methods' do
|
205
|
+
expect(Stripe::PaymentMethod.list(customer: customer1.id, type: 'card', limit: 2).count).to eq(2)
|
206
|
+
end
|
104
207
|
end
|
105
|
-
end
|
106
208
|
|
107
|
-
|
108
|
-
|
209
|
+
context 'when listing the payment methods of another customer' do
|
210
|
+
it 'does not list any payment methods' do
|
211
|
+
expect(Stripe::PaymentMethod.list(customer: customer2.id, type: 'card').count).to eq(0)
|
212
|
+
end
|
213
|
+
end
|
109
214
|
end
|
110
215
|
|
111
|
-
context '
|
112
|
-
|
113
|
-
|
216
|
+
context 'with ideal' do
|
217
|
+
before do
|
218
|
+
3.times do
|
219
|
+
payment_method = Stripe::PaymentMethod.create(type: 'ideal', ideal: ideal_details)
|
220
|
+
Stripe::PaymentMethod.attach(payment_method.id, customer: customer1.id)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'lists all payment methods' do
|
225
|
+
expect(Stripe::PaymentMethod.list(customer: customer1.id, type: 'ideal').count).to eq(3)
|
226
|
+
end
|
227
|
+
|
228
|
+
context 'when passing a limit' do
|
229
|
+
it 'only lists the limited number of payment methods' do
|
230
|
+
expect(Stripe::PaymentMethod.list(customer: customer1.id, type: 'ideal', limit: 2).count).to eq(2)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
context 'when listing the payment methods of another customer' do
|
235
|
+
it 'does not list any payment methods' do
|
236
|
+
expect(Stripe::PaymentMethod.list(customer: customer2.id, type: 'ideal').count).to eq(0)
|
237
|
+
end
|
114
238
|
end
|
115
239
|
end
|
116
240
|
|
117
|
-
context '
|
118
|
-
|
119
|
-
|
241
|
+
context 'with sepa debit' do
|
242
|
+
before do
|
243
|
+
3.times do
|
244
|
+
payment_method = Stripe::PaymentMethod.create(type: 'sepa_debit', sepa_debit: sepa_debit_details)
|
245
|
+
Stripe::PaymentMethod.attach(payment_method.id, customer: customer1.id)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
it 'lists all payment methods' do
|
250
|
+
expect(Stripe::PaymentMethod.list(customer: customer1.id, type: 'sepa_debit').count).to eq(3)
|
251
|
+
end
|
252
|
+
|
253
|
+
context 'when passing a limit' do
|
254
|
+
it 'only lists the limited number of payment methods' do
|
255
|
+
expect(Stripe::PaymentMethod.list(customer: customer1.id, type: 'sepa_debit', limit: 2).count).to eq(2)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
context 'when listing the payment methods of another customer' do
|
260
|
+
it 'does not list any payment methods' do
|
261
|
+
expect(Stripe::PaymentMethod.list(customer: customer2.id, type: 'sepa_debit').count).to eq(0)
|
262
|
+
end
|
120
263
|
end
|
121
264
|
end
|
122
265
|
end
|
@@ -124,18 +267,55 @@ shared_examples 'PaymentMethod API' do
|
|
124
267
|
# post /v1/payment_methods/:id/attach
|
125
268
|
describe 'Attach a PaymentMethod to a Customer', live: true do
|
126
269
|
let(:customer) { Stripe::Customer.create }
|
127
|
-
let(:payment_method) { Stripe::PaymentMethod.create(type: 'card', card: card_details) }
|
128
270
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
271
|
+
context 'with credit card' do
|
272
|
+
let(:payment_method) { Stripe::PaymentMethod.create(type: 'card', card: card_details) }
|
273
|
+
|
274
|
+
it 'attaches a payment method to a customer' do
|
275
|
+
expect { Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id) }
|
276
|
+
.to change { Stripe::PaymentMethod.retrieve(payment_method.id).customer }
|
277
|
+
.from(nil).to(customer.id)
|
278
|
+
end
|
279
|
+
|
280
|
+
context "when the customer doesn't exist" do
|
281
|
+
it 'raises invalid requestion exception' do
|
282
|
+
expect { Stripe::PaymentMethod.attach(payment_method.id, customer: 'cus_invalid') }
|
283
|
+
.to raise_error(Stripe::InvalidRequestError)
|
284
|
+
end
|
285
|
+
end
|
133
286
|
end
|
134
287
|
|
135
|
-
context
|
136
|
-
|
137
|
-
|
138
|
-
|
288
|
+
context 'with ideal' do
|
289
|
+
let(:payment_method) { Stripe::PaymentMethod.create(type: 'ideal', ideal: ideal_details) }
|
290
|
+
|
291
|
+
it 'attaches a payment method to a customer' do
|
292
|
+
expect { Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id) }
|
293
|
+
.to change { Stripe::PaymentMethod.retrieve(payment_method.id).customer }
|
294
|
+
.from(nil).to(customer.id)
|
295
|
+
end
|
296
|
+
|
297
|
+
context "when the customer doesn't exist" do
|
298
|
+
it 'raises invalid requestion exception' do
|
299
|
+
expect { Stripe::PaymentMethod.attach(payment_method.id, customer: 'cus_invalid') }
|
300
|
+
.to raise_error(Stripe::InvalidRequestError)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
context 'with sepa_debit' do
|
306
|
+
let(:payment_method) { Stripe::PaymentMethod.create(type: 'sepa_debit', sepa_debit: sepa_debit_details) }
|
307
|
+
|
308
|
+
it 'attaches a payment method to a customer' do
|
309
|
+
expect { Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id) }
|
310
|
+
.to change { Stripe::PaymentMethod.retrieve(payment_method.id).customer }
|
311
|
+
.from(nil).to(customer.id)
|
312
|
+
end
|
313
|
+
|
314
|
+
context "when the customer doesn't exist" do
|
315
|
+
it 'raises invalid requestion exception' do
|
316
|
+
expect { Stripe::PaymentMethod.attach(payment_method.id, customer: 'cus_invalid') }
|
317
|
+
.to raise_error(Stripe::InvalidRequestError)
|
318
|
+
end
|
139
319
|
end
|
140
320
|
end
|
141
321
|
end
|
@@ -143,42 +323,126 @@ shared_examples 'PaymentMethod API' do
|
|
143
323
|
# post /v1/payment_methods/:id/detach
|
144
324
|
describe 'Detach a PaymentMethod from a Customer', live: true do
|
145
325
|
let(:customer) { Stripe::Customer.create }
|
146
|
-
|
147
|
-
|
148
|
-
|
326
|
+
|
327
|
+
context 'with credit card' do
|
328
|
+
let(:payment_method) do
|
329
|
+
payment_method = Stripe::PaymentMethod.create(type: 'card', card: card_details)
|
330
|
+
Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id)
|
331
|
+
end
|
332
|
+
|
333
|
+
it 'detaches a PaymentMethod from a customer' do
|
334
|
+
expect { Stripe::PaymentMethod.detach(payment_method.id) }
|
335
|
+
.to change { Stripe::PaymentMethod.retrieve(payment_method.id).customer }
|
336
|
+
.from(customer.id).to(nil)
|
337
|
+
end
|
149
338
|
end
|
150
339
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
.
|
340
|
+
context 'with ideal' do
|
341
|
+
let(:payment_method) do
|
342
|
+
payment_method = Stripe::PaymentMethod.create(type: 'ideal', ideal: ideal_details)
|
343
|
+
Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id)
|
344
|
+
end
|
345
|
+
|
346
|
+
it 'detaches a PaymentMethod from a customer' do
|
347
|
+
expect { Stripe::PaymentMethod.detach(payment_method.id) }
|
348
|
+
.to change { Stripe::PaymentMethod.retrieve(payment_method.id).customer }
|
349
|
+
.from(customer.id).to(nil)
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
context 'with sepa debit' do
|
354
|
+
let(:payment_method) do
|
355
|
+
payment_method = Stripe::PaymentMethod.create(type: 'sepa_debit', sepa_debit: sepa_debit_details)
|
356
|
+
Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id)
|
357
|
+
end
|
358
|
+
|
359
|
+
it 'detaches a PaymentMethod from a customer' do
|
360
|
+
expect { Stripe::PaymentMethod.detach(payment_method.id) }
|
361
|
+
.to change { Stripe::PaymentMethod.retrieve(payment_method.id).customer }
|
362
|
+
.from(customer.id).to(nil)
|
363
|
+
end
|
155
364
|
end
|
156
365
|
end
|
157
366
|
|
158
367
|
# post /v1/payment_methods/:id
|
159
368
|
describe 'Update a PaymentMethod', live: true do
|
160
369
|
let(:customer) { Stripe::Customer.create }
|
161
|
-
|
162
|
-
|
370
|
+
|
371
|
+
context 'with credit card' do
|
372
|
+
let(:payment_method) do
|
373
|
+
Stripe::PaymentMethod.create(type: 'card', card: card_details)
|
374
|
+
end
|
375
|
+
|
376
|
+
it 'updates the card for the payment method' do
|
377
|
+
Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id)
|
378
|
+
|
379
|
+
original_card_exp_month = payment_method.card.exp_month
|
380
|
+
new_card_exp_month = 12
|
381
|
+
|
382
|
+
expect do
|
383
|
+
Stripe::PaymentMethod.update(payment_method.id, card: { exp_month: new_card_exp_month })
|
384
|
+
end.to change { Stripe::PaymentMethod.retrieve(payment_method.id).card.exp_month }
|
385
|
+
.from(original_card_exp_month).to(new_card_exp_month)
|
386
|
+
end
|
387
|
+
|
388
|
+
context 'without a customer' do
|
389
|
+
it 'raises invalid requestion exception' do
|
390
|
+
expect do
|
391
|
+
Stripe::PaymentMethod.update(payment_method.id, card: { exp_month: 12 })
|
392
|
+
end.to raise_error(Stripe::InvalidRequestError)
|
393
|
+
end
|
394
|
+
end
|
163
395
|
end
|
164
396
|
|
165
|
-
|
166
|
-
|
397
|
+
context 'with ideal' do
|
398
|
+
let(:payment_method) do
|
399
|
+
Stripe::PaymentMethod.create(type: 'ideal', ideal: ideal_details)
|
400
|
+
end
|
401
|
+
|
402
|
+
it 'updates the ideal for the payment method' do
|
403
|
+
Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id)
|
167
404
|
|
168
|
-
|
169
|
-
|
405
|
+
original_ideal_bank = payment_method.ideal.bank
|
406
|
+
new_ideal_bank = 12
|
170
407
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
408
|
+
expect do
|
409
|
+
Stripe::PaymentMethod.update(payment_method.id, ideal: { bank: new_ideal_bank })
|
410
|
+
end.to change { Stripe::PaymentMethod.retrieve(payment_method.id).ideal.bank }
|
411
|
+
.from(original_ideal_bank).to(new_ideal_bank)
|
412
|
+
end
|
413
|
+
|
414
|
+
context 'without a customer' do
|
415
|
+
it 'raises invalid requestion exception' do
|
416
|
+
expect do
|
417
|
+
Stripe::PaymentMethod.update(payment_method.id, ideal: { bank: 12 })
|
418
|
+
end.to raise_error(Stripe::InvalidRequestError)
|
419
|
+
end
|
420
|
+
end
|
175
421
|
end
|
176
422
|
|
177
|
-
context '
|
178
|
-
|
423
|
+
context 'with sepa debit' do
|
424
|
+
let(:payment_method) do
|
425
|
+
Stripe::PaymentMethod.create(type: 'sepa_debit', sepa_debit: sepa_debit_details)
|
426
|
+
end
|
427
|
+
|
428
|
+
it 'updates the sepa_debit for the payment method' do
|
429
|
+
Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id)
|
430
|
+
|
431
|
+
original_iban = payment_method.sepa_debit.iban
|
432
|
+
new_iban = 'DE62370400440532013001'
|
433
|
+
|
179
434
|
expect do
|
180
|
-
Stripe::PaymentMethod.update(payment_method.id,
|
181
|
-
end.to
|
435
|
+
Stripe::PaymentMethod.update(payment_method.id, sepa_debit: { iban: new_iban })
|
436
|
+
end.to change { Stripe::PaymentMethod.retrieve(payment_method.id).sepa_debit.iban }
|
437
|
+
.from(original_iban).to(new_iban)
|
438
|
+
end
|
439
|
+
|
440
|
+
context 'without a customer' do
|
441
|
+
it 'raises invalid requestion exception' do
|
442
|
+
expect do
|
443
|
+
Stripe::PaymentMethod.update(payment_method.id, sepa_debit: { iban: 'DE62370400440532013001' })
|
444
|
+
end.to raise_error(Stripe::InvalidRequestError)
|
445
|
+
end
|
182
446
|
end
|
183
447
|
end
|
184
448
|
end
|