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.
Files changed (49) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +2 -5
  3. data/CHANGELOG.md +28 -15
  4. data/Gemfile +1 -0
  5. data/lib/stripe_mock.rb +4 -0
  6. data/lib/stripe_mock/api/client.rb +1 -1
  7. data/lib/stripe_mock/api/instance.rb +1 -1
  8. data/lib/stripe_mock/api/webhooks.rb +2 -0
  9. data/lib/stripe_mock/client.rb +2 -1
  10. data/lib/stripe_mock/data.rb +127 -25
  11. data/lib/stripe_mock/data/list.rb +31 -6
  12. data/lib/stripe_mock/instance.rb +7 -2
  13. data/lib/stripe_mock/request_handlers/account_links.rb +15 -0
  14. data/lib/stripe_mock/request_handlers/charges.rb +6 -4
  15. data/lib/stripe_mock/request_handlers/checkout_session.rb +16 -0
  16. data/lib/stripe_mock/request_handlers/customers.rb +22 -13
  17. data/lib/stripe_mock/request_handlers/ephemeral_key.rb +1 -1
  18. data/lib/stripe_mock/request_handlers/express_login_links.rb +15 -0
  19. data/lib/stripe_mock/request_handlers/helpers/subscription_helpers.rb +12 -7
  20. data/lib/stripe_mock/request_handlers/invoices.rb +4 -3
  21. data/lib/stripe_mock/request_handlers/payment_methods.rb +8 -5
  22. data/lib/stripe_mock/request_handlers/prices.rb +44 -0
  23. data/lib/stripe_mock/request_handlers/sources.rb +12 -6
  24. data/lib/stripe_mock/request_handlers/subscriptions.rb +29 -19
  25. data/lib/stripe_mock/request_handlers/tokens.rb +6 -4
  26. data/lib/stripe_mock/request_handlers/validators/param_validators.rb +32 -0
  27. data/lib/stripe_mock/test_strategies/base.rb +26 -0
  28. data/lib/stripe_mock/version.rb +1 -1
  29. data/lib/stripe_mock/webhook_fixtures/balance.available.json +6 -0
  30. data/lib/stripe_mock/webhook_fixtures/payment_intent.payment_failed.json +186 -0
  31. data/lib/stripe_mock/webhook_fixtures/payment_intent.succeeded.json +164 -0
  32. data/spec/instance_spec.rb +4 -6
  33. data/spec/list_spec.rb +23 -0
  34. data/spec/server_spec.rb +4 -2
  35. data/spec/shared_stripe_examples/account_link_examples.rb +16 -0
  36. data/spec/shared_stripe_examples/balance_examples.rb +6 -0
  37. data/spec/shared_stripe_examples/card_token_examples.rb +17 -21
  38. data/spec/shared_stripe_examples/checkout_examples.rb +20 -1
  39. data/spec/shared_stripe_examples/customer_examples.rb +11 -13
  40. data/spec/shared_stripe_examples/express_login_link_examples.rb +12 -0
  41. data/spec/shared_stripe_examples/invoice_examples.rb +8 -8
  42. data/spec/shared_stripe_examples/payment_method_examples.rb +332 -68
  43. data/spec/shared_stripe_examples/price_examples.rb +183 -0
  44. data/spec/shared_stripe_examples/subscription_examples.rb +115 -8
  45. data/spec/spec_helper.rb +4 -0
  46. data/spec/stripe_mock_spec.rb +2 -2
  47. data/spec/support/stripe_examples.rb +5 -1
  48. data/stripe-ruby-mock.gemspec +6 -1
  49. 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
- it 'creates a payment method with a valid id', live: false do
44
- expect(payment_method.id).to match(/^test_pm/)
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
- it 'creates a payment method with a billing address' do
48
- expect(payment_method.billing_details.address.city).to eq('North New Portland')
49
- expect(payment_method.billing_details.address.country).to eq('US')
50
- expect(payment_method.billing_details.address.line1).to eq('2631 Bloomfield Way')
51
- expect(payment_method.billing_details.address.line2).to eq('Apartment 5B')
52
- expect(payment_method.billing_details.address.postal_code).to eq('05555')
53
- expect(payment_method.billing_details.address.state).to eq('ME')
54
- expect(payment_method.billing_details.email).to eq('john@example.com')
55
- expect(payment_method.billing_details.name).to eq('John Doe')
56
- expect(payment_method.billing_details.phone).to eq('555-555-5555')
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
- it 'creates a payment method with metadata' do
60
- expect(payment_method.metadata.order_id).to eq('123456789')
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
- it 'retrieves a given payment method' do
75
- customer = Stripe::Customer.create
76
- original = Stripe::PaymentMethod.create(type: 'card', card: card_details)
77
- Stripe::PaymentMethod.attach(original.id, customer: customer.id)
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
- payment_method = Stripe::PaymentMethod.retrieve(original.id)
141
+ payment_method = Stripe::PaymentMethod.retrieve(original.id)
80
142
 
81
- expect(payment_method.id).to eq(original.id)
82
- expect(payment_method.type).to eq(original.type)
83
- expect(payment_method.customer).to eq(customer.id)
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(:customer) { Stripe::Customer.create }
188
+ let(:customer1) { Stripe::Customer.create }
99
189
  let(:customer2) { Stripe::Customer.create }
100
- before do
101
- 3.times do
102
- payment_method = Stripe::PaymentMethod.create(type: 'card', card: card_details)
103
- Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id)
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
- it 'lists all payment methods' do
108
- expect(Stripe::PaymentMethod.list(customer: customer.id, type: 'card').count).to eq(3)
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 'when passing a limit' do
112
- it 'only lists the limited number of payment methods' do
113
- expect(Stripe::PaymentMethod.list(customer: customer.id, type: 'card', limit: 2).count).to eq(2)
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 'when listing the payment methods of another customer' do
118
- it 'does not list any payment methods' do
119
- expect(Stripe::PaymentMethod.list(customer: customer2.id, type: 'card').count).to eq(0)
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
- it 'attaches a payment method to a customer' do
130
- expect { Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id) }
131
- .to change { Stripe::PaymentMethod.retrieve(payment_method.id).customer }
132
- .from(nil).to(customer.id)
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 "when the customer doesn't exist" do
136
- it 'raises invalid requestion exception' do
137
- expect { Stripe::PaymentMethod.attach(payment_method.id, customer: 'cus_invalid') }
138
- .to raise_error(Stripe::InvalidRequestError)
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
- let(:payment_method) do
147
- payment_method = Stripe::PaymentMethod.create(type: 'card', card: card_details)
148
- Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id)
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
- it 'detaches a PaymentMethod from a customer' do
152
- expect { Stripe::PaymentMethod.detach(payment_method.id) }
153
- .to change { Stripe::PaymentMethod.retrieve(payment_method.id).customer }
154
- .from(customer.id).to(nil)
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
- let(:payment_method) do
162
- Stripe::PaymentMethod.create(type: 'card', card: card_details)
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
- it 'updates the card for the payment method' do
166
- Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id)
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
- original_card_exp_month = payment_method.card.exp_month
169
- new_card_exp_month = 12
405
+ original_ideal_bank = payment_method.ideal.bank
406
+ new_ideal_bank = 12
170
407
 
171
- expect do
172
- Stripe::PaymentMethod.update(payment_method.id, card: { exp_month: new_card_exp_month })
173
- end.to change { Stripe::PaymentMethod.retrieve(payment_method.id).card.exp_month }
174
- .from(original_card_exp_month).to(new_card_exp_month)
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 'without a customer' do
178
- it 'raises invalid requestion exception' do
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, card: { exp_month: 12 })
181
- end.to raise_error(Stripe::InvalidRequestError)
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