stripe-ruby-mock 2.5.8 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/rspec_tests.yml +38 -0
- data/.gitignore +1 -1
- data/.rspec +2 -1
- data/CHANGELOG.md +77 -0
- data/Gemfile +1 -5
- data/README.md +19 -11
- data/lib/stripe_mock/api/client.rb +2 -2
- data/lib/stripe_mock/api/errors.rb +34 -28
- data/lib/stripe_mock/api/instance.rb +1 -1
- data/lib/stripe_mock/api/webhooks.rb +68 -24
- data/lib/stripe_mock/client.rb +2 -1
- data/lib/stripe_mock/data/list.rb +42 -9
- data/lib/stripe_mock/data.rb +359 -21
- data/lib/stripe_mock/instance.rb +23 -5
- 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/balance_transactions.rb +2 -2
- data/lib/stripe_mock/request_handlers/charges.rb +31 -5
- data/lib/stripe_mock/request_handlers/checkout_session.rb +179 -0
- data/lib/stripe_mock/request_handlers/customers.rb +47 -19
- 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 +6 -0
- data/lib/stripe_mock/request_handlers/helpers/search_helpers.rb +67 -0
- data/lib/stripe_mock/request_handlers/helpers/subscription_helpers.rb +36 -12
- data/lib/stripe_mock/request_handlers/helpers/token_helpers.rb +1 -1
- data/lib/stripe_mock/request_handlers/invoices.rb +26 -6
- data/lib/stripe_mock/request_handlers/payment_intents.rb +202 -0
- data/lib/stripe_mock/request_handlers/payment_methods.rb +124 -0
- data/lib/stripe_mock/request_handlers/plans.rb +1 -1
- data/lib/stripe_mock/request_handlers/prices.rb +71 -0
- data/lib/stripe_mock/request_handlers/products.rb +15 -5
- 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 +100 -0
- data/lib/stripe_mock/request_handlers/sources.rb +12 -6
- data/lib/stripe_mock/request_handlers/subscriptions.rb +146 -25
- 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 +124 -9
- data/lib/stripe_mock/server.rb +2 -2
- data/lib/stripe_mock/test_strategies/base.rb +98 -12
- 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/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 +101 -44
- 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 -45
- 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 -46
- 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 +40 -0
- data/lib/stripe_mock/webhook_fixtures/product.deleted.json +40 -0
- data/lib/stripe_mock/webhook_fixtures/product.updated.json +47 -0
- 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 +11 -0
- data/spec/instance_spec.rb +13 -13
- data/spec/integration_examples/completing_checkout_sessions_example.rb +37 -0
- data/spec/list_spec.rb +38 -0
- data/spec/readme_spec.rb +1 -1
- data/spec/server_spec.rb +6 -3
- data/spec/shared_stripe_examples/account_examples.rb +10 -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/balance_transaction_examples.rb +3 -3
- data/spec/shared_stripe_examples/bank_examples.rb +3 -3
- data/spec/shared_stripe_examples/bank_token_examples.rb +5 -7
- data/spec/shared_stripe_examples/card_examples.rb +4 -4
- data/spec/shared_stripe_examples/card_token_examples.rb +17 -21
- data/spec/shared_stripe_examples/charge_examples.rb +106 -22
- data/spec/shared_stripe_examples/checkout_session_examples.rb +99 -0
- data/spec/shared_stripe_examples/coupon_examples.rb +1 -1
- data/spec/shared_stripe_examples/customer_examples.rb +149 -53
- 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/express_login_link_examples.rb +12 -0
- data/spec/shared_stripe_examples/external_account_examples.rb +3 -3
- data/spec/shared_stripe_examples/invoice_examples.rb +148 -40
- data/spec/shared_stripe_examples/invoice_item_examples.rb +1 -1
- data/spec/shared_stripe_examples/payment_intent_examples.rb +283 -0
- data/spec/shared_stripe_examples/payment_method_examples.rb +454 -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/price_examples.rb +292 -0
- data/spec/shared_stripe_examples/product_examples.rb +215 -0
- data/spec/shared_stripe_examples/promotion_code_examples.rb +68 -0
- data/spec/shared_stripe_examples/refund_examples.rb +38 -21
- data/spec/shared_stripe_examples/setup_intent_examples.rb +85 -0
- data/spec/shared_stripe_examples/subscription_examples.rb +706 -324
- data/spec/shared_stripe_examples/subscription_items_examples.rb +3 -2
- data/spec/shared_stripe_examples/transfer_examples.rb +16 -7
- data/spec/shared_stripe_examples/webhook_event_examples.rb +62 -16
- data/spec/spec_helper.rb +8 -5
- data/spec/stripe_mock_spec.rb +4 -4
- data/spec/support/shared_contexts/stripe_validator_spec.rb +8 -0
- data/spec/support/stripe_examples.rb +11 -1
- data/stripe-ruby-mock.gemspec +9 -5
- metadata +115 -47
- data/.travis.yml +0 -28
- data/spec/shared_stripe_examples/product_example.rb +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: be25dafb9048c0f9fea9671c8dfa3c25f51121afcd11e2a83fb28033d84fb609
|
4
|
+
data.tar.gz: 5ccd183891c8ee2a67aa21b7be2508226850a514b9d1f5c8bbe994e374b832df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3be1ba24da98944abb23977d94ab25205ef5458fbe1504bff4293fa55b6d0ae57f922ede65d28f80872c60e66086fd68a32f5b4a96dd5c23ab59a20639f1c74
|
7
|
+
data.tar.gz: b06bea97f9417cfaf61e4c4a4dc86c914ef1dc76ec170bda9514fd782eddabeceac62b60a65fef771220b59c7b83aeba0c60a809a641c0b02984c1fa8378ce15
|
@@ -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.7', '3.0', '3.2']
|
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/.gitignore
CHANGED
data/.rspec
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
--colour
|
1
|
+
--colour
|
2
|
+
--format progress
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
### Unreleased
|
2
|
+
|
3
|
+
### 4.0.0 (2024-08-07)
|
4
|
+
- [#905](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/905) Allow Stripe SDK v11 by [@stevenharman ](https://github.com/stevenharman)
|
5
|
+
- [#830](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/830) Implement search API by [@adamstegman](https://github.com/adamstegman)
|
6
|
+
- [#848](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/848) Extending runtime dependency on Stripe gem from version 5 through 11 by [@smakani](https://github.com/smakani)
|
7
|
+
- [#893](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/893) Adds support for stripe-ruby v10 by [@fabianoarruda](https://github.com/fabianoarruda)
|
8
|
+
|
9
|
+
|
10
|
+
### 3.1.0 (2024-01-03)
|
11
|
+
- [#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)
|
12
|
+
- [#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)
|
13
|
+
- [#687](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/687) Add PaymentIntent Webhooks by [@klaustopher](https://github.com/klaustopher)
|
14
|
+
- [#708](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/708) Implement Stripe::Checkout::Session.retrieve by [@coorasse](https://github.com/coorasse)
|
15
|
+
- [#711](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/711) Adding account link mock by [@amenon](https://github.com/amenon)
|
16
|
+
- [#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)
|
17
|
+
- [#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)
|
18
|
+
- [#720](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/720) Add additional parameters by [@rpietraszko](https://github.com/rpietraszko)
|
19
|
+
- [#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)
|
20
|
+
- [#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)
|
21
|
+
- [#739](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/739) Add data to account links by [@dudyn5ky1](https://github.com/dudyn5ky1)
|
22
|
+
- [#756](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/756) Added #715 PR to changelog by [@espen](https://github.com/espen)
|
23
|
+
- [#759](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/759) Adding express dashboard login link mock by [@rohitbegani](https://github.com/rohitbegani)
|
24
|
+
- [#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)
|
25
|
+
- [#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)
|
26
|
+
- [#758](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/758) Create price by [@jamesprior](https://github.com/jamesprior)
|
27
|
+
- [#730](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/730) support on price api by [@hidenba](https://github.com/hidenba)
|
28
|
+
- [#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)
|
29
|
+
- [#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)
|
30
|
+
- [#755](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/755) Add allowed params to subscriptions by [@dominikdarnel](https://github.com/dominikdarnel)
|
31
|
+
- [#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)
|
32
|
+
|
33
|
+
- [#806](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/806) - Remove `payment_method_types` from required arguments for `Stripe::Checkout::Session`
|
34
|
+
- [#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.
|
35
|
+
|
36
|
+
|
37
|
+
### 3.1.0.rc3 (pre-release 2021-07-14)
|
38
|
+
|
39
|
+
- [#785](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/785): `Stripe::Product` no longer requires `type`. [@TastyPi](https://github.com/TastyPi)
|
40
|
+
- [#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)
|
41
|
+
- [#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)
|
42
|
+
|
43
|
+
### 3.1.0.rc2 (pre-release 2021-03-03)
|
44
|
+
|
45
|
+
- [#767](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/767): Fixes tests and more [@lpsBetty](https://github.com/lpsBetty)
|
46
|
+
|
47
|
+
### 3.1.0.rc1 (pre-release 2021-02-17)
|
48
|
+
|
49
|
+
- [#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)
|
50
|
+
- [#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)
|
51
|
+
- [#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)
|
52
|
+
- [#755](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/755): Add allowed params to subscriptions [@dominikdarnel ](https://github.com/dominikdarnel)
|
53
|
+
- [#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).
|
54
|
+
- [#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)
|
55
|
+
- [#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)
|
56
|
+
- [#709](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/709): Remove unnecessary check on customer's currency - [@coorasse](https://github.com/coorasse)
|
57
|
+
|
58
|
+
### 3.0.1 (TBD)
|
59
|
+
|
60
|
+
- Added Changelog file
|
61
|
+
- [#640](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/640): Support Payment Intent status requires_capture - [@theodorton](https://github.com/theodorton).
|
62
|
+
- [#685](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/685): Adds support for pending_invoice_item_interval - [@joshcass](https://github.com/joshcass).
|
63
|
+
- [#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).
|
64
|
+
- [#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).
|
65
|
+
- [#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).
|
66
|
+
- [#667](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/667):
|
67
|
+
Remove empty and duplicated methods from payment methods - [@mnin](https://github.com/mnin).
|
68
|
+
- [#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).
|
69
|
+
- [#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).
|
70
|
+
- [#648](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/648): Initial implementation of checkout session API - [@fauxparse](https://github.com/fauxparse).
|
71
|
+
- [#644](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/644): Allow payment_behavior attribute on subscription create - [@j15e](https://github.com/j15e).
|
72
|
+
|
73
|
+
### 3.0.0 (2019-12-17)
|
74
|
+
|
75
|
+
##### the main thing is:
|
76
|
+
|
77
|
+
- [#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,18 +1,24 @@
|
|
1
|
-
# stripe-ruby-mock [](https://github.com/stripe-ruby-mock/stripe-ruby-mock/actions/workflows/rspec_tests.yml)
|
2
2
|
|
3
|
-
* Homepage: https://github.com/
|
4
|
-
* Issues: https://github.com/
|
3
|
+
* Homepage: https://github.com/stripe-ruby-mock/stripe-ruby-mock
|
4
|
+
* Issues: https://github.com/stripe-ruby-mock/stripe-ruby-mock/issues
|
5
5
|
* **CHAT**: https://gitter.im/rebelidealist/stripe-ruby-mock
|
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', :require => 'stripe_mock'
|
16
|
+
|
17
|
+
## !!! Important
|
18
|
+
|
19
|
+
We have [changelog](https://github.com/stripe-ruby-mock/stripe-ruby-mock/blob/master/CHANGELOG.md). It's first attempt. Feel free to update it and suggest to a new format of it.
|
20
|
+
|
21
|
+
version `3.0.0` has [breaking changes](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/658) - we support stripe > 5 and < 6 for now and try to follow the newest API version. But if you still use older versions please [read](https://github.com/stripe-ruby-mock/stripe-ruby-mock#specifications).
|
16
22
|
|
17
23
|
## Features
|
18
24
|
|
@@ -23,12 +29,12 @@ In your gemfile:
|
|
23
29
|
|
24
30
|
### Requirements
|
25
31
|
|
26
|
-
* ruby >= 2.
|
27
|
-
* stripe
|
32
|
+
* ruby >= 2.7.0
|
33
|
+
* stripe > 5 & < 11
|
28
34
|
|
29
35
|
### Specifications
|
30
36
|
|
31
|
-
**STRIPE API TARGET VERSION:**
|
37
|
+
**STRIPE API TARGET VERSION:** 2019-08-20 (master) - we try, but some features are not implemented yet.
|
32
38
|
|
33
39
|
Older API version branches:
|
34
40
|
|
@@ -141,7 +147,7 @@ end
|
|
141
147
|
```
|
142
148
|
|
143
149
|
## Mocking Card Errors
|
144
|
-
|
150
|
+
** Ensure you start StripeMock in a before filter `StripeMock.start`
|
145
151
|
Tired of manually inputting fake credit card numbers to test against errors? Tire no more!
|
146
152
|
|
147
153
|
```ruby
|
@@ -176,7 +182,7 @@ StripeMock.prepare_card_error(:incorrect_zip)
|
|
176
182
|
You can see the details of each error in [lib/stripe_mock/api/errors.rb](lib/stripe_mock/api/errors.rb)
|
177
183
|
|
178
184
|
### Specifying Card Errors
|
179
|
-
|
185
|
+
** Ensure you start StripeMock in a before filter `StripeMock.start`
|
180
186
|
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
187
|
|
182
188
|
```ruby
|
@@ -195,7 +201,7 @@ customer.cards.create
|
|
195
201
|
`: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
202
|
|
197
203
|
### Custom Errors
|
198
|
-
|
204
|
+
** Ensure you start StripeMock in a before filter `StripeMock.start`
|
199
205
|
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
206
|
|
201
207
|
If you wanted to raise an error for creating a new customer, for instance, you would do the following:
|
@@ -400,6 +406,8 @@ Patches are welcome and greatly appreciated! If you're contributing to fix a pro
|
|
400
406
|
be sure to write tests that illustrate the problem being fixed.
|
401
407
|
This will help ensure that the problem remains fixed in future updates.
|
402
408
|
|
409
|
+
Note: You may need to `ulimit -n 4048` before running the test suite to get all tests to pass.
|
410
|
+
|
403
411
|
## Copyright
|
404
412
|
|
405
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
|
@@ -27,7 +27,7 @@ module StripeMock
|
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
-
def self.redirect_to_mock_server(method, url, api_key: nil, api_base: nil, params: {}, headers: {})
|
30
|
+
def self.redirect_to_mock_server(method, url, api_key: nil, api_base: nil, usage: [], params: {}, headers: {})
|
31
31
|
handler = Instance.handler_for_method_url("#{method} #{url}")
|
32
32
|
|
33
33
|
if mock_error = client.error_queue.error_for_handler_name(handler[:name])
|
@@ -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,33 @@ 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
|
+
when :insufficient_funds then build_card_error('The card has insufficient funds to complete the purchase.', nil, code: 'insufficient_funds', http_status: 402)
|
41
|
+
when :lost_card then build_card_error('The payment has been declined because the card is reported lost.', nil, code: 'lost_card', http_status: 402)
|
42
|
+
when :stolen_card then build_card_error('The payment has been declined because the card is reported stolen.', nil, code: 'stolen_card', http_status: 402)
|
43
|
+
end
|
40
44
|
end
|
41
45
|
|
42
46
|
def self.get_decline_code(code)
|
@@ -50,16 +54,18 @@ module StripeMock
|
|
50
54
|
decline_code_map[code_key]
|
51
55
|
end
|
52
56
|
|
53
|
-
def self.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
def self.build_card_error(message, param, **kwargs)
|
58
|
+
json_hash = {
|
59
|
+
message: message,
|
60
|
+
param: param,
|
61
|
+
code: kwargs[:code],
|
62
|
+
type: 'card_error',
|
63
|
+
decline_code: get_decline_code(kwargs[:code])
|
64
|
+
}
|
59
65
|
|
60
|
-
|
66
|
+
error_keyword_args = kwargs.merge(json_body: { error: json_hash }, http_body: { error: json_hash }.to_json)
|
61
67
|
|
62
|
-
|
68
|
+
Stripe::CardError.new(message, param, **error_keyword_args)
|
63
69
|
end
|
64
70
|
end
|
65
71
|
end
|
@@ -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,50 +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',
|
78
|
-
'
|
79
|
-
'
|
103
|
+
'plan.updated',
|
104
|
+
'price.created',
|
105
|
+
'price.deleted',
|
106
|
+
'price.updated',
|
107
|
+
'product.created',
|
108
|
+
'product.deleted',
|
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',
|
80
124
|
'transfer.created',
|
125
|
+
'transfer.failed',
|
81
126
|
'transfer.paid',
|
82
|
-
'transfer.updated'
|
83
|
-
'transfer.failed'
|
127
|
+
'transfer.updated'
|
84
128
|
]
|
85
129
|
end
|
86
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
|
@@ -1,19 +1,17 @@
|
|
1
1
|
module StripeMock
|
2
2
|
module Data
|
3
3
|
class List
|
4
|
-
attr_reader :data, :limit, :offset, :starting_after, :ending_before
|
4
|
+
attr_reader :data, :limit, :offset, :starting_after, :ending_before, :active
|
5
5
|
|
6
6
|
def initialize(data, options = {})
|
7
7
|
@data = Array(data.clone)
|
8
8
|
@limit = [[options[:limit] || 10, 100].min, 1].max # restrict @limit to 1..100
|
9
9
|
@starting_after = options[:starting_after]
|
10
10
|
@ending_before = options[:ending_before]
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
@data.sort_by { |x| x.created }
|
16
|
-
@data.reverse!
|
11
|
+
@active = options[:active]
|
12
|
+
if contains_stripe_objects?
|
13
|
+
prune_deleted_data
|
14
|
+
sort_data
|
17
15
|
end
|
18
16
|
end
|
19
17
|
|
@@ -53,14 +51,21 @@ module StripeMock
|
|
53
51
|
(index || raise("No such object id: #{starting_after}")) + 1
|
54
52
|
when ending_before
|
55
53
|
index = data.index { |datum| datum[:id] == ending_before }
|
56
|
-
(index || raise("No such object id: #{ending_before}")) - 1
|
54
|
+
(index || raise("No such object id: #{ending_before}")) - 1
|
57
55
|
else
|
58
56
|
0
|
59
57
|
end
|
60
58
|
end
|
61
59
|
|
62
60
|
def data_page
|
63
|
-
|
61
|
+
filtered_data[offset, limit]
|
62
|
+
end
|
63
|
+
|
64
|
+
def filtered_data
|
65
|
+
filtered_data = data
|
66
|
+
filtered_data = filtered_data.select { |d| d[:active] == active } unless active.nil?
|
67
|
+
|
68
|
+
filtered_data
|
64
69
|
end
|
65
70
|
|
66
71
|
def object_types
|
@@ -68,6 +73,34 @@ module StripeMock
|
|
68
73
|
"#{first_object.class.to_s.split('::')[-1].downcase}s"
|
69
74
|
end
|
70
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
|
71
104
|
end
|
72
105
|
end
|
73
106
|
end
|