stripe 5.26.0 → 5.55.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +126 -0
  3. data/Gemfile +0 -1
  4. data/Makefile +7 -0
  5. data/README.md +10 -5
  6. data/VERSION +1 -1
  7. data/lib/stripe/api_operations/request.rb +35 -2
  8. data/lib/stripe/api_operations/search.rb +19 -0
  9. data/lib/stripe/api_resource.rb +10 -17
  10. data/lib/stripe/api_resource_test_helpers.rb +47 -0
  11. data/lib/stripe/connection_manager.rb +51 -10
  12. data/lib/stripe/error_object.rb +2 -3
  13. data/lib/stripe/instrumentation.rb +3 -1
  14. data/lib/stripe/oauth.rb +4 -3
  15. data/lib/stripe/object_types.rb +19 -1
  16. data/lib/stripe/resources/account.rb +3 -8
  17. data/lib/stripe/resources/application_fee_refund.rb +2 -1
  18. data/lib/stripe/resources/billing_portal/configuration.rb +14 -0
  19. data/lib/stripe/resources/bitcoin_transaction.rb +3 -2
  20. data/lib/stripe/resources/capability.rb +2 -1
  21. data/lib/stripe/resources/cash_balance.rb +22 -0
  22. data/lib/stripe/resources/charge.rb +9 -0
  23. data/lib/stripe/resources/checkout/session.rb +11 -0
  24. data/lib/stripe/resources/credit_note_line_item.rb +1 -0
  25. data/lib/stripe/resources/customer.rb +39 -1
  26. data/lib/stripe/resources/customer_balance_transaction.rb +3 -2
  27. data/lib/stripe/resources/discount.rb +1 -0
  28. data/lib/stripe/resources/file.rb +2 -1
  29. data/lib/stripe/resources/financial_connections/account.rb +31 -0
  30. data/lib/stripe/resources/financial_connections/account_owner.rb +10 -0
  31. data/lib/stripe/resources/financial_connections/account_ownership.rb +10 -0
  32. data/lib/stripe/resources/financial_connections/session.rb +12 -0
  33. data/lib/stripe/resources/funding_instructions.rb +16 -0
  34. data/lib/stripe/resources/identity/verification_report.rb +12 -0
  35. data/lib/stripe/resources/identity/verification_session.rb +35 -0
  36. data/lib/stripe/resources/invoice.rb +9 -0
  37. data/lib/stripe/resources/invoice_line_item.rb +1 -0
  38. data/lib/stripe/resources/issuing/card_details.rb +2 -1
  39. data/lib/stripe/resources/line_item.rb +1 -0
  40. data/lib/stripe/resources/login_link.rb +1 -0
  41. data/lib/stripe/resources/payment_intent.rb +39 -0
  42. data/lib/stripe/resources/payment_link.rb +23 -0
  43. data/lib/stripe/resources/payout.rb +10 -0
  44. data/lib/stripe/resources/person.rb +1 -0
  45. data/lib/stripe/resources/price.rb +9 -0
  46. data/lib/stripe/resources/product.rb +9 -0
  47. data/lib/stripe/resources/quote.rb +105 -0
  48. data/lib/stripe/resources/refund.rb +30 -0
  49. data/lib/stripe/resources/reversal.rb +3 -2
  50. data/lib/stripe/resources/setup_intent.rb +10 -0
  51. data/lib/stripe/resources/shipping_rate.rb +12 -0
  52. data/lib/stripe/resources/source_transaction.rb +1 -0
  53. data/lib/stripe/resources/subscription.rb +9 -0
  54. data/lib/stripe/resources/tax_code.rb +10 -0
  55. data/lib/stripe/resources/tax_id.rb +1 -0
  56. data/lib/stripe/resources/terminal/configuration.rb +15 -0
  57. data/lib/stripe/resources/terminal/reader.rb +60 -0
  58. data/lib/stripe/resources/test_helpers/test_clock.rb +25 -0
  59. data/lib/stripe/resources/usage_record.rb +1 -0
  60. data/lib/stripe/resources/usage_record_summary.rb +1 -0
  61. data/lib/stripe/resources.rb +16 -0
  62. data/lib/stripe/search_result_object.rb +86 -0
  63. data/lib/stripe/stripe_client.rb +252 -114
  64. data/lib/stripe/stripe_configuration.rb +35 -8
  65. data/lib/stripe/stripe_object.rb +23 -0
  66. data/lib/stripe/stripe_response.rb +80 -52
  67. data/lib/stripe/util.rb +62 -7
  68. data/lib/stripe/version.rb +1 -1
  69. data/lib/stripe.rb +27 -22
  70. data/stripe.gemspec +12 -5
  71. metadata +26 -196
  72. data/.editorconfig +0 -10
  73. data/.gitattributes +0 -4
  74. data/.github/ISSUE_TEMPLATE.md +0 -5
  75. data/.gitignore +0 -8
  76. data/.rubocop.yml +0 -80
  77. data/.rubocop_todo.yml +0 -33
  78. data/.travis.yml +0 -38
  79. data/.vscode/extensions.json +0 -7
  80. data/.vscode/settings.json +0 -8
  81. data/test/openapi/README.md +0 -9
  82. data/test/stripe/account_link_test.rb +0 -18
  83. data/test/stripe/account_test.rb +0 -412
  84. data/test/stripe/alipay_account_test.rb +0 -37
  85. data/test/stripe/api_operations_test.rb +0 -80
  86. data/test/stripe/api_resource_test.rb +0 -646
  87. data/test/stripe/apple_pay_domain_test.rb +0 -46
  88. data/test/stripe/application_fee_refund_test.rb +0 -37
  89. data/test/stripe/application_fee_test.rb +0 -58
  90. data/test/stripe/balance_test.rb +0 -13
  91. data/test/stripe/balance_transaction_test.rb +0 -20
  92. data/test/stripe/bank_account_test.rb +0 -36
  93. data/test/stripe/billing_portal/session_test.rb +0 -18
  94. data/test/stripe/capability_test.rb +0 -45
  95. data/test/stripe/charge_test.rb +0 -64
  96. data/test/stripe/checkout/session_test.rb +0 -53
  97. data/test/stripe/connection_manager_test.rb +0 -163
  98. data/test/stripe/country_spec_test.rb +0 -20
  99. data/test/stripe/coupon_test.rb +0 -61
  100. data/test/stripe/credit_note_test.rb +0 -90
  101. data/test/stripe/customer_balance_transaction_test.rb +0 -37
  102. data/test/stripe/customer_card_test.rb +0 -48
  103. data/test/stripe/customer_test.rb +0 -226
  104. data/test/stripe/dispute_test.rb +0 -51
  105. data/test/stripe/ephemeral_key_test.rb +0 -93
  106. data/test/stripe/errors_test.rb +0 -53
  107. data/test/stripe/exchange_rate_test.rb +0 -20
  108. data/test/stripe/file_link_test.rb +0 -41
  109. data/test/stripe/file_test.rb +0 -87
  110. data/test/stripe/instrumentation_test.rb +0 -74
  111. data/test/stripe/invoice_item_test.rb +0 -66
  112. data/test/stripe/invoice_line_item_test.rb +0 -8
  113. data/test/stripe/invoice_test.rb +0 -229
  114. data/test/stripe/issuing/authorization_test.rb +0 -72
  115. data/test/stripe/issuing/card_test.rb +0 -74
  116. data/test/stripe/issuing/cardholder_test.rb +0 -53
  117. data/test/stripe/issuing/dispute_test.rb +0 -54
  118. data/test/stripe/issuing/transaction_test.rb +0 -48
  119. data/test/stripe/list_object_test.rb +0 -202
  120. data/test/stripe/login_link_test.rb +0 -37
  121. data/test/stripe/mandate_test.rb +0 -14
  122. data/test/stripe/multipart_encoder_test.rb +0 -130
  123. data/test/stripe/oauth_test.rb +0 -104
  124. data/test/stripe/order_return_test.rb +0 -21
  125. data/test/stripe/order_test.rb +0 -82
  126. data/test/stripe/payment_intent_test.rb +0 -107
  127. data/test/stripe/payment_method_test.rb +0 -84
  128. data/test/stripe/payout_test.rb +0 -57
  129. data/test/stripe/person_test.rb +0 -46
  130. data/test/stripe/plan_test.rb +0 -98
  131. data/test/stripe/price_test.rb +0 -48
  132. data/test/stripe/product_test.rb +0 -58
  133. data/test/stripe/promotion_code_test.rb +0 -42
  134. data/test/stripe/radar/early_fraud_warning_test.rb +0 -22
  135. data/test/stripe/radar/value_list_item_test.rb +0 -48
  136. data/test/stripe/radar/value_list_test.rb +0 -61
  137. data/test/stripe/recipient_test.rb +0 -62
  138. data/test/stripe/refund_test.rb +0 -39
  139. data/test/stripe/reporting/report_run_test.rb +0 -33
  140. data/test/stripe/reporting/report_type_test.rb +0 -22
  141. data/test/stripe/reversal_test.rb +0 -43
  142. data/test/stripe/review_test.rb +0 -27
  143. data/test/stripe/setup_attempt_test.rb +0 -16
  144. data/test/stripe/setup_intent_test.rb +0 -84
  145. data/test/stripe/sigma/scheduled_query_run_test.rb +0 -22
  146. data/test/stripe/sku_test.rb +0 -60
  147. data/test/stripe/source_test.rb +0 -119
  148. data/test/stripe/stripe_client_test.rb +0 -1291
  149. data/test/stripe/stripe_configuration_test.rb +0 -128
  150. data/test/stripe/stripe_object_test.rb +0 -500
  151. data/test/stripe/stripe_response_test.rb +0 -95
  152. data/test/stripe/subscription_item_test.rb +0 -84
  153. data/test/stripe/subscription_schedule_test.rb +0 -82
  154. data/test/stripe/subscription_test.rb +0 -80
  155. data/test/stripe/tax_id_test.rb +0 -31
  156. data/test/stripe/tax_rate_test.rb +0 -43
  157. data/test/stripe/terminal/connection_token_test.rb +0 -16
  158. data/test/stripe/terminal/location_test.rb +0 -68
  159. data/test/stripe/terminal/reader_test.rb +0 -62
  160. data/test/stripe/three_d_secure_test.rb +0 -23
  161. data/test/stripe/topup_test.rb +0 -62
  162. data/test/stripe/transfer_test.rb +0 -88
  163. data/test/stripe/usage_record_summary_test.rb +0 -29
  164. data/test/stripe/util_test.rb +0 -402
  165. data/test/stripe/webhook_endpoint_test.rb +0 -59
  166. data/test/stripe/webhook_test.rb +0 -135
  167. data/test/stripe_mock.rb +0 -78
  168. data/test/stripe_test.rb +0 -119
  169. data/test/test_data.rb +0 -61
  170. data/test/test_helper.rb +0 -75
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 904e51a8673243fee242bfac79daeeb93aa5f3333ae0a70dbafc7aac55f87d90
4
- data.tar.gz: e4d11976d87cdae6b9cbf3f62379effa07a719e244b81d4c3cc1914a5be3ccd1
3
+ metadata.gz: 7e81cc3af76a8942f879c1b312bbcc6ad27257cb9b68f9a63df76bd430ff9cf8
4
+ data.tar.gz: c83f7ae353941a10279ba76237f64e700f0e6bce06fe9475250b85308f72d57f
5
5
  SHA512:
6
- metadata.gz: 1c130372f29afb9cf4bae86d2608a537aae2302cf342dfc152b018ac71a787053977dcb7e0a5e044e518b7feb1fa67f2932de67cbb24cb82c9d7e946890503de
7
- data.tar.gz: a91d6654370dc3a187e159cd49f4546ebe11b0f00e96b165b06f010b639d4213681393426a6ea40b4c768db6b6bf337307be5408d4d987f5ac616ff6817a6960
6
+ metadata.gz: 4b4aff3650ae5933a0fae274bf1fe1e142f8361fbd0b3734502ce317a82492bda2124e155ff335b311abbda1d9751fdbc15e4a1754c94fe8b6d8a24e206b599e
7
+ data.tar.gz: f23307331d6ded3934361f9fff180a0ecda5df30bb3f5708e359d3b0712ed5262873b2220400d124544b113249a7ff5f1ae885cef381b9a8b3aa6388295527a7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,131 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.55.0 - 2022-05-05
4
+ * [#1055](https://github.com/stripe/stripe-ruby/pull/1055) API Updates
5
+ * Add support for new resources `FinancialConnections.AccountOwner`, `FinancialConnections.AccountOwnership`, `FinancialConnections.Account`, and `FinancialConnections.Session`
6
+
7
+
8
+ ## 5.54.0 - 2022-05-03
9
+ * [#1053](https://github.com/stripe/stripe-ruby/pull/1053) API Updates
10
+ * Add support for new resource `CashBalance`
11
+
12
+ ## 5.53.0 - 2022-04-21
13
+ * [#1050](https://github.com/stripe/stripe-ruby/pull/1050) API Updates
14
+ * Add support for `expire` test helper method on resource `Refund`
15
+
16
+ ## 5.52.0 - 2022-04-18
17
+ * [#1046](https://github.com/stripe/stripe-ruby/pull/1046) [#1047](https://github.com/stripe/stripe-ruby/pull/1047) API Updates
18
+ * Add support for new resources `FundingInstructions` and `Terminal.Configuration`
19
+
20
+ ## 5.51.0 - 2022-04-15
21
+ * [#1046](https://github.com/stripe/stripe-ruby/pull/1046) This release was incomplete and was yanked from RubyGems immediately after it was published.
22
+
23
+ ## 5.50.0 - 2022-04-13
24
+ * [#1045](https://github.com/stripe/stripe-ruby/pull/1045) API Updates
25
+ * Add support for `increment_authorization` method on resource `PaymentIntent`
26
+
27
+ ## 5.49.0 - 2022-04-08
28
+ * [#1043](https://github.com/stripe/stripe-ruby/pull/1043) API Updates
29
+ * Add support for `apply_customer_balance` method on resource `PaymentIntent`
30
+
31
+ ## 5.48.0 - 2022-03-30
32
+ * [#1041](https://github.com/stripe/stripe-ruby/pull/1041) API Updates
33
+ * Add support for `cancel_action`, `process_payment_intent`, `process_setup_intent`, and `set_reader_display` methods on resource `Terminal.Reader`
34
+
35
+ ## 5.47.0 - 2022-03-29
36
+ * [#1040](https://github.com/stripe/stripe-ruby/pull/1040) API Updates
37
+ * Add support for Search API
38
+ * Add support for `search` method on resources `Charge`, `Customer`, `Invoice`, `PaymentIntent`, `Price`, `Product`, and `Subscription`
39
+
40
+ * [#1034](https://github.com/stripe/stripe-ruby/pull/1034) Add supporting classes for test helper generation
41
+
42
+ ## 5.46.0 - 2022-03-23
43
+ * [#1039](https://github.com/stripe/stripe-ruby/pull/1039) API Updates
44
+ * Add support for `cancel` method on resource `Refund`
45
+ * [#992](https://github.com/stripe/stripe-ruby/pull/992) Add support for Search API
46
+
47
+ ## 5.45.0 - 2022-03-01
48
+ * [#1035](https://github.com/stripe/stripe-ruby/pull/1035) API Updates
49
+ * Add support for new resource `TestHelpers.TestClock`
50
+
51
+ ## 5.44.0 - 2022-02-16
52
+ * [#1032](https://github.com/stripe/stripe-ruby/pull/1032) API Updates
53
+ * Add support for `verify_microdeposits` method on resources `PaymentIntent` and `SetupIntent`
54
+
55
+ ## 5.43.0 - 2022-01-20
56
+ * [#1031](https://github.com/stripe/stripe-ruby/pull/1031) API Updates
57
+ * Add support for new resource `PaymentLink`
58
+
59
+ ## 5.42.0 - 2021-12-13
60
+ * [#1022](https://github.com/stripe/stripe-ruby/pull/1022) Add connection manager logging and include object IDs in logging.
61
+
62
+ ## 5.41.0 - 2021-11-16
63
+ * [#1017](https://github.com/stripe/stripe-ruby/pull/1017) API Updates
64
+ * Add support for new resource `ShippingRate`
65
+
66
+ ## 5.40.0 - 2021-11-11
67
+ * [#1015](https://github.com/stripe/stripe-ruby/pull/1015) API Updates
68
+ * Add support for `expire` method on resource `Checkout.Session`
69
+ * [#1013](https://github.com/stripe/stripe-ruby/pull/1013) Add tests for child resources.
70
+ * [#1012](https://github.com/stripe/stripe-ruby/pull/1012) Add tests for namespaced resources.
71
+ * [#1011](https://github.com/stripe/stripe-ruby/pull/1011) codegen: 3 more files
72
+
73
+ ## 5.39.0 - 2021-10-11
74
+ * [#1010](https://github.com/stripe/stripe-ruby/pull/1010) API Updates
75
+ * Add support for `list_payment_methods` method on resource `Customer`
76
+
77
+ ## 5.38.0 - 2021-08-10
78
+ * [#993](https://github.com/stripe/stripe-ruby/pull/993) Add `request_id` to RequestEndEvent
79
+ * [#991](https://github.com/stripe/stripe-ruby/pull/991) Codegen more files
80
+ * [#989](https://github.com/stripe/stripe-ruby/pull/989) Remove unused API error types from docs.
81
+
82
+ ## 5.37.0 - 2021-07-14
83
+ * [#988](https://github.com/stripe/stripe-ruby/pull/988) API Updates
84
+ * Add support for `list_computed_upfront_line_items` method on resource `Quote`
85
+
86
+ ## 5.36.0 - 2021-07-09
87
+ * [#987](https://github.com/stripe/stripe-ruby/pull/987) Add support for `Quote` API
88
+
89
+ ## 5.35.0 - 2021-06-30
90
+ * [#985](https://github.com/stripe/stripe-ruby/pull/985) Update normalize_opts to use dup instead of clone.
91
+ * [#982](https://github.com/stripe/stripe-ruby/pull/982) Deprecate travis
92
+ * [#983](https://github.com/stripe/stripe-ruby/pull/983) Add support for making a request and receiving the response as a stream.
93
+
94
+ ## 5.34.0 - 2021-06-04
95
+ * [#981](https://github.com/stripe/stripe-ruby/pull/981) API Updates
96
+ * Add support for `TaxCode` API.
97
+
98
+ ## 5.33.0 - 2021-05-19
99
+ * [#979](https://github.com/stripe/stripe-ruby/pull/979) Add support for the Identify VerificationSession and VerificationReport APIs
100
+
101
+ ## 5.32.1 - 2021-04-05
102
+ * Correct use of regexp `match` in gemspec for old versions of Ruby
103
+
104
+ ## 5.32.0 - 2021-04-05
105
+ * [#973](https://github.com/stripe/stripe-ruby/pull/973) Reduce packed gem size
106
+
107
+ ## 5.31.0 - 2021-04-02
108
+ * [#968](https://github.com/stripe/stripe-ruby/pull/968) Allow StripeClient to be configured per instance
109
+ * [#971](https://github.com/stripe/stripe-ruby/pull/971) On config change, only clear connection managers for changed config
110
+ * [#972](https://github.com/stripe/stripe-ruby/pull/972) Rename `Stripe.configuration` to `Stripe.config`
111
+ * [#970](https://github.com/stripe/stripe-ruby/pull/970) Reserve some critical field names when adding `StripeObject` accessors
112
+ * [#967](https://github.com/stripe/stripe-ruby/pull/967) CI: github actions
113
+
114
+ ## 5.30.0 - 2021-02-22
115
+ * [#965](https://github.com/stripe/stripe-ruby/pull/965) Add support for the Billing Portal Configuration API
116
+
117
+ ## 5.29.1 - 2021-02-09
118
+ * [#964](https://github.com/stripe/stripe-ruby/pull/964) Fix return value of `Customer#delete_discount`
119
+
120
+ ## 5.29.0 - 2021-01-05
121
+ * [#952](https://github.com/stripe/stripe-ruby/pull/952) Allow client_id configuration on instance config
122
+
123
+ ## 5.28.0 - 2020-10-14
124
+ * [#950](https://github.com/stripe/stripe-ruby/pull/950) Add configuration option for `write_timeout` for connections on Ruby 2.6+
125
+
126
+ ## 5.27.0 - 2020-10-14
127
+ * [#951](https://github.com/stripe/stripe-ruby/pull/951) Add support for the Payout Reverse API
128
+
3
129
  ## 5.26.0 - 2020-09-29
4
130
  * [#949](https://github.com/stripe/stripe-ruby/pull/949) Add support for the `SetupAttempt` resource and List API
5
131
 
data/Gemfile CHANGED
@@ -5,7 +5,6 @@ source "https://rubygems.org"
5
5
  gemspec
6
6
 
7
7
  group :development do
8
- gem "coveralls", require: false
9
8
  gem "mocha", "~> 0.13.2"
10
9
  gem "rack", ">= 2.0.6"
11
10
  gem "rake"
data/Makefile ADDED
@@ -0,0 +1,7 @@
1
+ .PHONY: update-version codegen-format
2
+ update-version:
3
+ @echo "$(VERSION)" > VERSION
4
+ @perl -pi -e 's|VERSION = "[.\d]+"|VERSION = "$(VERSION)"|' lib/stripe/version.rb
5
+
6
+ codegen-format:
7
+ bundle exec rubocop -o /dev/null --auto-correct
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/stripe.svg)](https://badge.fury.io/rb/stripe)
4
4
  [![Build Status](https://travis-ci.org/stripe/stripe-ruby.svg?branch=master)](https://travis-ci.org/stripe/stripe-ruby)
5
- [![Coverage Status](https://coveralls.io/repos/github/stripe/stripe-ruby/badge.svg?branch=master)](https://coveralls.io/github/stripe/stripe-ruby?branch=master)
6
5
 
7
6
  The Stripe Ruby library provides convenient access to the Stripe API from
8
7
  applications written in the Ruby language. It includes a pre-defined set of
@@ -19,7 +18,10 @@ The library also provides other features. For example:
19
18
 
20
19
  ## Documentation
21
20
 
22
- See the [Ruby API docs](https://stripe.com/docs/api/ruby#intro).
21
+ See the [Ruby API docs](https://stripe.com/docs/api?lang=ruby).
22
+
23
+ See [video demonstrations][youtube-playlist] covering how to use the library.
24
+
23
25
 
24
26
  ## Installation
25
27
 
@@ -186,11 +188,12 @@ retries are safe.
186
188
 
187
189
  ### Configuring Timeouts
188
190
 
189
- Open and read timeouts are configurable:
191
+ Open, read and write timeouts are configurable:
190
192
 
191
193
  ```ruby
192
194
  Stripe.open_timeout = 30 # in seconds
193
195
  Stripe.read_timeout = 80
196
+ Stripe.write_timeout = 30 # only supported on Ruby 2.6+
194
197
  ```
195
198
 
196
199
  Please take care to set conservative read timeouts. Some API requests can take
@@ -249,6 +252,7 @@ a success or error. Receives `RequestEndEvent` with the following properties:
249
252
  - `path`: Request path. (`String`)
250
253
  - `user_data`: A hash on which users may have set arbitrary data in
251
254
  `request_begin`. See above for more information. (`Hash`)
255
+ - `request_id`. HTTP request identifier.
252
256
 
253
257
  #### Example
254
258
 
@@ -336,9 +340,10 @@ Update the bundled [stripe-mock] by editing the version number found in
336
340
  [api-keys]: https://dashboard.stripe.com/account/apikeys
337
341
  [connect]: https://stripe.com/connect
338
342
  [curl]: http://curl.haxx.se/docs/caextract.html
339
- [idempotency-keys]: https://stripe.com/docs/api/ruby#idempotent_requests
343
+ [idempotency-keys]: https://stripe.com/docs/api/idempotent_requests?lang=ruby
340
344
  [stripe-mock]: https://github.com/stripe/stripe-mock
341
- [versioning]: https://stripe.com/docs/api/ruby#versioning
345
+ [versioning]: https://stripe.com/docs/api/versioning?lang=ruby
346
+ [youtube-playlist]: https://www.youtube.com/playlist?list=PLy1nL-pvL2M50RmP6ie-gdcSnfOuQCRYk
342
347
 
343
348
  <!--
344
349
  # vim: set tw=79:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.26.0
1
+ 5.55.0
@@ -6,6 +6,28 @@ module Stripe
6
6
  module ClassMethods
7
7
  def execute_resource_request(method, url,
8
8
  params = {}, opts = {})
9
+ execute_resource_request_internal(
10
+ :execute_request, method, url, params, opts
11
+ )
12
+ end
13
+
14
+ def execute_resource_request_stream(method, url,
15
+ params = {}, opts = {},
16
+ &read_body_chunk_block)
17
+ execute_resource_request_internal(
18
+ :execute_request_stream,
19
+ method,
20
+ url,
21
+ params,
22
+ opts,
23
+ &read_body_chunk_block
24
+ )
25
+ end
26
+
27
+ private def execute_resource_request_internal(client_request_method_sym,
28
+ method, url,
29
+ params, opts,
30
+ &read_body_chunk_block)
9
31
  params ||= {}
10
32
 
11
33
  error_on_invalid_params(params)
@@ -22,10 +44,12 @@ module Stripe
22
44
  client = headers.delete(:client)
23
45
  # Assume all remaining opts must be headers
24
46
 
25
- resp, opts[:api_key] = client.execute_request(
47
+ resp, opts[:api_key] = client.send(
48
+ client_request_method_sym,
26
49
  method, url,
27
50
  api_base: api_base, api_key: api_key,
28
- headers: headers, params: params
51
+ headers: headers, params: params,
52
+ &read_body_chunk_block
29
53
  )
30
54
 
31
55
  # Hash#select returns an array before 1.9
@@ -89,6 +113,15 @@ module Stripe
89
113
  self.class.execute_resource_request(method, url, params, opts)
90
114
  end
91
115
 
116
+ protected def execute_resource_request_stream(method, url,
117
+ params = {}, opts = {},
118
+ &read_body_chunk_block)
119
+ opts = @opts.merge(Util.normalize_opts(opts))
120
+ self.class.execute_resource_request_stream(
121
+ method, url, params, opts, &read_body_chunk_block
122
+ )
123
+ end
124
+
92
125
  # See notes on `alias` above.
93
126
  alias request execute_resource_request
94
127
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stripe
4
+ module APIOperations
5
+ module Search
6
+ def _search(search_url, filters = {}, opts = {})
7
+ opts = Util.normalize_opts(opts)
8
+
9
+ resp, opts = execute_resource_request(:get, search_url, filters, opts)
10
+ obj = SearchResultObject.construct_from(resp.data, opts)
11
+
12
+ # set filters so that we can fetch the same limit and query
13
+ # when accessing the next page
14
+ obj.filters = filters.dup
15
+ obj
16
+ end
17
+ end
18
+ end
19
+ end
@@ -63,22 +63,7 @@ module Stripe
63
63
  # adds a `capture` class method to the resource class that, when called,
64
64
  # will send a POST request to `/v1/<object_name>/capture`.
65
65
  def self.custom_method(name, http_verb:, http_path: nil)
66
- unless %i[get post delete].include?(http_verb)
67
- raise ArgumentError,
68
- "Invalid http_verb value: #{http_verb.inspect}. Should be one " \
69
- "of :get, :post or :delete."
70
- end
71
- http_path ||= name.to_s
72
- define_singleton_method(name) do |id, params = {}, opts = {}|
73
- unless id.is_a?(String)
74
- raise ArgumentError,
75
- "id should be a string representing the ID of an API resource"
76
- end
77
-
78
- url = "#{resource_url}/#{CGI.escape(id)}/#{CGI.escape(http_path)}"
79
- resp, opts = execute_resource_request(http_verb, url, params, opts)
80
- Util.convert_to_stripe_object(resp.data, opts)
81
- end
66
+ Util.custom_method self, self, name, http_verb, http_path
82
67
  end
83
68
 
84
69
  def resource_url
@@ -105,7 +90,7 @@ module Stripe
105
90
  instance
106
91
  end
107
92
 
108
- protected def request_stripe_object(method:, path:, params:, opts: {})
93
+ def request_stripe_object(method:, path:, params:, opts: {})
109
94
  resp, opts = execute_resource_request(method, path, params, opts)
110
95
 
111
96
  # If we're getting back this thing, update; otherwise, instantiate.
@@ -115,5 +100,13 @@ module Stripe
115
100
  Util.convert_to_stripe_object(resp.data, opts)
116
101
  end
117
102
  end
103
+
104
+ protected def request_stream(method:, path:, params:, opts: {},
105
+ &read_body_chunk_block)
106
+ resp, = execute_resource_request_stream(
107
+ method, path, params, opts, &read_body_chunk_block
108
+ )
109
+ resp
110
+ end
118
111
  end
119
112
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stripe
4
+ # The base class for nested TestHelpers classes in resource objects.
5
+ # The APIResourceTestHelpers handles URL generation and custom method
6
+ # support for test-helper methods.
7
+ #
8
+ # class MyAPIResource < APIResource
9
+ # class TestHelpers < APIResourceTestHelpers
10
+ class APIResourceTestHelpers
11
+ def initialize(resource)
12
+ @resource = resource
13
+ end
14
+
15
+ # Adds a custom method to a test helper. This is used to add support for
16
+ # non-CRUDL API requests, e.g. capturing charges. custom_method takes the
17
+ # following parameters:
18
+ # - name: the name of the custom method to create (as a symbol)
19
+ # - http_verb: the HTTP verb for the API request (:get, :post, or :delete)
20
+ # - http_path: the path to append to the resource's URL. If not provided,
21
+ # the name is used as the path
22
+ #
23
+ # For example, this call:
24
+ # custom_method :capture, http_verb: post
25
+ # adds a `capture` class method to the resource class that, when called,
26
+ # will send a POST request to `/v1/<object_name>/capture`.
27
+ def self.custom_method(name, http_verb:, http_path: nil)
28
+ Util.custom_method self::RESOURCE_CLASS, self, name, http_verb, http_path
29
+ end
30
+
31
+ def self.resource_url
32
+ "/v1/test_helpers/"\
33
+ "#{self::RESOURCE_CLASS::OBJECT_NAME.downcase.tr('.', '/')}s"
34
+ end
35
+
36
+ def resource_url
37
+ unless (id = @resource["id"])
38
+ raise InvalidRequestError.new(
39
+ "Could not determine which URL to request: #{self.class} instance " \
40
+ "has invalid ID: #{id.inspect}",
41
+ "id"
42
+ )
43
+ end
44
+ "#{self.class.resource_url}/#{CGI.escape(id)}"
45
+ end
46
+ end
47
+ end
@@ -15,8 +15,10 @@ module Stripe
15
15
  # by `StripeClient` to determine whether a connection manager should be
16
16
  # garbage collected or not.
17
17
  attr_reader :last_used
18
+ attr_reader :config
18
19
 
19
- def initialize
20
+ def initialize(config = Stripe.config)
21
+ @config = config
20
22
  @active_connections = {}
21
23
  @last_used = Util.monotonic_time
22
24
 
@@ -64,7 +66,8 @@ module Stripe
64
66
 
65
67
  # Executes an HTTP request to the given URI with the given method. Also
66
68
  # allows a request body, headers, and query string to be specified.
67
- def execute_request(method, uri, body: nil, headers: nil, query: nil)
69
+ def execute_request(method, uri, body: nil, headers: nil, query: nil,
70
+ &block)
68
71
  # Perform some basic argument validation because it's easy to get
69
72
  # confused between strings and hashes for things like body and query
70
73
  # parameters.
@@ -90,9 +93,44 @@ module Stripe
90
93
  u.path
91
94
  end
92
95
 
93
- @mutex.synchronize do
94
- connection.send_request(method.to_s.upcase, path, body, headers)
96
+ method_name = method.to_s.upcase
97
+ has_response_body = method_name != "HEAD"
98
+ request = Net::HTTPGenericRequest.new(
99
+ method_name,
100
+ (body ? true : false),
101
+ has_response_body,
102
+ path,
103
+ headers
104
+ )
105
+
106
+ Util.log_debug("ConnectionManager starting request",
107
+ method_name: method_name,
108
+ path: path,
109
+ process_id: Process.pid,
110
+ thread_object_id: Thread.current.object_id,
111
+ connection_manager_object_id: object_id,
112
+ connection_object_id: connection.object_id,
113
+ log_timestamp: Util.monotonic_time)
114
+
115
+ resp = @mutex.synchronize do
116
+ # The block parameter is special here. If a block is provided, the block
117
+ # is invoked with the Net::HTTPResponse. However, the body will not have
118
+ # been read yet in the block, and can be streamed by calling
119
+ # HTTPResponse#read_body.
120
+ connection.request(request, body, &block)
95
121
  end
122
+
123
+ Util.log_debug("ConnectionManager request complete",
124
+ method_name: method_name,
125
+ path: path,
126
+ process_id: Process.pid,
127
+ thread_object_id: Thread.current.object_id,
128
+ connection_manager_object_id: object_id,
129
+ connection_object_id: connection.object_id,
130
+ response_object_id: resp.object_id,
131
+ log_timestamp: Util.monotonic_time)
132
+
133
+ resp
96
134
  end
97
135
 
98
136
  #
@@ -117,14 +155,17 @@ module Stripe
117
155
  # reused Go's default for `DefaultTransport`.
118
156
  connection.keep_alive_timeout = 30
119
157
 
120
- connection.open_timeout = Stripe.open_timeout
121
- connection.read_timeout = Stripe.read_timeout
158
+ connection.open_timeout = config.open_timeout
159
+ connection.read_timeout = config.read_timeout
160
+ if connection.respond_to?(:write_timeout=)
161
+ connection.write_timeout = config.write_timeout
162
+ end
122
163
 
123
164
  connection.use_ssl = uri.scheme == "https"
124
165
 
125
- if Stripe.verify_ssl_certs
166
+ if config.verify_ssl_certs
126
167
  connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
127
- connection.cert_store = Stripe.ca_store
168
+ connection.cert_store = config.ca_store
128
169
  else
129
170
  connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
130
171
  warn_ssl_verify_none
@@ -138,10 +179,10 @@ module Stripe
138
179
  # out those pieces to make passing them into a new connection a little less
139
180
  # ugly.
140
181
  private def proxy_parts
141
- if Stripe.proxy.nil?
182
+ if config.proxy.nil?
142
183
  [nil, nil, nil, nil]
143
184
  else
144
- u = URI.parse(Stripe.proxy)
185
+ u = URI.parse(config.proxy)
145
186
  [u.host, u.port, u.user, u.password]
146
187
  end
147
188
  end
@@ -69,9 +69,8 @@ module Stripe
69
69
  @values[:source]
70
70
  end
71
71
 
72
- # The type of error returned. One of `api_connection_error`, `api_error`,
73
- # `authentication_error`, `card_error`, `idempotency_error`,
74
- # `invalid_request_error`, or `rate_limit_error`.
72
+ # The type of error returned. One of `api_error`, `card_error`,
73
+ # `idempotency_error`, or `invalid_request_error`.
75
74
  def type
76
75
  @values[:type]
77
76
  end
@@ -32,6 +32,7 @@ module Stripe
32
32
  attr_reader :method
33
33
  attr_reader :num_retries
34
34
  attr_reader :path
35
+ attr_reader :request_id
35
36
 
36
37
  # Arbitrary user-provided data in the form of a Ruby hash that's passed
37
38
  # from subscribers on `request_begin` to subscribers on `request_end`.
@@ -40,12 +41,13 @@ module Stripe
40
41
  attr_reader :user_data
41
42
 
42
43
  def initialize(duration:, http_status:, method:, num_retries:, path:,
43
- user_data: nil)
44
+ request_id:, user_data: nil)
44
45
  @duration = duration
45
46
  @http_status = http_status
46
47
  @method = method
47
48
  @num_retries = num_retries
48
49
  @path = path
50
+ @request_id = request_id
49
51
  @user_data = user_data
50
52
  freeze
51
53
  end
data/lib/stripe/oauth.rb CHANGED
@@ -7,8 +7,8 @@ module Stripe
7
7
 
8
8
  def self.execute_resource_request(method, url, params, opts)
9
9
  opts = Util.normalize_opts(opts)
10
- opts[:client] ||= StripeClient.active_client
11
- opts[:api_base] ||= Stripe.connect_base
10
+ opts[:client] ||= opts[:client] || StripeClient.active_client
11
+ opts[:api_base] ||= opts[:client].config.connect_base
12
12
 
13
13
  super(method, url, params, opts)
14
14
  end
@@ -29,7 +29,8 @@ module Stripe
29
29
  end
30
30
 
31
31
  def self.authorize_url(params = {}, opts = {})
32
- base = opts[:connect_base] || Stripe.connect_base
32
+ client = opts[:client] || StripeClient.active_client
33
+ base = opts[:connect_base] || client.config.connect_base
33
34
 
34
35
  path = "/oauth/authorize"
35
36
  path = "/express" + path if opts[:express]
@@ -1,3 +1,4 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  # rubocop:disable Metrics/MethodLength
@@ -8,6 +9,7 @@ module Stripe
8
9
  {
9
10
  # data structures
10
11
  ListObject::OBJECT_NAME => ListObject,
12
+ SearchResultObject::OBJECT_NAME => SearchResultObject,
11
13
 
12
14
  # business objects
13
15
  Account::OBJECT_NAME => Account,
@@ -19,11 +21,13 @@ module Stripe
19
21
  Balance::OBJECT_NAME => Balance,
20
22
  BalanceTransaction::OBJECT_NAME => BalanceTransaction,
21
23
  BankAccount::OBJECT_NAME => BankAccount,
24
+ BillingPortal::Configuration::OBJECT_NAME => BillingPortal::Configuration,
22
25
  BillingPortal::Session::OBJECT_NAME => BillingPortal::Session,
23
26
  BitcoinReceiver::OBJECT_NAME => BitcoinReceiver,
24
27
  BitcoinTransaction::OBJECT_NAME => BitcoinTransaction,
25
28
  Capability::OBJECT_NAME => Capability,
26
29
  Card::OBJECT_NAME => Card,
30
+ CashBalance::OBJECT_NAME => CashBalance,
27
31
  Charge::OBJECT_NAME => Charge,
28
32
  Checkout::Session::OBJECT_NAME => Checkout::Session,
29
33
  CountrySpec::OBJECT_NAME => CountrySpec,
@@ -40,6 +44,14 @@ module Stripe
40
44
  File::OBJECT_NAME => File,
41
45
  File::OBJECT_NAME_ALT => File,
42
46
  FileLink::OBJECT_NAME => FileLink,
47
+ FinancialConnections::Account::OBJECT_NAME => FinancialConnections::Account,
48
+ FinancialConnections::AccountOwner::OBJECT_NAME => FinancialConnections::AccountOwner,
49
+ FinancialConnections::AccountOwnership::OBJECT_NAME =>
50
+ FinancialConnections::AccountOwnership,
51
+ FinancialConnections::Session::OBJECT_NAME => FinancialConnections::Session,
52
+ FundingInstructions::OBJECT_NAME => FundingInstructions,
53
+ Identity::VerificationReport::OBJECT_NAME => Identity::VerificationReport,
54
+ Identity::VerificationSession::OBJECT_NAME => Identity::VerificationSession,
43
55
  Invoice::OBJECT_NAME => Invoice,
44
56
  InvoiceItem::OBJECT_NAME => InvoiceItem,
45
57
  InvoiceLineItem::OBJECT_NAME => InvoiceLineItem,
@@ -55,6 +67,7 @@ module Stripe
55
67
  Order::OBJECT_NAME => Order,
56
68
  OrderReturn::OBJECT_NAME => OrderReturn,
57
69
  PaymentIntent::OBJECT_NAME => PaymentIntent,
70
+ PaymentLink::OBJECT_NAME => PaymentLink,
58
71
  PaymentMethod::OBJECT_NAME => PaymentMethod,
59
72
  Payout::OBJECT_NAME => Payout,
60
73
  Person::OBJECT_NAME => Person,
@@ -62,6 +75,7 @@ module Stripe
62
75
  Price::OBJECT_NAME => Price,
63
76
  Product::OBJECT_NAME => Product,
64
77
  PromotionCode::OBJECT_NAME => PromotionCode,
78
+ Quote::OBJECT_NAME => Quote,
65
79
  Radar::EarlyFraudWarning::OBJECT_NAME => Radar::EarlyFraudWarning,
66
80
  Radar::ValueList::OBJECT_NAME => Radar::ValueList,
67
81
  Radar::ValueListItem::OBJECT_NAME => Radar::ValueListItem,
@@ -72,20 +86,24 @@ module Stripe
72
86
  Reporting::ReportType::OBJECT_NAME => Reporting::ReportType,
73
87
  Reversal::OBJECT_NAME => Reversal,
74
88
  Review::OBJECT_NAME => Review,
75
- SKU::OBJECT_NAME => SKU,
76
89
  SetupAttempt::OBJECT_NAME => SetupAttempt,
77
90
  SetupIntent::OBJECT_NAME => SetupIntent,
91
+ ShippingRate::OBJECT_NAME => ShippingRate,
78
92
  Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun,
93
+ SKU::OBJECT_NAME => SKU,
79
94
  Source::OBJECT_NAME => Source,
80
95
  SourceTransaction::OBJECT_NAME => SourceTransaction,
81
96
  Subscription::OBJECT_NAME => Subscription,
82
97
  SubscriptionItem::OBJECT_NAME => SubscriptionItem,
83
98
  SubscriptionSchedule::OBJECT_NAME => SubscriptionSchedule,
99
+ TaxCode::OBJECT_NAME => TaxCode,
84
100
  TaxId::OBJECT_NAME => TaxId,
85
101
  TaxRate::OBJECT_NAME => TaxRate,
102
+ Terminal::Configuration::OBJECT_NAME => Terminal::Configuration,
86
103
  Terminal::ConnectionToken::OBJECT_NAME => Terminal::ConnectionToken,
87
104
  Terminal::Location::OBJECT_NAME => Terminal::Location,
88
105
  Terminal::Reader::OBJECT_NAME => Terminal::Reader,
106
+ TestHelpers::TestClock::OBJECT_NAME => TestHelpers::TestClock,
89
107
  ThreeDSecure::OBJECT_NAME => ThreeDSecure,
90
108
  Token::OBJECT_NAME => Token,
91
109
  Topup::OBJECT_NAME => Topup,
@@ -45,12 +45,8 @@ module Stripe
45
45
  end
46
46
 
47
47
  # @override To make id optional
48
- def self.retrieve(id = ARGUMENT_NOT_PROVIDED, opts = {})
49
- id = if id.equal?(ARGUMENT_NOT_PROVIDED)
50
- nil
51
- else
52
- Util.check_string_argument!(id)
53
- end
48
+ def self.retrieve(id = nil, opts = {})
49
+ Util.check_string_argument!(id) if id
54
50
 
55
51
  # Account used to be a singleton, where this method's signature was
56
52
  # `(opts={})`. For the sake of not breaking folks who pass in an OAuth
@@ -136,11 +132,10 @@ module Stripe
136
132
  client_id: client_id,
137
133
  stripe_user_id: id,
138
134
  }
135
+ opts = @opts.merge(Util.normalize_opts(opts))
139
136
  OAuth.deauthorize(params, opts)
140
137
  end
141
138
 
142
- ARGUMENT_NOT_PROVIDED = Object.new
143
-
144
139
  private def serialize_additional_owners(legal_entity, additional_owners)
145
140
  original_value =
146
141
  legal_entity