stripe-ruby-mock 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/rspec_tests.yml +38 -0
- data/.rspec +2 -1
- data/CHANGELOG.md +62 -15
- data/Gemfile +1 -0
- data/README.md +5 -3
- 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 +66 -25
- data/lib/stripe_mock/client.rb +2 -1
- data/lib/stripe_mock/data/list.rb +31 -6
- data/lib/stripe_mock/data.rb +201 -30
- data/lib/stripe_mock/instance.rb +12 -3
- data/lib/stripe_mock/request_handlers/account_links.rb +15 -0
- data/lib/stripe_mock/request_handlers/accounts.rb +17 -6
- data/lib/stripe_mock/request_handlers/charges.rb +11 -4
- data/lib/stripe_mock/request_handlers/checkout_session.rb +179 -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/events.rb +30 -3
- data/lib/stripe_mock/request_handlers/express_login_links.rb +15 -0
- data/lib/stripe_mock/request_handlers/helpers/coupon_helpers.rb +1 -0
- data/lib/stripe_mock/request_handlers/helpers/subscription_helpers.rb +36 -12
- data/lib/stripe_mock/request_handlers/invoices.rb +10 -4
- data/lib/stripe_mock/request_handlers/payment_intents.rb +13 -2
- data/lib/stripe_mock/request_handlers/payment_methods.rb +11 -4
- data/lib/stripe_mock/request_handlers/prices.rb +62 -0
- data/lib/stripe_mock/request_handlers/promotion_codes.rb +43 -0
- data/lib/stripe_mock/request_handlers/refunds.rb +13 -2
- data/lib/stripe_mock/request_handlers/setup_intents.rb +16 -9
- data/lib/stripe_mock/request_handlers/sources.rb +12 -6
- data/lib/stripe_mock/request_handlers/subscriptions.rb +120 -21
- data/lib/stripe_mock/request_handlers/tokens.rb +6 -4
- data/lib/stripe_mock/request_handlers/transfers.rb +12 -1
- data/lib/stripe_mock/request_handlers/validators/param_validators.rb +33 -4
- data/lib/stripe_mock/server.rb +2 -2
- data/lib/stripe_mock/test_strategies/base.rb +62 -10
- data/lib/stripe_mock/version.rb +1 -1
- data/lib/stripe_mock/webhook_fixtures/account.updated.json +1 -1
- data/lib/stripe_mock/webhook_fixtures/balance.available.json +27 -15
- data/lib/stripe_mock/webhook_fixtures/charge.captured.json +143 -0
- data/lib/stripe_mock/webhook_fixtures/charge.dispute.created.json +63 -16
- data/lib/stripe_mock/webhook_fixtures/charge.failed.json +49 -120
- data/lib/stripe_mock/webhook_fixtures/charge.refund.updated.json +35 -0
- data/lib/stripe_mock/webhook_fixtures/charge.refunded.json +145 -50
- data/lib/stripe_mock/webhook_fixtures/charge.succeeded.json +114 -43
- data/lib/stripe_mock/webhook_fixtures/checkout.session.completed.json +79 -0
- data/lib/stripe_mock/webhook_fixtures/checkout.session.completed.payment_mode.json +53 -0
- data/lib/stripe_mock/webhook_fixtures/checkout.session.completed.setup_mode.json +45 -0
- data/lib/stripe_mock/webhook_fixtures/customer.created.json +37 -46
- data/lib/stripe_mock/webhook_fixtures/customer.deleted.json +36 -32
- data/lib/stripe_mock/webhook_fixtures/customer.source.created.json +31 -22
- data/lib/stripe_mock/webhook_fixtures/customer.source.updated.json +36 -25
- data/lib/stripe_mock/webhook_fixtures/customer.subscription.created.json +135 -47
- data/lib/stripe_mock/webhook_fixtures/customer.subscription.deleted.json +134 -45
- data/lib/stripe_mock/webhook_fixtures/customer.subscription.updated.json +135 -56
- data/lib/stripe_mock/webhook_fixtures/customer.updated.json +38 -47
- data/lib/stripe_mock/webhook_fixtures/invoice.created.json +176 -49
- data/lib/stripe_mock/webhook_fixtures/invoice.finalized.json +171 -0
- data/lib/stripe_mock/webhook_fixtures/invoice.paid.json +171 -0
- data/lib/stripe_mock/webhook_fixtures/invoice.payment_action_required.json +171 -0
- data/lib/stripe_mock/webhook_fixtures/invoice.payment_failed.json +149 -83
- data/lib/stripe_mock/webhook_fixtures/invoice.payment_succeeded.json +149 -90
- data/lib/stripe_mock/webhook_fixtures/invoice.upcoming.json +70 -0
- data/lib/stripe_mock/webhook_fixtures/invoice.updated.json +178 -50
- data/lib/stripe_mock/webhook_fixtures/invoiceitem.created.json +87 -13
- data/lib/stripe_mock/webhook_fixtures/invoiceitem.updated.json +88 -14
- data/lib/stripe_mock/webhook_fixtures/mandate.updated.json +34 -0
- data/lib/stripe_mock/webhook_fixtures/payment_intent.amount_capturable_updated.json +170 -0
- data/lib/stripe_mock/webhook_fixtures/payment_intent.canceled.json +73 -0
- data/lib/stripe_mock/webhook_fixtures/payment_intent.created.json +86 -0
- data/lib/stripe_mock/webhook_fixtures/payment_intent.payment_failed.json +225 -0
- data/lib/stripe_mock/webhook_fixtures/payment_intent.processing.json +162 -0
- data/lib/stripe_mock/webhook_fixtures/payment_intent.requires_action.json +191 -0
- data/lib/stripe_mock/webhook_fixtures/payment_intent.succeeded.json +196 -0
- data/lib/stripe_mock/webhook_fixtures/payment_link.created.json +47 -0
- data/lib/stripe_mock/webhook_fixtures/payment_link.updated.json +50 -0
- data/lib/stripe_mock/webhook_fixtures/payment_method.attached.json +63 -0
- data/lib/stripe_mock/webhook_fixtures/payment_method.detached.json +62 -0
- data/lib/stripe_mock/webhook_fixtures/payout.created.json +40 -0
- data/lib/stripe_mock/webhook_fixtures/payout.paid.json +40 -0
- data/lib/stripe_mock/webhook_fixtures/payout.updated.json +46 -0
- data/lib/stripe_mock/webhook_fixtures/plan.created.json +30 -13
- data/lib/stripe_mock/webhook_fixtures/plan.deleted.json +30 -13
- data/lib/stripe_mock/webhook_fixtures/plan.updated.json +34 -14
- data/lib/stripe_mock/webhook_fixtures/price.created.json +42 -0
- data/lib/stripe_mock/webhook_fixtures/price.deleted.json +42 -0
- data/lib/stripe_mock/webhook_fixtures/price.updated.json +48 -0
- data/lib/stripe_mock/webhook_fixtures/product.created.json +19 -13
- data/lib/stripe_mock/webhook_fixtures/product.deleted.json +20 -14
- data/lib/stripe_mock/webhook_fixtures/product.updated.json +24 -15
- data/lib/stripe_mock/webhook_fixtures/quote.accepted.json +92 -0
- data/lib/stripe_mock/webhook_fixtures/quote.canceled.json +92 -0
- data/lib/stripe_mock/webhook_fixtures/quote.created.json +92 -0
- data/lib/stripe_mock/webhook_fixtures/quote.finalized.json +92 -0
- data/lib/stripe_mock/webhook_fixtures/setup_intent.canceled.json +46 -0
- data/lib/stripe_mock/webhook_fixtures/setup_intent.created.json +51 -0
- data/lib/stripe_mock/webhook_fixtures/setup_intent.setup_failed.json +100 -0
- data/lib/stripe_mock/webhook_fixtures/setup_intent.succeeded.json +46 -0
- data/lib/stripe_mock/webhook_fixtures/subscription_schedule.canceled.json +119 -0
- data/lib/stripe_mock/webhook_fixtures/subscription_schedule.created.json +114 -0
- data/lib/stripe_mock/webhook_fixtures/subscription_schedule.released.json +111 -0
- data/lib/stripe_mock/webhook_fixtures/subscription_schedule.updated.json +125 -0
- data/lib/stripe_mock/webhook_fixtures/tax_rate.created.json +32 -0
- data/lib/stripe_mock/webhook_fixtures/tax_rate.updated.json +37 -0
- data/lib/stripe_mock.rb +7 -1
- data/spec/instance_spec.rb +7 -7
- data/spec/integration_examples/completing_checkout_sessions_example.rb +37 -0
- data/spec/list_spec.rb +23 -0
- data/spec/readme_spec.rb +1 -1
- data/spec/server_spec.rb +4 -2
- data/spec/shared_stripe_examples/account_examples.rb +9 -1
- 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_session_examples.rb +99 -0
- 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 +29 -8
- data/spec/shared_stripe_examples/payment_intent_examples.rb +74 -0
- data/spec/shared_stripe_examples/payment_method_examples.rb +336 -67
- data/spec/shared_stripe_examples/price_examples.rb +223 -0
- data/spec/shared_stripe_examples/product_examples.rb +1 -9
- data/spec/shared_stripe_examples/promotion_code_examples.rb +68 -0
- data/spec/shared_stripe_examples/refund_examples.rb +13 -0
- data/spec/shared_stripe_examples/setup_intent_examples.rb +17 -0
- data/spec/shared_stripe_examples/subscription_examples.rb +327 -9
- data/spec/shared_stripe_examples/transfer_examples.rb +10 -1
- data/spec/shared_stripe_examples/webhook_event_examples.rb +51 -5
- data/spec/spec_helper.rb +4 -0
- data/spec/stripe_mock_spec.rb +2 -2
- data/spec/support/stripe_examples.rb +8 -2
- data/stripe-ruby-mock.gemspec +7 -2
- metadata +72 -15
- data/.travis.yml +0 -28
- data/lib/stripe_mock/request_handlers/checkout.rb +0 -15
- data/spec/shared_stripe_examples/checkout_examples.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7b5b1b83df91e8e6fd700456710804749b9b1008e572fd8c74eec4f1519e8a49
|
4
|
+
data.tar.gz: bf362cf2fe9aa556e155df2b61076248335e3b2a43f69e0e6fc046406d65da57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a397bf1b196f62bb7c8d76f79e2582f6d6594d20ddb9473b8dd5e7680c1844620a29456cddd8be8c5d9b785f4317ea1b092b340f841ccdbef92d849c6bb116e7
|
7
|
+
data.tar.gz: 90f97fe65c4dcd10eaa853aec740bce21c56b8df57bc1a589acc6f13ebf1b65943731b50f820d9f8eaa77954673f78b34bb62b326cbb7c71f5692a0b74a347c0
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Tests
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ "master" ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ "master" ]
|
15
|
+
|
16
|
+
permissions:
|
17
|
+
contents: read
|
18
|
+
|
19
|
+
jobs:
|
20
|
+
test:
|
21
|
+
|
22
|
+
runs-on: ubuntu-latest
|
23
|
+
strategy:
|
24
|
+
matrix:
|
25
|
+
ruby-version: ['2.6', '2.7', '3.0']
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v3
|
29
|
+
- name: Set up Ruby
|
30
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
31
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
32
|
+
# uses: ruby/setup-ruby@v1
|
33
|
+
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
|
34
|
+
with:
|
35
|
+
ruby-version: ${{ matrix.ruby-version }}
|
36
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
37
|
+
- name: Run tests
|
38
|
+
run: bundle exec rspec
|
data/.rspec
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
--colour
|
1
|
+
--colour
|
2
|
+
--format progress
|
data/CHANGELOG.md
CHANGED
@@ -1,22 +1,69 @@
|
|
1
|
-
###
|
1
|
+
### Unreleased
|
2
2
|
|
3
|
-
|
3
|
+
- [#693](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/693) gemspec: add change,issue,source_code URL by [@mtmail](https://github.com/mtmail)
|
4
|
+
- [#700](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/700) update the balance API to respond with instant_available by [@iamnader](https://github.com/iamnader)
|
5
|
+
- [#687](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/687) Add PaymentIntent Webhooks by [@klaustopher](https://github.com/klaustopher)
|
6
|
+
- [#708](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/708) Implement Stripe::Checkout::Session.retrieve by [@coorasse](https://github.com/coorasse)
|
7
|
+
- [#711](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/711) Adding account link mock by [@amenon](https://github.com/amenon)
|
8
|
+
- [#715](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/715) Added application_fee_amount to mock charge object by [@espen](https://github.com/espen)
|
9
|
+
- [#694](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/694) Introduce ideal and sepa_debit types for PaymentMethod by [@mnin](https://github.com/mnin)
|
10
|
+
- [#720](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/720) Add additional parameters by [@rpietraszko](https://github.com/rpietraszko)
|
11
|
+
- [#695](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/695) Add `has_more` attribute to all ListObject instances by [@gbp](https://github.com/gbp)
|
12
|
+
- [#727](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/727) Fix List initialize error with deleted records by [@jmulieri](https://github.com/jmulieri)
|
13
|
+
- [#739](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/739) Add data to account links by [@dudyn5ky1](https://github.com/dudyn5ky1)
|
14
|
+
- [#756](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/756) Added #715 PR to changelog by [@espen](https://github.com/espen)
|
15
|
+
- [#759](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/759) Adding express dashboard login link mock by [@rohitbegani](https://github.com/rohitbegani)
|
16
|
+
- [#747](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/747) Fix ruby 2.7 deprecation warnings by [@coding-chimp](https://github.com/coding-chimp)
|
17
|
+
- [#762](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/762) Support Stripe Connect by adding stripe_account header namespace for customers by [@csalvato](https://github.com/csalvato)
|
18
|
+
- [#758](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/758) Create price by [@jamesprior](https://github.com/jamesprior)
|
19
|
+
- [#730](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/730) support on price api by [@hidenba](https://github.com/hidenba)
|
20
|
+
- [#764](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/764) Fixes erroneous error message when fetching upcoming invoices. by [@csalvato](https://github.com/csalvato)
|
21
|
+
- [#765](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/765) Properly set the status of a trialing subscription by [@csalvato](https://github.com/csalvato)
|
22
|
+
- [#755](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/755) Add allowed params to subscriptions by [@dominikdarnel](https://github.com/dominikdarnel)
|
23
|
+
- [#709](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/709) Remove unnecessary check on customer's currency by [@coorasse](https://github.com/coorasse)
|
24
|
+
|
25
|
+
- [#806](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/806) - Remove `payment_method_types` from required arguments for `Stripe::Checkout::Session`
|
26
|
+
- [#806](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/806) - Raise more helpful exception when Stripe::Price cannot be found within a `Stripe::Checkout::Session` `line_items` argument.
|
27
|
+
|
28
|
+
|
29
|
+
### 3.1.0.rc3 (pre-release 2021-07-14)
|
30
|
+
|
31
|
+
- [#785](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/785): `Stripe::Product` no longer requires `type`. [@TastyPi](https://github.com/TastyPi)
|
32
|
+
- [#784](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/784): Fix "Wrong number of arguments" error in tests. [@TastyPi](https://github.com/TastyPi)
|
33
|
+
- [#782](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/782): Support expanding `setup_intent` in `Stripe::Checkout::Session`. [@TastyPi](https://github.com/TastyPi)
|
34
|
+
|
35
|
+
### 3.1.0.rc2 (pre-release 2021-03-03)
|
36
|
+
|
37
|
+
- [#767](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/767): Fixes tests and more [@lpsBetty](https://github.com/lpsBetty)
|
38
|
+
|
39
|
+
### 3.1.0.rc1 (pre-release 2021-02-17)
|
40
|
+
|
41
|
+
- [#765](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/765): Properly set the status of a trialing subscription. [@csalvato](https://github.com/csalvato)
|
42
|
+
- [#764](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/764): Fixes erroneous error message when fetching upcoming invoices. [@csalvato](https://github.com/csalvato)
|
43
|
+
- [#762](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/762): Support Stripe Connect with Customers by adding stripe_account header namespace for customer object [@csalvato](https://github.com/csalvato)
|
44
|
+
- [#755](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/755): Add allowed params to subscriptions [@dominikdarnel ](https://github.com/dominikdarnel)
|
45
|
+
- [#748](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/758): Support Prices - [@hidenba](https://github.com/hidenba) and [@jamesprior](https://github.com/jamesprior).
|
46
|
+
- [#747](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/747/files): Fix ruby 2.7 deprecation warnings. Adds Ruby 3.0.0 compatibility. [@coding-chimp](https://github.com/coding-chimp)
|
47
|
+
- [#715](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/715): Added application_fee_amount to mock charge object - [@espen](https://github.com/espen)
|
48
|
+
- [#709](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/709): Remove unnecessary check on customer's currency - [@coorasse](https://github.com/coorasse)
|
4
49
|
|
5
50
|
### 3.0.1 (TBD)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
51
|
+
|
52
|
+
- Added Changelog file
|
53
|
+
- [#640](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/640): Support Payment Intent status requires_capture - [@theodorton](https://github.com/theodorton).
|
54
|
+
- [#685](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/685): Adds support for pending_invoice_item_interval - [@joshcass](https://github.com/joshcass).
|
55
|
+
- [#682](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/682): Prevent customer metadata from being overwritten with each update - [@sethkrasnianski](https://github.com/sethkrasnianski).
|
56
|
+
- [#679](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/679): Fix for [#678](https://github.com/stripe-ruby-mock/stripe-ruby-mock/issues/678) Add active filter to Data::List - [@rnmp](https://github.com/rnmp).
|
57
|
+
- [#668](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/668): Fix for [#665](https://github.com/stripe-ruby-mock/stripe-ruby-mock/issues/665) Allow to remove discount from customer - [@mnin](https://github.com/mnin).
|
58
|
+
- [#667](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/667):
|
59
|
+
Remove empty and duplicated methods from payment methods - [@mnin](https://github.com/mnin).
|
60
|
+
- [#664](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/664): Bugfix: pass through PaymentIntent amount to mocked Charge - [@typeoneerror](https://github.com/typeoneerror).
|
61
|
+
- [#654](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/654): fix for [#626](https://github.com/stripe-ruby-mock/stripe-ruby-mock/issues/626) Added missing decline codes - [@iCreateJB](https://github.com/iCreateJB).
|
62
|
+
- [#648](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/648): Initial implementation of checkout session API - [@fauxparse](https://github.com/fauxparse).
|
63
|
+
- [#644](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/644): Allow payment_behavior attribute on subscription create - [@j15e](https://github.com/j15e).
|
18
64
|
|
19
65
|
### 3.0.0 (2019-12-17)
|
20
66
|
|
21
67
|
##### the main thing is:
|
22
|
-
|
68
|
+
|
69
|
+
- [#658](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/658) Make the gem compatible with Stripe Gem v.5
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# stripe-ruby-mock [![
|
1
|
+
# stripe-ruby-mock [![Tests](https://github.com/stripe-ruby-mock/stripe-ruby-mock/actions/workflows/rspec_tests.yml/badge.svg)](https://github.com/stripe-ruby-mock/stripe-ruby-mock/actions/workflows/rspec_tests.yml)
|
2
2
|
|
3
3
|
* Homepage: https://github.com/stripe-ruby-mock/stripe-ruby-mock
|
4
4
|
* Issues: https://github.com/stripe-ruby-mock/stripe-ruby-mock/issues
|
@@ -12,7 +12,7 @@ This gem has unexpectedly grown in popularity and I've gotten pretty busy, so I'
|
|
12
12
|
|
13
13
|
In your gemfile:
|
14
14
|
|
15
|
-
gem 'stripe-ruby-mock', '~> 3.0
|
15
|
+
gem 'stripe-ruby-mock', '~> 3.1.0', :require => 'stripe_mock'
|
16
16
|
|
17
17
|
## !!! Important
|
18
18
|
|
@@ -29,7 +29,7 @@ version `3.0.0` has [breaking changes](https://github.com/stripe-ruby-mock/strip
|
|
29
29
|
|
30
30
|
### Requirements
|
31
31
|
|
32
|
-
* ruby >= 2.
|
32
|
+
* ruby >= 2.6.0
|
33
33
|
* stripe >= 5.0.0
|
34
34
|
|
35
35
|
### Specifications
|
@@ -406,6 +406,8 @@ Patches are welcome and greatly appreciated! If you're contributing to fix a pro
|
|
406
406
|
be sure to write tests that illustrate the problem being fixed.
|
407
407
|
This will help ensure that the problem remains fixed in future updates.
|
408
408
|
|
409
|
+
Note: You may need to `ulimit -n 4048` before running the test suite to get all tests to pass.
|
410
|
+
|
409
411
|
## Copyright
|
410
412
|
|
411
413
|
Copyright (c) 2013 Gilbert
|
@@ -8,7 +8,7 @@ module StripeMock
|
|
8
8
|
return false if @state == 'live'
|
9
9
|
return @client unless @client.nil?
|
10
10
|
|
11
|
-
Stripe::StripeClient.send(:define_method, :execute_request) { |*args| StripeMock.redirect_to_mock_server(*args) }
|
11
|
+
Stripe::StripeClient.send(:define_method, :execute_request) { |*args, **keyword_args| StripeMock.redirect_to_mock_server(*args, **keyword_args) }
|
12
12
|
@client = StripeMock::Client.new(port)
|
13
13
|
@state = 'remote'
|
14
14
|
@client
|
@@ -7,7 +7,7 @@ module StripeMock
|
|
7
7
|
def self.start
|
8
8
|
return false if @state == 'live'
|
9
9
|
@instance = instance = Instance.new
|
10
|
-
Stripe::StripeClient.send(:define_method, :execute_request) { |*args| instance.mock_request(*args) }
|
10
|
+
Stripe::StripeClient.send(:define_method, :execute_request) { |*args, **keyword_args| instance.mock_request(*args, **keyword_args) }
|
11
11
|
@state = 'local'
|
12
12
|
end
|
13
13
|
|
@@ -4,7 +4,7 @@ module StripeMock
|
|
4
4
|
|
5
5
|
fixture_file = File.join(@webhook_fixture_path, "#{type}.json")
|
6
6
|
|
7
|
-
unless File.
|
7
|
+
unless File.exist?(fixture_file)
|
8
8
|
unless Webhooks.event_list.include?(type)
|
9
9
|
raise UnsupportedRequestError.new "Unsupported webhook event `#{type}` (Searched in #{@webhook_fixture_path})"
|
10
10
|
end
|
@@ -37,53 +37,94 @@ module StripeMock
|
|
37
37
|
module Webhooks
|
38
38
|
def self.event_list
|
39
39
|
@__list = [
|
40
|
-
'account.updated',
|
41
40
|
'account.application.deauthorized',
|
42
41
|
'account.external_account.created',
|
43
|
-
'account.external_account.updated',
|
44
42
|
'account.external_account.deleted',
|
43
|
+
'account.external_account.updated',
|
44
|
+
'account.updated',
|
45
45
|
'balance.available',
|
46
|
-
'charge.
|
47
|
-
'charge.updated',
|
48
|
-
'charge.failed',
|
49
|
-
'charge.refunded',
|
50
|
-
'charge.dispute.created',
|
51
|
-
'charge.dispute.updated',
|
46
|
+
'charge.captured',
|
52
47
|
'charge.dispute.closed',
|
48
|
+
'charge.dispute.created',
|
53
49
|
'charge.dispute.funds_reinstated',
|
54
50
|
'charge.dispute.funds_withdrawn',
|
51
|
+
'charge.dispute.updated',
|
52
|
+
'charge.failed',
|
53
|
+
'charge.refund.updated',
|
54
|
+
'charge.refunded',
|
55
|
+
'charge.succeeded',
|
56
|
+
'charge.updated',
|
57
|
+
'checkout.session.completed',
|
58
|
+
'checkout.session.completed.payment_mode',
|
59
|
+
'checkout.session.completed.setup_mode',
|
60
|
+
'coupon.created',
|
61
|
+
'coupon.deleted',
|
62
|
+
'customer.created',
|
63
|
+
'customer.deleted',
|
64
|
+
'customer.discount.created',
|
65
|
+
'customer.discount.deleted',
|
66
|
+
'customer.discount.updated',
|
55
67
|
'customer.source.created',
|
56
68
|
'customer.source.deleted',
|
57
69
|
'customer.source.updated',
|
58
|
-
'customer.created',
|
59
|
-
'customer.updated',
|
60
|
-
'customer.deleted',
|
61
70
|
'customer.subscription.created',
|
62
|
-
'customer.subscription.updated',
|
63
71
|
'customer.subscription.deleted',
|
64
72
|
'customer.subscription.trial_will_end',
|
65
|
-
'customer.
|
66
|
-
'customer.
|
67
|
-
'customer.discount.deleted',
|
73
|
+
'customer.subscription.updated',
|
74
|
+
'customer.updated',
|
68
75
|
'invoice.created',
|
69
|
-
'invoice.
|
70
|
-
'invoice.
|
76
|
+
'invoice.finalized',
|
77
|
+
'invoice.paid',
|
78
|
+
'invoice.payment_action_required',
|
71
79
|
'invoice.payment_failed',
|
80
|
+
'invoice.payment_succeeded',
|
81
|
+
'invoice.upcoming',
|
82
|
+
'invoice.updated',
|
72
83
|
'invoiceitem.created',
|
73
|
-
'invoiceitem.updated',
|
74
84
|
'invoiceitem.deleted',
|
85
|
+
'invoiceitem.updated',
|
86
|
+
'mandate.updated',
|
87
|
+
'payment_intent.amount_capturable_updated',
|
88
|
+
'payment_intent.canceled',
|
89
|
+
'payment_intent.created',
|
90
|
+
'payment_intent.payment_failed',
|
91
|
+
'payment_intent.processing',
|
92
|
+
'payment_intent.requires_action',
|
93
|
+
'payment_intent.succeeded',
|
94
|
+
'payment_link.created',
|
95
|
+
'payment_link.updated',
|
96
|
+
'payment_method.attached',
|
97
|
+
'payment_method.detached',
|
98
|
+
'payout.created',
|
99
|
+
'payout.paid',
|
100
|
+
'payout.updated',
|
75
101
|
'plan.created',
|
76
|
-
'plan.updated',
|
77
102
|
'plan.deleted',
|
103
|
+
'plan.updated',
|
104
|
+
'price.created',
|
105
|
+
'price.deleted',
|
106
|
+
'price.updated',
|
78
107
|
'product.created',
|
79
|
-
'product.updated',
|
80
108
|
'product.deleted',
|
81
|
-
'
|
82
|
-
'
|
109
|
+
'product.updated',
|
110
|
+
'quote.accepted',
|
111
|
+
'quote.canceled',
|
112
|
+
'quote.created',
|
113
|
+
'quote.finalized',
|
114
|
+
'setup_intent.canceled',
|
115
|
+
'setup_intent.created',
|
116
|
+
'setup_intent.setup_failed',
|
117
|
+
'setup_intent.succeeded',
|
118
|
+
'subscription_schedule.canceled',
|
119
|
+
'subscription_schedule.created',
|
120
|
+
'subscription_schedule.released',
|
121
|
+
'subscription_schedule.updated',
|
122
|
+
'tax_rate.created',
|
123
|
+
'tax_rate.updated',
|
83
124
|
'transfer.created',
|
125
|
+
'transfer.failed',
|
84
126
|
'transfer.paid',
|
85
|
-
'transfer.updated'
|
86
|
-
'transfer.failed'
|
127
|
+
'transfer.updated'
|
87
128
|
]
|
88
129
|
end
|
89
130
|
end
|
data/lib/stripe_mock/client.rb
CHANGED
@@ -18,7 +18,8 @@ module StripeMock
|
|
18
18
|
@pipe.mock_request(method, url, api_key: api_key, params: params, headers: headers).tap {|result|
|
19
19
|
response, api_key = result
|
20
20
|
if response.is_a?(Hash) && response[:error_raised] == 'invalid_request'
|
21
|
-
|
21
|
+
args, keyword_args = response[:error_params].first(2), response[:error_params].last
|
22
|
+
raise Stripe::InvalidRequestError.new(*args, **keyword_args)
|
22
23
|
end
|
23
24
|
}
|
24
25
|
end
|
@@ -9,12 +9,9 @@ module StripeMock
|
|
9
9
|
@starting_after = options[:starting_after]
|
10
10
|
@ending_before = options[:ending_before]
|
11
11
|
@active = options[:active]
|
12
|
-
if
|
13
|
-
|
14
|
-
|
15
|
-
elsif @data.first.respond_to?(:created)
|
16
|
-
@data.sort_by { |x| x.created }
|
17
|
-
@data.reverse!
|
12
|
+
if contains_stripe_objects?
|
13
|
+
prune_deleted_data
|
14
|
+
sort_data
|
18
15
|
end
|
19
16
|
end
|
20
17
|
|
@@ -76,6 +73,34 @@ module StripeMock
|
|
76
73
|
"#{first_object.class.to_s.split('::')[-1].downcase}s"
|
77
74
|
end
|
78
75
|
end
|
76
|
+
|
77
|
+
def contains_stripe_objects?
|
78
|
+
return false if data.empty?
|
79
|
+
|
80
|
+
object = data.first
|
81
|
+
object.is_a?(Stripe::StripeObject) || (
|
82
|
+
object.is_a?(Hash) && [:created, :deleted].any? { |k| object.key?(k) }
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
def prune_deleted_data
|
87
|
+
data.reject! do |object|
|
88
|
+
(object.is_a?(Hash) && object[:deleted]) ||
|
89
|
+
(object.is_a?(Stripe::StripeObject) && object.deleted?)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def sort_data
|
94
|
+
# Reverse must follow sort to preserve existing test dependencies. The
|
95
|
+
# alternative would be to simply reverse lhs and rhs in the comparison,
|
96
|
+
# however, being a stable sort this breaks the existing dependency when
|
97
|
+
# more than one record share the same `created` value.
|
98
|
+
@data = data.sort { |lhs, rhs| sort_val(lhs) <=> sort_val(rhs) }.reverse
|
99
|
+
end
|
100
|
+
|
101
|
+
def sort_val(object)
|
102
|
+
object.is_a?(Stripe::StripeObject) ? object.created : object[:created]
|
103
|
+
end
|
79
104
|
end
|
80
105
|
end
|
81
106
|
end
|