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.
Files changed (137) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/rspec_tests.yml +38 -0
  3. data/.rspec +2 -1
  4. data/CHANGELOG.md +62 -15
  5. data/Gemfile +1 -0
  6. data/README.md +5 -3
  7. data/lib/stripe_mock/api/client.rb +1 -1
  8. data/lib/stripe_mock/api/instance.rb +1 -1
  9. data/lib/stripe_mock/api/webhooks.rb +66 -25
  10. data/lib/stripe_mock/client.rb +2 -1
  11. data/lib/stripe_mock/data/list.rb +31 -6
  12. data/lib/stripe_mock/data.rb +201 -30
  13. data/lib/stripe_mock/instance.rb +12 -3
  14. data/lib/stripe_mock/request_handlers/account_links.rb +15 -0
  15. data/lib/stripe_mock/request_handlers/accounts.rb +17 -6
  16. data/lib/stripe_mock/request_handlers/charges.rb +11 -4
  17. data/lib/stripe_mock/request_handlers/checkout_session.rb +179 -0
  18. data/lib/stripe_mock/request_handlers/customers.rb +22 -13
  19. data/lib/stripe_mock/request_handlers/ephemeral_key.rb +1 -1
  20. data/lib/stripe_mock/request_handlers/events.rb +30 -3
  21. data/lib/stripe_mock/request_handlers/express_login_links.rb +15 -0
  22. data/lib/stripe_mock/request_handlers/helpers/coupon_helpers.rb +1 -0
  23. data/lib/stripe_mock/request_handlers/helpers/subscription_helpers.rb +36 -12
  24. data/lib/stripe_mock/request_handlers/invoices.rb +10 -4
  25. data/lib/stripe_mock/request_handlers/payment_intents.rb +13 -2
  26. data/lib/stripe_mock/request_handlers/payment_methods.rb +11 -4
  27. data/lib/stripe_mock/request_handlers/prices.rb +62 -0
  28. data/lib/stripe_mock/request_handlers/promotion_codes.rb +43 -0
  29. data/lib/stripe_mock/request_handlers/refunds.rb +13 -2
  30. data/lib/stripe_mock/request_handlers/setup_intents.rb +16 -9
  31. data/lib/stripe_mock/request_handlers/sources.rb +12 -6
  32. data/lib/stripe_mock/request_handlers/subscriptions.rb +120 -21
  33. data/lib/stripe_mock/request_handlers/tokens.rb +6 -4
  34. data/lib/stripe_mock/request_handlers/transfers.rb +12 -1
  35. data/lib/stripe_mock/request_handlers/validators/param_validators.rb +33 -4
  36. data/lib/stripe_mock/server.rb +2 -2
  37. data/lib/stripe_mock/test_strategies/base.rb +62 -10
  38. data/lib/stripe_mock/version.rb +1 -1
  39. data/lib/stripe_mock/webhook_fixtures/account.updated.json +1 -1
  40. data/lib/stripe_mock/webhook_fixtures/balance.available.json +27 -15
  41. data/lib/stripe_mock/webhook_fixtures/charge.captured.json +143 -0
  42. data/lib/stripe_mock/webhook_fixtures/charge.dispute.created.json +63 -16
  43. data/lib/stripe_mock/webhook_fixtures/charge.failed.json +49 -120
  44. data/lib/stripe_mock/webhook_fixtures/charge.refund.updated.json +35 -0
  45. data/lib/stripe_mock/webhook_fixtures/charge.refunded.json +145 -50
  46. data/lib/stripe_mock/webhook_fixtures/charge.succeeded.json +114 -43
  47. data/lib/stripe_mock/webhook_fixtures/checkout.session.completed.json +79 -0
  48. data/lib/stripe_mock/webhook_fixtures/checkout.session.completed.payment_mode.json +53 -0
  49. data/lib/stripe_mock/webhook_fixtures/checkout.session.completed.setup_mode.json +45 -0
  50. data/lib/stripe_mock/webhook_fixtures/customer.created.json +37 -46
  51. data/lib/stripe_mock/webhook_fixtures/customer.deleted.json +36 -32
  52. data/lib/stripe_mock/webhook_fixtures/customer.source.created.json +31 -22
  53. data/lib/stripe_mock/webhook_fixtures/customer.source.updated.json +36 -25
  54. data/lib/stripe_mock/webhook_fixtures/customer.subscription.created.json +135 -47
  55. data/lib/stripe_mock/webhook_fixtures/customer.subscription.deleted.json +134 -45
  56. data/lib/stripe_mock/webhook_fixtures/customer.subscription.updated.json +135 -56
  57. data/lib/stripe_mock/webhook_fixtures/customer.updated.json +38 -47
  58. data/lib/stripe_mock/webhook_fixtures/invoice.created.json +176 -49
  59. data/lib/stripe_mock/webhook_fixtures/invoice.finalized.json +171 -0
  60. data/lib/stripe_mock/webhook_fixtures/invoice.paid.json +171 -0
  61. data/lib/stripe_mock/webhook_fixtures/invoice.payment_action_required.json +171 -0
  62. data/lib/stripe_mock/webhook_fixtures/invoice.payment_failed.json +149 -83
  63. data/lib/stripe_mock/webhook_fixtures/invoice.payment_succeeded.json +149 -90
  64. data/lib/stripe_mock/webhook_fixtures/invoice.upcoming.json +70 -0
  65. data/lib/stripe_mock/webhook_fixtures/invoice.updated.json +178 -50
  66. data/lib/stripe_mock/webhook_fixtures/invoiceitem.created.json +87 -13
  67. data/lib/stripe_mock/webhook_fixtures/invoiceitem.updated.json +88 -14
  68. data/lib/stripe_mock/webhook_fixtures/mandate.updated.json +34 -0
  69. data/lib/stripe_mock/webhook_fixtures/payment_intent.amount_capturable_updated.json +170 -0
  70. data/lib/stripe_mock/webhook_fixtures/payment_intent.canceled.json +73 -0
  71. data/lib/stripe_mock/webhook_fixtures/payment_intent.created.json +86 -0
  72. data/lib/stripe_mock/webhook_fixtures/payment_intent.payment_failed.json +225 -0
  73. data/lib/stripe_mock/webhook_fixtures/payment_intent.processing.json +162 -0
  74. data/lib/stripe_mock/webhook_fixtures/payment_intent.requires_action.json +191 -0
  75. data/lib/stripe_mock/webhook_fixtures/payment_intent.succeeded.json +196 -0
  76. data/lib/stripe_mock/webhook_fixtures/payment_link.created.json +47 -0
  77. data/lib/stripe_mock/webhook_fixtures/payment_link.updated.json +50 -0
  78. data/lib/stripe_mock/webhook_fixtures/payment_method.attached.json +63 -0
  79. data/lib/stripe_mock/webhook_fixtures/payment_method.detached.json +62 -0
  80. data/lib/stripe_mock/webhook_fixtures/payout.created.json +40 -0
  81. data/lib/stripe_mock/webhook_fixtures/payout.paid.json +40 -0
  82. data/lib/stripe_mock/webhook_fixtures/payout.updated.json +46 -0
  83. data/lib/stripe_mock/webhook_fixtures/plan.created.json +30 -13
  84. data/lib/stripe_mock/webhook_fixtures/plan.deleted.json +30 -13
  85. data/lib/stripe_mock/webhook_fixtures/plan.updated.json +34 -14
  86. data/lib/stripe_mock/webhook_fixtures/price.created.json +42 -0
  87. data/lib/stripe_mock/webhook_fixtures/price.deleted.json +42 -0
  88. data/lib/stripe_mock/webhook_fixtures/price.updated.json +48 -0
  89. data/lib/stripe_mock/webhook_fixtures/product.created.json +19 -13
  90. data/lib/stripe_mock/webhook_fixtures/product.deleted.json +20 -14
  91. data/lib/stripe_mock/webhook_fixtures/product.updated.json +24 -15
  92. data/lib/stripe_mock/webhook_fixtures/quote.accepted.json +92 -0
  93. data/lib/stripe_mock/webhook_fixtures/quote.canceled.json +92 -0
  94. data/lib/stripe_mock/webhook_fixtures/quote.created.json +92 -0
  95. data/lib/stripe_mock/webhook_fixtures/quote.finalized.json +92 -0
  96. data/lib/stripe_mock/webhook_fixtures/setup_intent.canceled.json +46 -0
  97. data/lib/stripe_mock/webhook_fixtures/setup_intent.created.json +51 -0
  98. data/lib/stripe_mock/webhook_fixtures/setup_intent.setup_failed.json +100 -0
  99. data/lib/stripe_mock/webhook_fixtures/setup_intent.succeeded.json +46 -0
  100. data/lib/stripe_mock/webhook_fixtures/subscription_schedule.canceled.json +119 -0
  101. data/lib/stripe_mock/webhook_fixtures/subscription_schedule.created.json +114 -0
  102. data/lib/stripe_mock/webhook_fixtures/subscription_schedule.released.json +111 -0
  103. data/lib/stripe_mock/webhook_fixtures/subscription_schedule.updated.json +125 -0
  104. data/lib/stripe_mock/webhook_fixtures/tax_rate.created.json +32 -0
  105. data/lib/stripe_mock/webhook_fixtures/tax_rate.updated.json +37 -0
  106. data/lib/stripe_mock.rb +7 -1
  107. data/spec/instance_spec.rb +7 -7
  108. data/spec/integration_examples/completing_checkout_sessions_example.rb +37 -0
  109. data/spec/list_spec.rb +23 -0
  110. data/spec/readme_spec.rb +1 -1
  111. data/spec/server_spec.rb +4 -2
  112. data/spec/shared_stripe_examples/account_examples.rb +9 -1
  113. data/spec/shared_stripe_examples/account_link_examples.rb +16 -0
  114. data/spec/shared_stripe_examples/balance_examples.rb +6 -0
  115. data/spec/shared_stripe_examples/card_token_examples.rb +17 -21
  116. data/spec/shared_stripe_examples/checkout_session_examples.rb +99 -0
  117. data/spec/shared_stripe_examples/customer_examples.rb +11 -13
  118. data/spec/shared_stripe_examples/express_login_link_examples.rb +12 -0
  119. data/spec/shared_stripe_examples/invoice_examples.rb +29 -8
  120. data/spec/shared_stripe_examples/payment_intent_examples.rb +74 -0
  121. data/spec/shared_stripe_examples/payment_method_examples.rb +336 -67
  122. data/spec/shared_stripe_examples/price_examples.rb +223 -0
  123. data/spec/shared_stripe_examples/product_examples.rb +1 -9
  124. data/spec/shared_stripe_examples/promotion_code_examples.rb +68 -0
  125. data/spec/shared_stripe_examples/refund_examples.rb +13 -0
  126. data/spec/shared_stripe_examples/setup_intent_examples.rb +17 -0
  127. data/spec/shared_stripe_examples/subscription_examples.rb +327 -9
  128. data/spec/shared_stripe_examples/transfer_examples.rb +10 -1
  129. data/spec/shared_stripe_examples/webhook_event_examples.rb +51 -5
  130. data/spec/spec_helper.rb +4 -0
  131. data/spec/stripe_mock_spec.rb +2 -2
  132. data/spec/support/stripe_examples.rb +8 -2
  133. data/stripe-ruby-mock.gemspec +7 -2
  134. metadata +72 -15
  135. data/.travis.yml +0 -28
  136. data/lib/stripe_mock/request_handlers/checkout.rb +0 -15
  137. data/spec/shared_stripe_examples/checkout_examples.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7918d71c6145222a77feaeea20d2e5c211ce53c4
4
- data.tar.gz: 1aa548101a97a4fb5d5afe9294928b65fe0491d4
2
+ SHA256:
3
+ metadata.gz: 7b5b1b83df91e8e6fd700456710804749b9b1008e572fd8c74eec4f1519e8a49
4
+ data.tar.gz: bf362cf2fe9aa556e155df2b61076248335e3b2a43f69e0e6fc046406d65da57
5
5
  SHA512:
6
- metadata.gz: d83ccd0ba75faea9acce0f2f978099f215e22cd60563e80375a8e6f40ba3879e9b3d00b4a467f23797a80320e641629a60c20ebc675c2b7bfc92fedc055bc0d2
7
- data.tar.gz: 2e84b51981c315096a514e6d0e6caf8085d239a800e6dd47590d323bedd492d9c79250c448caa70c7a9ac8ae2f7d62b55d5928b2d489ff379b35e448d90584e0
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 --format documentation
1
+ --colour
2
+ --format progress
data/CHANGELOG.md CHANGED
@@ -1,22 +1,69 @@
1
- ### 3.0.2 (Next)
1
+ ### Unreleased
2
2
 
3
- * Your contribution here.
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
- * Added Changelog file
7
- * [#640](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/640): Support Payment Intent status requires_capture - [@theodorton](https://github.com/theodorton).
8
- * [#685](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/685): Adds support for pending_invoice_item_interval - [@joshcass](https://github.com/joshcass).
9
- * [#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).
10
- * [#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).
11
- * [#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).
12
- * [#667](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/667):
13
- Remove empty and duplicated methods from payment methods - [@mnin](https://github.com/mnin).
14
- * [#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).
15
- * [#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).
16
- * [#648](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/648): Initial implementation of checkout session API - [@fauxparse](https://github.com/fauxparse).
17
- * [#644](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/644): Allow payment_behavior attribute on subscription create - [@j15e](https://github.com/j15e).
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
- - [#658](https://github.com/stripe-ruby-mock/stripe-ruby-mock/pull/658) Make the gem compatible with Stripe Gem v.5
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
@@ -7,6 +7,7 @@ end
7
7
 
8
8
  group :test do
9
9
  gem 'rake'
10
+ gem 'dotenv'
10
11
  end
11
12
 
12
13
  gemspec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # stripe-ruby-mock [![Build Status](https://travis-ci.org/stripe-ruby-mock/stripe-ruby-mock.png?branch=master)](https://travis-ci.org/stripe-ruby-mock/stripe-ruby-mock) [![Gitter chat](https://badges.gitter.im/rebelidealist/stripe-ruby-mock.png)](https://gitter.im/rebelidealist/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.1', :require => 'stripe_mock'
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.4.0
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.exists?(fixture_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.succeeded',
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.discount.created',
66
- 'customer.discount.updated',
67
- 'customer.discount.deleted',
73
+ 'customer.subscription.updated',
74
+ 'customer.updated',
68
75
  'invoice.created',
69
- 'invoice.updated',
70
- 'invoice.payment_succeeded',
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
- 'coupon.created',
82
- 'coupon.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',
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
@@ -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
- raise Stripe::InvalidRequestError.new(*response[:error_params])
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 @data.first.is_a?(Hash) && @data.first[:created]
13
- @data.sort_by! { |x| x[:created] }
14
- @data.reverse!
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