stripe-ruby-mock 2.5.8 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +6 -6
- data/README.md +8 -8
- data/lib/stripe_mock.rb +3 -0
- data/lib/stripe_mock/api/errors.rb +31 -28
- data/lib/stripe_mock/api/webhooks.rb +3 -0
- data/lib/stripe_mock/data.rb +140 -13
- data/lib/stripe_mock/instance.rb +10 -3
- data/lib/stripe_mock/request_handlers/balance_transactions.rb +2 -2
- data/lib/stripe_mock/request_handlers/helpers/subscription_helpers.rb +1 -1
- data/lib/stripe_mock/request_handlers/helpers/token_helpers.rb +1 -1
- data/lib/stripe_mock/request_handlers/invoices.rb +6 -1
- data/lib/stripe_mock/request_handlers/payment_intents.rb +175 -0
- data/lib/stripe_mock/request_handlers/payment_methods.rb +138 -0
- data/lib/stripe_mock/request_handlers/products.rb +1 -0
- data/lib/stripe_mock/request_handlers/setup_intents.rb +93 -0
- data/lib/stripe_mock/request_handlers/subscriptions.rb +17 -4
- data/lib/stripe_mock/request_handlers/validators/param_validators.rb +95 -9
- data/lib/stripe_mock/test_strategies/base.rb +42 -8
- data/lib/stripe_mock/test_strategies/live.rb +23 -12
- data/lib/stripe_mock/test_strategies/mock.rb +6 -2
- data/lib/stripe_mock/version.rb +1 -1
- data/lib/stripe_mock/webhook_fixtures/charge.failed.json +166 -38
- data/lib/stripe_mock/webhook_fixtures/customer.created.json +1 -0
- data/lib/stripe_mock/webhook_fixtures/customer.updated.json +1 -0
- data/lib/stripe_mock/webhook_fixtures/product.created.json +34 -0
- data/lib/stripe_mock/webhook_fixtures/product.deleted.json +34 -0
- data/lib/stripe_mock/webhook_fixtures/product.updated.json +38 -0
- data/spec/instance_spec.rb +6 -6
- data/spec/server_spec.rb +2 -1
- data/spec/shared_stripe_examples/account_examples.rb +1 -1
- data/spec/shared_stripe_examples/balance_transaction_examples.rb +3 -3
- data/spec/shared_stripe_examples/bank_examples.rb +3 -3
- data/spec/shared_stripe_examples/card_examples.rb +4 -4
- data/spec/shared_stripe_examples/charge_examples.rb +9 -22
- data/spec/shared_stripe_examples/coupon_examples.rb +1 -1
- data/spec/shared_stripe_examples/customer_examples.rb +44 -30
- data/spec/shared_stripe_examples/dispute_examples.rb +2 -2
- data/spec/shared_stripe_examples/error_mock_examples.rb +8 -7
- data/spec/shared_stripe_examples/external_account_examples.rb +3 -3
- data/spec/shared_stripe_examples/invoice_examples.rb +41 -39
- data/spec/shared_stripe_examples/invoice_item_examples.rb +1 -1
- data/spec/shared_stripe_examples/payment_intent_examples.rb +137 -0
- data/spec/shared_stripe_examples/payment_method_examples.rb +185 -0
- data/spec/shared_stripe_examples/payout_examples.rb +2 -2
- data/spec/shared_stripe_examples/plan_examples.rb +135 -92
- data/spec/shared_stripe_examples/product_examples.rb +155 -0
- data/spec/shared_stripe_examples/refund_examples.rb +25 -21
- data/spec/shared_stripe_examples/setup_intent_examples.rb +68 -0
- data/spec/shared_stripe_examples/subscription_examples.rb +281 -310
- data/spec/shared_stripe_examples/subscription_items_examples.rb +3 -2
- data/spec/shared_stripe_examples/transfer_examples.rb +6 -6
- data/spec/shared_stripe_examples/webhook_event_examples.rb +11 -11
- data/spec/spec_helper.rb +3 -4
- data/spec/stripe_mock_spec.rb +2 -2
- data/spec/support/shared_contexts/stripe_validator_spec.rb +8 -0
- data/spec/support/stripe_examples.rb +3 -0
- data/stripe-ruby-mock.gemspec +2 -2
- metadata +47 -27
- data/spec/shared_stripe_examples/product_example.rb +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83e0a13431e08fd71904300dbc7717e48deead7f
|
4
|
+
data.tar.gz: 481c5c3a5d1643107ddf35fbaf14e0f8bdd36f72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46c6533cfb41b36eaa7be7ac93a54e2d7f3f5c74eb2e48c1473c21f88c49b65011153719c2b9f62cf5f1157a6e7938ea3a84ff133c363445a5212e9dc6a59682
|
7
|
+
data.tar.gz: 1d09905741e5fa10537abfedb94db03b5c9475db967476b5c8e87c460ae46821e07d89455f008ba7c902b61adcf751b16ed812c9fd5bf949c5f4de3336b32491
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -3,13 +3,12 @@ group: deprecated-2017Q2
|
|
3
3
|
sudo: required
|
4
4
|
language: ruby
|
5
5
|
rvm:
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.3.4
|
6
|
+
- 2.4.6
|
7
|
+
- 2.5.5
|
8
|
+
- 2.6.3
|
10
9
|
before_install:
|
11
10
|
- rvm 2.1.10 do gem install mime-types -v 2.6.2
|
12
|
-
- gem install bundler
|
11
|
+
- gem install bundler -v '< 2'
|
13
12
|
before_script:
|
14
13
|
- "sudo touch /var/log/stripe-mock-server.log"
|
15
14
|
- "sudo chown travis /var/log/stripe-mock-server.log"
|
@@ -17,7 +16,7 @@ script: "bundle exec rspec && bundle exec rspec -t live"
|
|
17
16
|
|
18
17
|
env:
|
19
18
|
global:
|
20
|
-
- IS_TRAVIS=true STRIPE_TEST_SECRET_KEY_A=
|
19
|
+
- IS_TRAVIS=true STRIPE_TEST_SECRET_KEY_A=sk_test_BsztzqQjzd7lqkgo1LjEG5DF00KzH7tWKF STRIPE_TEST_SECRET_KEY_B=sk_test_rKCEu0x8jzg6cKPqoey8kUPQ00usQO3KYE STRIPE_TEST_SECRET_KEY_C=sk_test_qeaB7R6Ywp8sC9pzd1ZIABH700YLC7nhmZ
|
21
20
|
|
22
21
|
notifications:
|
23
22
|
webhooks:
|
@@ -26,3 +25,4 @@ notifications:
|
|
26
25
|
on_success: change # options: [always|never|change] default: always
|
27
26
|
on_failure: always # options: [always|never|change] default: always
|
28
27
|
on_start: false # default: false
|
28
|
+
|
data/README.md
CHANGED
@@ -6,13 +6,13 @@
|
|
6
6
|
|
7
7
|
# REQUEST: Looking for More Core Contributors
|
8
8
|
|
9
|
-
This gem has unexpectedly grown in popularity and I've gotten pretty busy, so I'm currently looking for more core contributors to help me out. If you're interested, there is only one requirement: submit a significant enough pull request and have it merged into master (many of you have already done this). Afterwards, ping
|
9
|
+
This gem has unexpectedly grown in popularity and I've gotten pretty busy, so I'm currently looking for more core contributors to help me out. If you're interested, there is only one requirement: submit a significant enough pull request and have it merged into master (many of you have already done this). Afterwards, ping [@gilbert](https://gitter.im/gilbert) in [chat](https://gitter.im/rebelidealist/stripe-ruby-mock) and I will add you as a collaborator.
|
10
10
|
|
11
11
|
## Install
|
12
12
|
|
13
13
|
In your gemfile:
|
14
14
|
|
15
|
-
gem 'stripe-ruby-mock', '~>
|
15
|
+
gem 'stripe-ruby-mock', '~> 3.0.0', :require => 'stripe_mock'
|
16
16
|
|
17
17
|
## Features
|
18
18
|
|
@@ -23,12 +23,12 @@ In your gemfile:
|
|
23
23
|
|
24
24
|
### Requirements
|
25
25
|
|
26
|
-
* ruby >= 2.
|
27
|
-
* stripe >=
|
26
|
+
* ruby >= 2.4.0
|
27
|
+
* stripe >= 5.0.0
|
28
28
|
|
29
29
|
### Specifications
|
30
30
|
|
31
|
-
**STRIPE API TARGET VERSION:**
|
31
|
+
**STRIPE API TARGET VERSION:** 2019-08-20 (master) - we try, but some features are not implemented yet.
|
32
32
|
|
33
33
|
Older API version branches:
|
34
34
|
|
@@ -141,7 +141,7 @@ end
|
|
141
141
|
```
|
142
142
|
|
143
143
|
## Mocking Card Errors
|
144
|
-
|
144
|
+
** Ensure you start StripeMock in a before filter `StripeMock.start`
|
145
145
|
Tired of manually inputting fake credit card numbers to test against errors? Tire no more!
|
146
146
|
|
147
147
|
```ruby
|
@@ -176,7 +176,7 @@ StripeMock.prepare_card_error(:incorrect_zip)
|
|
176
176
|
You can see the details of each error in [lib/stripe_mock/api/errors.rb](lib/stripe_mock/api/errors.rb)
|
177
177
|
|
178
178
|
### Specifying Card Errors
|
179
|
-
|
179
|
+
** Ensure you start StripeMock in a before filter `StripeMock.start`
|
180
180
|
By default, `prepare_card_error` only triggers for `:new_charge`, the event that happens when you run `Charge.create`. More explicitly, this is what happens by default:
|
181
181
|
|
182
182
|
```ruby
|
@@ -195,7 +195,7 @@ customer.cards.create
|
|
195
195
|
`:new_charge` and `:create_card` are names of methods in the [StripeMock request handlers](lib/stripe_mock/request_handlers). You can also set `StripeMock.toggle_debug(true)` to see the event name for each Stripe request made in your tests.
|
196
196
|
|
197
197
|
### Custom Errors
|
198
|
-
|
198
|
+
** Ensure you start StripeMock in a before filter `StripeMock.start`
|
199
199
|
To raise an error on a specific type of request, take a look at the [request handlers folder](lib/stripe_mock/request_handlers/) and pass a method name to `StripeMock.prepare_error`.
|
200
200
|
|
201
201
|
If you wanted to raise an error for creating a new customer, for instance, you would do the following:
|
data/lib/stripe_mock.rb
CHANGED
@@ -65,6 +65,9 @@ require 'stripe_mock/request_handlers/plans.rb'
|
|
65
65
|
require 'stripe_mock/request_handlers/recipients.rb'
|
66
66
|
require 'stripe_mock/request_handlers/refunds.rb'
|
67
67
|
require 'stripe_mock/request_handlers/transfers.rb'
|
68
|
+
require 'stripe_mock/request_handlers/payment_intents.rb'
|
69
|
+
require 'stripe_mock/request_handlers/payment_methods.rb'
|
70
|
+
require 'stripe_mock/request_handlers/setup_intents.rb'
|
68
71
|
require 'stripe_mock/request_handlers/payouts.rb'
|
69
72
|
require 'stripe_mock/request_handlers/subscriptions.rb'
|
70
73
|
require 'stripe_mock/request_handlers/subscription_items.rb'
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module StripeMock
|
2
|
-
|
3
2
|
def self.prepare_error(stripe_error, *handler_names)
|
4
3
|
handler_names.push(:all) if handler_names.count == 0
|
5
4
|
|
@@ -15,28 +14,30 @@ module StripeMock
|
|
15
14
|
def self.prepare_card_error(code, *handler_names)
|
16
15
|
handler_names.push(:new_charge) if handler_names.count == 0
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
error = CardErrors.build_error_for(code)
|
18
|
+
if error.nil?
|
19
|
+
raise StripeMockError, "Unrecognized stripe card error code: #{code}"
|
20
|
+
end
|
21
|
+
|
22
|
+
prepare_error error, *handler_names
|
21
23
|
end
|
22
24
|
|
23
25
|
module CardErrors
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
}
|
26
|
+
def self.build_error_for(code)
|
27
|
+
case code
|
28
|
+
when :incorrect_number then build_card_error('The card number is incorrect', 'number', code: 'incorrect_number', http_status: 402)
|
29
|
+
when :invalid_number then build_card_error('The card number is not a valid credit card number', 'number', code: 'invalid_number', http_status: 402)
|
30
|
+
when :invalid_expiry_month then build_card_error("The card's expiration month is invalid", 'exp_month', code: 'invalid_expiry_month', http_status: 402)
|
31
|
+
when :invalid_expiry_year then build_card_error("The card's expiration year is invalid", 'exp_year', code: 'invalid_expiry_year', http_status: 402)
|
32
|
+
when :invalid_cvc then build_card_error("The card's security code is invalid", 'cvc', code: 'invalid_cvc', http_status: 402)
|
33
|
+
when :expired_card then build_card_error('The card has expired', 'exp_month', code: 'expired_card', http_status: 402)
|
34
|
+
when :incorrect_cvc then build_card_error("The card's security code is incorrect", 'cvc', code: 'incorrect_cvc', http_status: 402)
|
35
|
+
when :card_declined then build_card_error('The card was declined', nil, code: 'card_declined', http_status: 402)
|
36
|
+
when :missing then build_card_error('There is no card on a customer that is being charged.', nil, code: 'missing', http_status: 402)
|
37
|
+
when :processing_error then build_card_error('An error occurred while processing the card', nil, code: 'processing_error', http_status: 402)
|
38
|
+
when :card_error then build_card_error('The card number is not a valid credit card number.', 'number', code: 'invalid_number', http_status: 402)
|
39
|
+
when :incorrect_zip then build_card_error('The zip code you supplied failed validation.', 'address_zip', code: 'incorrect_zip', http_status: 402)
|
40
|
+
end
|
40
41
|
end
|
41
42
|
|
42
43
|
def self.get_decline_code(code)
|
@@ -50,16 +51,18 @@ module StripeMock
|
|
50
51
|
decline_code_map[code_key]
|
51
52
|
end
|
52
53
|
|
53
|
-
def self.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
def self.build_card_error(message, param, **kwargs)
|
55
|
+
json_hash = {
|
56
|
+
message: message,
|
57
|
+
param: param,
|
58
|
+
code: kwargs[:code],
|
59
|
+
type: 'card_error',
|
60
|
+
decline_code: get_decline_code(kwargs[:code])
|
61
|
+
}
|
59
62
|
|
60
|
-
|
63
|
+
error_keyword_args = kwargs.merge(json_body: { error: json_hash }, http_body: { error: json_hash }.to_json)
|
61
64
|
|
62
|
-
|
65
|
+
Stripe::CardError.new(message, param, **error_keyword_args)
|
63
66
|
end
|
64
67
|
end
|
65
68
|
end
|
data/lib/stripe_mock/data.rb
CHANGED
@@ -128,11 +128,17 @@ module StripeMock
|
|
128
128
|
created: 1372126710,
|
129
129
|
id: cus_id,
|
130
130
|
name: nil,
|
131
|
+
preferred_locales: [],
|
131
132
|
livemode: false,
|
132
133
|
delinquent: false,
|
133
134
|
discount: nil,
|
134
135
|
account_balance: 0,
|
135
136
|
currency: currency,
|
137
|
+
invoice_settings: {
|
138
|
+
default_payment_method: nil,
|
139
|
+
custom_fields: nil,
|
140
|
+
footer: nil
|
141
|
+
},
|
136
142
|
sources: {
|
137
143
|
object: "list",
|
138
144
|
total_count: sources.size,
|
@@ -199,7 +205,7 @@ module StripeMock
|
|
199
205
|
data: []
|
200
206
|
},
|
201
207
|
transfer: nil,
|
202
|
-
balance_transaction: "txn_2dyYXXP90MN26R",
|
208
|
+
balance_transaction: params[:balance_transaction] || "txn_2dyYXXP90MN26R",
|
203
209
|
failure_message: nil,
|
204
210
|
failure_code: nil,
|
205
211
|
amount_refunded: 0,
|
@@ -342,7 +348,8 @@ module StripeMock
|
|
342
348
|
quantity: 1,
|
343
349
|
tax_percent: nil,
|
344
350
|
discount: nil,
|
345
|
-
metadata: {}
|
351
|
+
metadata: {},
|
352
|
+
default_tax_rates: nil
|
346
353
|
}, params)
|
347
354
|
end
|
348
355
|
|
@@ -358,6 +365,7 @@ module StripeMock
|
|
358
365
|
created: 1349738950,
|
359
366
|
period_end: 1349738950,
|
360
367
|
period_start: 1349738950,
|
368
|
+
due_date: nil,
|
361
369
|
lines: {
|
362
370
|
object: "list",
|
363
371
|
total_count: lines.count,
|
@@ -385,7 +393,7 @@ module StripeMock
|
|
385
393
|
amount_paid: 0,
|
386
394
|
currency: currency,
|
387
395
|
starting_balance: 0,
|
388
|
-
ending_balance:
|
396
|
+
ending_balance: 0,
|
389
397
|
next_payment_attempt: 1349825350,
|
390
398
|
charge: nil,
|
391
399
|
discount: nil,
|
@@ -399,6 +407,7 @@ module StripeMock
|
|
399
407
|
end
|
400
408
|
due = invoice[:total] + invoice[:starting_balance]
|
401
409
|
invoice[:amount_due] = due < 0 ? 0 : due
|
410
|
+
invoice[:ending_balance] = invoice[:starting_balance] + invoice[:total] if invoice[:amount_due] == 0
|
402
411
|
invoice
|
403
412
|
end
|
404
413
|
|
@@ -521,33 +530,49 @@ module StripeMock
|
|
521
530
|
def self.mock_plan(params={})
|
522
531
|
currency = params[:currency] || StripeMock.default_currency
|
523
532
|
{
|
524
|
-
id: "
|
533
|
+
id: "mock_plan_123",
|
525
534
|
object: "plan",
|
535
|
+
active: true,
|
536
|
+
aggregate_usage: nil,
|
526
537
|
amount: 2300,
|
538
|
+
billing_scheme: "per_unit",
|
527
539
|
created: 1466698898,
|
528
540
|
currency: currency,
|
529
541
|
interval: "month",
|
530
542
|
interval_count: 1,
|
531
543
|
livemode: false,
|
532
544
|
metadata: {},
|
533
|
-
|
534
|
-
|
535
|
-
|
545
|
+
nickname: "My Mock Plan",
|
546
|
+
product: "mock_prod_NONEXIST", # override this with your own existing product id
|
547
|
+
tiers: nil,
|
548
|
+
tiers_mode: nil,
|
549
|
+
transform_usage: nil,
|
550
|
+
trial_period_days: nil,
|
551
|
+
usage_type: "licensed"
|
536
552
|
}.merge(params)
|
537
553
|
end
|
538
554
|
|
539
|
-
def self.mock_product(params
|
555
|
+
def self.mock_product(params={})
|
540
556
|
{
|
541
|
-
id: "
|
557
|
+
id: "mock_prod_abc123",
|
542
558
|
object: "product",
|
543
559
|
active: true,
|
544
|
-
|
560
|
+
attributes:[],
|
561
|
+
caption: nil,
|
562
|
+
created: 1466698000,
|
563
|
+
deactivate_on: [],
|
564
|
+
description: nil,
|
565
|
+
images: [],
|
545
566
|
livemode: false,
|
546
567
|
metadata: {},
|
547
|
-
name: "
|
548
|
-
|
568
|
+
name: "The Mock Product",
|
569
|
+
package_dimensions: nil,
|
570
|
+
shippable: nil,
|
571
|
+
statement_descriptor: nil,
|
549
572
|
type: "service",
|
550
|
-
|
573
|
+
unit_label: "my_unit",
|
574
|
+
updated: 1537939442,
|
575
|
+
url: nil
|
551
576
|
}.merge(params)
|
552
577
|
end
|
553
578
|
|
@@ -1088,5 +1113,107 @@ module StripeMock
|
|
1088
1113
|
secret: "ek_test_default"
|
1089
1114
|
}
|
1090
1115
|
end
|
1116
|
+
|
1117
|
+
def self.mock_payment_intent(params = {})
|
1118
|
+
payment_intent_id = params[:id] || "pi_1EwXFB2eZvKYlo2CggNnFBo8"
|
1119
|
+
amount = params[:amount] || 49900
|
1120
|
+
currency = params[:currency] || StripeMock.default_currency
|
1121
|
+
{
|
1122
|
+
id: payment_intent_id,
|
1123
|
+
object: "payment_intent",
|
1124
|
+
amount: amount,
|
1125
|
+
amount_capturable: 0,
|
1126
|
+
amount_received: 0,
|
1127
|
+
application: nil,
|
1128
|
+
application_fee_amount: nil,
|
1129
|
+
canceled_at: nil,
|
1130
|
+
cancellation_reason: nil,
|
1131
|
+
capture_method: "automatic",
|
1132
|
+
charges: {
|
1133
|
+
object: "list",
|
1134
|
+
data: [],
|
1135
|
+
has_more: false,
|
1136
|
+
total_count: 1,
|
1137
|
+
url: "/v1/charges?payment_intent=pi_1EwXFB2eZvKYlo2CggNnFBo8"
|
1138
|
+
},
|
1139
|
+
client_secret: "pi_1EwXFB2eZvKYlo2CggNnFBo8_secret_vOMkpqZu8ca7hxhfiO80tpT3v",
|
1140
|
+
confirmation_method: "manual",
|
1141
|
+
created: 1563208901,
|
1142
|
+
currency: currency,
|
1143
|
+
customer: nil,
|
1144
|
+
description: nil,
|
1145
|
+
invoice: nil,
|
1146
|
+
last_payment_error: nil,
|
1147
|
+
livemode: false,
|
1148
|
+
metadata: {},
|
1149
|
+
next_action: { type: "use_stripe_sdk" },
|
1150
|
+
on_behalf_of: nil,
|
1151
|
+
payment_method: nil,
|
1152
|
+
payment_method_types: [
|
1153
|
+
"card"
|
1154
|
+
],
|
1155
|
+
receipt_email: nil,
|
1156
|
+
review: nil,
|
1157
|
+
setup_future_usage: nil,
|
1158
|
+
shipping: nil,
|
1159
|
+
source: nil,
|
1160
|
+
statement_descriptor: nil,
|
1161
|
+
status: "requires_action",
|
1162
|
+
transfer_data: nil,
|
1163
|
+
transfer_group: nil
|
1164
|
+
}.merge(params)
|
1165
|
+
end
|
1166
|
+
|
1167
|
+
def self.mock_payment_method(params = {})
|
1168
|
+
payment_method_id = params[:id] || "pm_1ExEuFL2DI6wht39WNJgbybl"
|
1169
|
+
{
|
1170
|
+
id: payment_method_id,
|
1171
|
+
object: "payment_method",
|
1172
|
+
type: "card",
|
1173
|
+
billing_details: {},
|
1174
|
+
card: {
|
1175
|
+
brand: "visa",
|
1176
|
+
checks: { address_line1_check: nil, address_postal_code_check: nil, cvc_check: "pass" },
|
1177
|
+
country: "FR",
|
1178
|
+
exp_month: 2,
|
1179
|
+
exp_year: 2022,
|
1180
|
+
fingerprint: "Hr3Ly5z5IYxsokWA",
|
1181
|
+
funding: "credit",
|
1182
|
+
last4: "3155",
|
1183
|
+
three_d_secure_usage: { supported: true }
|
1184
|
+
},
|
1185
|
+
customer: params[:customer] || nil,
|
1186
|
+
metadata: {
|
1187
|
+
"order_id": "123456789"
|
1188
|
+
}
|
1189
|
+
|
1190
|
+
}.merge(params)
|
1191
|
+
end
|
1192
|
+
|
1193
|
+
def self.mock_setup_intent(params = {})
|
1194
|
+
setup_intent_id = params[:id] || "seti_1F96eK2aLAadsDqo0AVIyPmC"
|
1195
|
+
{
|
1196
|
+
:id => setup_intent_id,
|
1197
|
+
:object => "setup_intent",
|
1198
|
+
:application => nil,
|
1199
|
+
:cancellation_reason => nil,
|
1200
|
+
:client_secret => "seti_1F96eK2aLAadsDqo0AVIyPmC_secret_FePTYgOoPFxDOUL53fFMSoTAyiXsWAV",
|
1201
|
+
:created => 1566204936,
|
1202
|
+
:customer => nil,
|
1203
|
+
:description => nil,
|
1204
|
+
:last_setup_error => nil,
|
1205
|
+
:livemode => false,
|
1206
|
+
:metadata => {},
|
1207
|
+
:next_action => nil,
|
1208
|
+
:on_behalf_of => nil,
|
1209
|
+
:payment_method => nil,
|
1210
|
+
:payment_method_options => {
|
1211
|
+
"card": {"request_three_d_secure":"automatic"}
|
1212
|
+
},
|
1213
|
+
:payment_method_types => ["card"],
|
1214
|
+
:status => "requires_payment_method",
|
1215
|
+
:usage => "off_session"
|
1216
|
+
}.merge(params)
|
1217
|
+
end
|
1091
1218
|
end
|
1092
1219
|
end
|
data/lib/stripe_mock/instance.rb
CHANGED
@@ -20,6 +20,9 @@ module StripeMock
|
|
20
20
|
@@handlers.find {|h| method_url =~ h[:route] }
|
21
21
|
end
|
22
22
|
|
23
|
+
include StripeMock::RequestHandlers::PaymentIntents
|
24
|
+
include StripeMock::RequestHandlers::PaymentMethods
|
25
|
+
include StripeMock::RequestHandlers::SetupIntents
|
23
26
|
include StripeMock::RequestHandlers::ExternalAccounts
|
24
27
|
include StripeMock::RequestHandlers::Accounts
|
25
28
|
include StripeMock::RequestHandlers::Balance
|
@@ -48,9 +51,9 @@ module StripeMock
|
|
48
51
|
include StripeMock::RequestHandlers::TaxRates
|
49
52
|
|
50
53
|
attr_reader :accounts, :balance, :balance_transactions, :bank_tokens, :charges, :coupons, :customers,
|
51
|
-
:disputes, :events, :invoices, :invoice_items, :orders, :
|
52
|
-
:refunds, :transfers, :payouts, :subscriptions, :country_spec,
|
53
|
-
:products, :tax_rates
|
54
|
+
:disputes, :events, :invoices, :invoice_items, :orders, :payment_intents, :payment_methods,
|
55
|
+
:setup_intents, :plans, :recipients, :refunds, :transfers, :payouts, :subscriptions, :country_spec,
|
56
|
+
:subscriptions_items, :products, :tax_rates
|
54
57
|
|
55
58
|
attr_accessor :error_queue, :debug, :conversion_rate, :account_balance
|
56
59
|
|
@@ -62,12 +65,16 @@ module StripeMock
|
|
62
65
|
@card_tokens = {}
|
63
66
|
@customers = {}
|
64
67
|
@charges = {}
|
68
|
+
@payment_intents = {}
|
69
|
+
@payment_methods = {}
|
70
|
+
@setup_intents = {}
|
65
71
|
@coupons = {}
|
66
72
|
@disputes = Data.mock_disputes(['dp_05RsQX2eZvKYlo2C0FRTGSSA','dp_15RsQX2eZvKYlo2C0ERTYUIA', 'dp_25RsQX2eZvKYlo2C0ZXCVBNM', 'dp_35RsQX2eZvKYlo2C0QAZXSWE', 'dp_45RsQX2eZvKYlo2C0EDCVFRT', 'dp_55RsQX2eZvKYlo2C0OIKLJUY', 'dp_65RsQX2eZvKYlo2C0ASDFGHJ', 'dp_75RsQX2eZvKYlo2C0EDCXSWQ', 'dp_85RsQX2eZvKYlo2C0UJMCDET', 'dp_95RsQX2eZvKYlo2C0EDFRYUI'])
|
67
73
|
@events = {}
|
68
74
|
@invoices = {}
|
69
75
|
@invoice_items = {}
|
70
76
|
@orders = {}
|
77
|
+
@payment_methods = {}
|
71
78
|
@plans = {}
|
72
79
|
@products = {}
|
73
80
|
@recipients = {}
|