stripe 10.1.0 → 12.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +215 -21
  3. data/Gemfile +6 -5
  4. data/Makefile +8 -1
  5. data/OPENAPI_VERSION +1 -1
  6. data/README.md +46 -14
  7. data/Rakefile +7 -5
  8. data/VERSION +1 -1
  9. data/{bin → exe}/stripe-console +1 -1
  10. data/lib/stripe/api_operations/nested_resource.rb +22 -2
  11. data/lib/stripe/api_operations/request.rb +22 -18
  12. data/lib/stripe/api_operations/save.rb +7 -9
  13. data/lib/stripe/api_operations/search.rb +5 -0
  14. data/lib/stripe/api_operations/singleton_save.rb +86 -0
  15. data/lib/stripe/api_resource.rb +13 -4
  16. data/lib/stripe/api_resource_test_helpers.rb +7 -3
  17. data/lib/stripe/api_version.rb +1 -1
  18. data/lib/stripe/connection_manager.rb +4 -6
  19. data/lib/stripe/errors.rb +3 -11
  20. data/lib/stripe/instrumentation.rb +5 -21
  21. data/lib/stripe/list_object.rb +3 -0
  22. data/lib/stripe/multipart_encoder.rb +7 -7
  23. data/lib/stripe/oauth.rb +6 -6
  24. data/lib/stripe/object_types.rb +135 -116
  25. data/lib/stripe/resources/account.rb +103 -25
  26. data/lib/stripe/resources/account_link.rb +8 -0
  27. data/lib/stripe/resources/account_session.rb +8 -0
  28. data/lib/stripe/resources/alipay_account.rb +1 -1
  29. data/lib/stripe/resources/apple_pay_domain.rb +43 -0
  30. data/lib/stripe/resources/application_fee.rb +8 -0
  31. data/lib/stripe/resources/application_fee_refund.rb +4 -2
  32. data/lib/stripe/resources/apps/secret.rb +15 -0
  33. data/lib/stripe/resources/balance.rb +3 -0
  34. data/lib/stripe/resources/balance_transaction.rb +15 -0
  35. data/lib/stripe/resources/bank_account.rb +49 -7
  36. data/lib/stripe/resources/billing/alert.rb +87 -0
  37. data/lib/stripe/resources/billing/meter.rb +83 -0
  38. data/lib/stripe/resources/billing/meter_event.rb +27 -0
  39. data/lib/stripe/resources/billing/meter_event_adjustment.rb +26 -0
  40. data/lib/stripe/resources/billing/meter_event_summary.rb +15 -0
  41. data/lib/stripe/resources/billing_portal/configuration.rb +33 -0
  42. data/lib/stripe/resources/billing_portal/session.rb +14 -1
  43. data/lib/stripe/resources/capability.rb +4 -2
  44. data/lib/stripe/resources/card.rb +28 -0
  45. data/lib/stripe/resources/cash_balance.rb +3 -0
  46. data/lib/stripe/resources/charge.rb +39 -1
  47. data/lib/stripe/resources/checkout/session.rb +47 -5
  48. data/lib/stripe/resources/climate/order.rb +67 -0
  49. data/lib/stripe/resources/climate/product.rb +27 -0
  50. data/lib/stripe/resources/climate/supplier.rb +26 -0
  51. data/lib/stripe/resources/confirmation_token.rb +39 -0
  52. data/lib/stripe/resources/country_spec.rb +8 -0
  53. data/lib/stripe/resources/coupon.rb +45 -0
  54. data/lib/stripe/resources/credit_note.rb +47 -7
  55. data/lib/stripe/resources/credit_note_line_item.rb +3 -0
  56. data/lib/stripe/resources/customer.rb +89 -26
  57. data/lib/stripe/resources/customer_balance_transaction.rb +3 -1
  58. data/lib/stripe/resources/customer_cash_balance_transaction.rb +3 -2
  59. data/lib/stripe/resources/customer_session.rb +29 -0
  60. data/lib/stripe/resources/discount.rb +3 -0
  61. data/lib/stripe/resources/dispute.rb +26 -0
  62. data/lib/stripe/resources/entitlements/active_entitlement.rb +26 -0
  63. data/lib/stripe/resources/entitlements/feature.rb +49 -0
  64. data/lib/stripe/resources/ephemeral_key.rb +23 -0
  65. data/lib/stripe/resources/event.rb +11 -3
  66. data/lib/stripe/resources/exchange_rate.rb +8 -0
  67. data/lib/stripe/resources/file.rb +29 -16
  68. data/lib/stripe/resources/file_link.rb +23 -0
  69. data/lib/stripe/resources/financial_connections/account.rb +66 -7
  70. data/lib/stripe/resources/financial_connections/account_owner.rb +3 -0
  71. data/lib/stripe/resources/financial_connections/account_ownership.rb +3 -0
  72. data/lib/stripe/resources/financial_connections/session.rb +13 -0
  73. data/lib/stripe/resources/financial_connections/transaction.rb +26 -0
  74. data/lib/stripe/resources/forwarding/request.rb +52 -0
  75. data/lib/stripe/resources/funding_instructions.rb +3 -0
  76. data/lib/stripe/resources/identity/verification_report.rb +14 -1
  77. data/lib/stripe/resources/identity/verification_session.rb +90 -4
  78. data/lib/stripe/resources/invoice.rb +170 -17
  79. data/lib/stripe/resources/invoice_item.rb +43 -0
  80. data/lib/stripe/resources/invoice_line_item.rb +21 -0
  81. data/lib/stripe/resources/invoice_rendering_template.rb +63 -0
  82. data/lib/stripe/resources/issuing/authorization.rb +88 -14
  83. data/lib/stripe/resources/issuing/card.rb +50 -16
  84. data/lib/stripe/resources/issuing/cardholder.rb +33 -0
  85. data/lib/stripe/resources/issuing/dispute.rb +35 -0
  86. data/lib/stripe/resources/issuing/personalization_design.rb +119 -0
  87. data/lib/stripe/resources/issuing/physical_bundle.rb +26 -0
  88. data/lib/stripe/resources/issuing/token.rb +18 -0
  89. data/lib/stripe/resources/issuing/transaction.rb +30 -0
  90. data/lib/stripe/resources/line_item.rb +3 -0
  91. data/lib/stripe/resources/login_link.rb +4 -1
  92. data/lib/stripe/resources/mandate.rb +3 -0
  93. data/lib/stripe/resources/payment_intent.rb +190 -25
  94. data/lib/stripe/resources/payment_link.rb +25 -0
  95. data/lib/stripe/resources/payment_method.rb +57 -4
  96. data/lib/stripe/resources/payment_method_configuration.rb +33 -0
  97. data/lib/stripe/resources/payment_method_domain.rb +46 -1
  98. data/lib/stripe/resources/payout.rb +39 -4
  99. data/lib/stripe/resources/person.rb +5 -4
  100. data/lib/stripe/resources/plan.rb +43 -0
  101. data/lib/stripe/resources/price.rb +24 -1
  102. data/lib/stripe/resources/product.rb +47 -1
  103. data/lib/stripe/resources/product_feature.rb +13 -0
  104. data/lib/stripe/resources/promotion_code.rb +23 -0
  105. data/lib/stripe/resources/quote.rb +67 -32
  106. data/lib/stripe/resources/radar/early_fraud_warning.rb +13 -0
  107. data/lib/stripe/resources/radar/value_list.rb +53 -0
  108. data/lib/stripe/resources/radar/value_list_item.rb +43 -0
  109. data/lib/stripe/resources/refund.rb +46 -0
  110. data/lib/stripe/resources/reporting/report_run.rb +23 -0
  111. data/lib/stripe/resources/reporting/report_type.rb +13 -0
  112. data/lib/stripe/resources/reversal.rb +5 -3
  113. data/lib/stripe/resources/review.rb +10 -0
  114. data/lib/stripe/resources/setup_attempt.rb +8 -0
  115. data/lib/stripe/resources/setup_intent.rb +72 -10
  116. data/lib/stripe/resources/shipping_rate.rb +23 -0
  117. data/lib/stripe/resources/sigma/scheduled_query_run.rb +13 -0
  118. data/lib/stripe/resources/source.rb +23 -1
  119. data/lib/stripe/resources/source_transaction.rb +3 -0
  120. data/lib/stripe/resources/subscription.rb +81 -13
  121. data/lib/stripe/resources/subscription_item.rb +54 -1
  122. data/lib/stripe/resources/subscription_schedule.rb +41 -4
  123. data/lib/stripe/resources/tax/calculation.rb +15 -0
  124. data/lib/stripe/resources/tax/calculation_line_item.rb +3 -0
  125. data/lib/stripe/resources/tax/registration.rb +35 -0
  126. data/lib/stripe/resources/tax/settings.rb +4 -2
  127. data/lib/stripe/resources/tax/transaction.rb +15 -8
  128. data/lib/stripe/resources/tax/transaction_line_item.rb +3 -0
  129. data/lib/stripe/resources/tax_code.rb +8 -0
  130. data/lib/stripe/resources/tax_id.rb +30 -12
  131. data/lib/stripe/resources/tax_rate.rb +23 -0
  132. data/lib/stripe/resources/terminal/configuration.rb +53 -0
  133. data/lib/stripe/resources/terminal/connection_token.rb +13 -0
  134. data/lib/stripe/resources/terminal/location.rb +54 -0
  135. data/lib/stripe/resources/terminal/reader.rb +80 -12
  136. data/lib/stripe/resources/test_helpers/test_clock.rb +45 -0
  137. data/lib/stripe/resources/token.rb +10 -1
  138. data/lib/stripe/resources/topup.rb +25 -0
  139. data/lib/stripe/resources/transfer.rb +26 -1
  140. data/lib/stripe/resources/treasury/credit_reversal.rb +23 -0
  141. data/lib/stripe/resources/treasury/debit_reversal.rb +23 -0
  142. data/lib/stripe/resources/treasury/financial_account.rb +42 -5
  143. data/lib/stripe/resources/treasury/financial_account_features.rb +3 -0
  144. data/lib/stripe/resources/treasury/inbound_transfer.rb +47 -11
  145. data/lib/stripe/resources/treasury/outbound_payment.rb +64 -8
  146. data/lib/stripe/resources/treasury/outbound_transfer.rb +64 -8
  147. data/lib/stripe/resources/treasury/received_credit.rb +17 -0
  148. data/lib/stripe/resources/treasury/received_debit.rb +17 -0
  149. data/lib/stripe/resources/treasury/transaction.rb +13 -0
  150. data/lib/stripe/resources/treasury/transaction_entry.rb +13 -0
  151. data/lib/stripe/resources/usage_record.rb +5 -0
  152. data/lib/stripe/resources/usage_record_summary.rb +3 -0
  153. data/lib/stripe/resources/webhook_endpoint.rb +55 -2
  154. data/lib/stripe/resources.rb +18 -0
  155. data/lib/stripe/search_result_object.rb +4 -1
  156. data/lib/stripe/singleton_api_resource.rb +20 -3
  157. data/lib/stripe/stripe_client.rb +61 -63
  158. data/lib/stripe/stripe_configuration.rb +13 -29
  159. data/lib/stripe/stripe_object.rb +23 -21
  160. data/lib/stripe/stripe_response.rb +1 -3
  161. data/lib/stripe/util.rb +13 -15
  162. data/lib/stripe/version.rb +1 -1
  163. data/lib/stripe.rb +26 -0
  164. data/stripe.gemspec +7 -4
  165. metadata +25 -5
@@ -5,14 +5,14 @@ module Stripe
5
5
  module Request
6
6
  module ClassMethods
7
7
  def execute_resource_request(method, url,
8
- params = {}, opts = {})
8
+ params = {}, opts = {}, usage = [])
9
9
  execute_resource_request_internal(
10
- :execute_request, method, url, params, opts
10
+ :execute_request, method, url, params, opts, usage
11
11
  )
12
12
  end
13
13
 
14
14
  def execute_resource_request_stream(method, url,
15
- params = {}, opts = {},
15
+ params = {}, opts = {}, usage = [],
16
16
  &read_body_chunk_block)
17
17
  execute_resource_request_internal(
18
18
  :execute_request_stream,
@@ -20,18 +20,19 @@ module Stripe
20
20
  url,
21
21
  params,
22
22
  opts,
23
+ usage,
23
24
  &read_body_chunk_block
24
25
  )
25
26
  end
26
27
 
27
- private def request_stripe_object(method:, path:, params:, opts: {})
28
- resp, opts = execute_resource_request(method, path, params, opts)
29
- Util.convert_to_stripe_object_with_params(resp.data, params, opts)
28
+ private def request_stripe_object(method:, path:, params:, opts: {}, usage: [])
29
+ resp, opts = execute_resource_request(method, path, params, opts, usage)
30
+ Util.convert_to_stripe_object_with_params(resp.data, params, opts, resp)
30
31
  end
31
32
 
32
33
  private def execute_resource_request_internal(client_request_method_sym,
33
34
  method, url,
34
- params, opts,
35
+ params, opts, usage,
35
36
  &read_body_chunk_block)
36
37
  params ||= {}
37
38
 
@@ -53,7 +54,7 @@ module Stripe
53
54
  client_request_method_sym,
54
55
  method, url,
55
56
  api_base: api_base, api_key: api_key,
56
- headers: headers, params: params,
57
+ headers: headers, params: params, usage: usage,
57
58
  &read_body_chunk_block
58
59
  )
59
60
 
@@ -66,6 +67,7 @@ module Stripe
66
67
  [resp, opts_to_persist]
67
68
  end
68
69
 
70
+ # TODO: (major)
69
71
  # This method used to be called `request`, but it's such a short name
70
72
  # that it eventually conflicted with the name of a field on an API
71
73
  # resource (specifically, `Event#request`), so it was renamed to
@@ -76,6 +78,8 @@ module Stripe
76
78
  # place for backwards compatibility. Consider removing it on the next
77
79
  # major.
78
80
  alias request execute_resource_request
81
+ extend Gem::Deprecate
82
+ deprecate :request, "Stripe.raw_request", 2024, 7
79
83
 
80
84
  private def error_on_non_string_user_opts(opts)
81
85
  Util::OPTS_USER_SPECIFIED.each do |opt|
@@ -87,7 +91,7 @@ module Stripe
87
91
 
88
92
  raise ArgumentError,
89
93
  "request option '#{opt}' should be a string value " \
90
- "(was a #{val.class})"
94
+ "(was a #{val.class})"
91
95
  end
92
96
  end
93
97
 
@@ -96,14 +100,12 @@ module Stripe
96
100
 
97
101
  raise ArgumentError,
98
102
  "request params should be either a Hash or nil " \
99
- "(was a #{params.class})"
103
+ "(was a #{params.class})"
100
104
  end
101
105
 
102
106
  private def warn_on_opts_in_params(params)
103
107
  Util::OPTS_USER_SPECIFIED.each do |opt|
104
- if params.key?(opt)
105
- warn("WARNING: '#{opt}' should be in opts instead of params.")
106
- end
108
+ warn("WARNING: '#{opt}' should be in opts instead of params.") if params.key?(opt)
107
109
  end
108
110
  end
109
111
  end
@@ -113,9 +115,9 @@ module Stripe
113
115
  end
114
116
 
115
117
  protected def execute_resource_request(method, url,
116
- params = {}, opts = {})
118
+ params = {}, opts = {}, usage = [])
117
119
  opts = @opts.merge(Util.normalize_opts(opts))
118
- self.class.execute_resource_request(method, url, params, opts)
120
+ self.class.execute_resource_request(method, url, params, opts, usage)
119
121
  end
120
122
 
121
123
  protected def execute_resource_request_stream(method, url,
@@ -127,13 +129,15 @@ module Stripe
127
129
  )
128
130
  end
129
131
 
130
- private def request_stripe_object(method:, path:, params:, opts: {})
131
- resp, opts = execute_resource_request(method, path, params, opts)
132
- Util.convert_to_stripe_object_with_params(resp.data, params, opts)
132
+ private def request_stripe_object(method:, path:, params:, opts: {}, usage: [])
133
+ resp, opts = execute_resource_request(method, path, params, opts, usage)
134
+ Util.convert_to_stripe_object_with_params(resp.data, params, opts, resp)
133
135
  end
134
136
 
135
137
  # See notes on `alias` above.
136
138
  alias request execute_resource_request
139
+ extend Gem::Deprecate
140
+ deprecate :request, "Stripe.raw_request", 2024, 7
137
141
  end
138
142
  end
139
143
  end
@@ -19,9 +19,7 @@ module Stripe
19
19
  # {APIOperations::Request.execute_resource_request}.
20
20
  def update(id, params = {}, opts = {})
21
21
  params.each_key do |k|
22
- if protected_fields.include?(k)
23
- raise ArgumentError, "Cannot update protected field: #{k}"
24
- end
22
+ raise ArgumentError, "Cannot update protected field: #{k}" if protected_fields.include?(k)
25
23
  end
26
24
 
27
25
  request_stripe_object(
@@ -64,17 +62,17 @@ module Stripe
64
62
 
65
63
  values = serialize_params(self).merge(params)
66
64
 
67
- # note that id gets removed here our call to #url above has already
65
+ # Please note that id gets removed here our call to #url above has already
68
66
  # generated a uri for this object with an identifier baked in
69
67
  values.delete(:id)
70
68
 
71
- resp, opts = execute_resource_request(:post, save_url, values, opts)
72
- initialize_from(resp.data, opts)
69
+ resp, opts = execute_resource_request(:post, save_url, values, opts, ["save"])
70
+ initialize_from(resp.data, opts, resp)
73
71
  end
74
72
  extend Gem::Deprecate
75
- deprecate :save, "the `update` class method (for examples"\
76
- " see https://github.com/stripe/stripe-ruby"\
77
- "/wiki/Migration-guide-for-v8)", 2022, 11
73
+ deprecate :save, "the `update` class method (for examples " \
74
+ "see https://github.com/stripe/stripe-ruby" \
75
+ "/wiki/Migration-guide-for-v8)", 2022, 11
78
76
 
79
77
  def self.included(base)
80
78
  # Set `metadata` as additive so that when it's set directly we remember
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Stripe
4
4
  module APIOperations
5
+ # The _search method via API Operations is deprecated.
6
+ # Please use the search method from within the resource instead.
5
7
  module Search
6
8
  def _search(search_url, filters = {}, opts = {})
7
9
  request_stripe_object(
@@ -11,6 +13,9 @@ module Stripe
11
13
  opts: opts
12
14
  )
13
15
  end
16
+
17
+ extend Gem::Deprecate
18
+ deprecate :_search, "request_stripe_object", 2024, 1
14
19
  end
15
20
  end
16
21
  end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stripe
4
+ module APIOperations
5
+ module SingletonSave
6
+ module ClassMethods
7
+ # Updates a singleton API resource
8
+ #
9
+ # Updates the identified resource with the passed in parameters.
10
+ #
11
+ # ==== Attributes
12
+ #
13
+ # * +params+ - A hash of parameters to pass to the API
14
+ # * +opts+ - A Hash of additional options (separate from the params /
15
+ # object values) to be added to the request. E.g. to allow for an
16
+ # idempotency_key to be passed in the request headers, or for the
17
+ # api_key to be overwritten. See
18
+ # {APIOperations::Request.execute_resource_request}.
19
+ def update(params = {}, opts = {})
20
+ params.each_key do |k|
21
+ raise ArgumentError, "Cannot update protected field: #{k}" if protected_fields.include?(k)
22
+ end
23
+
24
+ request_stripe_object(
25
+ method: :post,
26
+ path: resource_url,
27
+ params: params,
28
+ opts: opts
29
+ )
30
+ end
31
+ end
32
+
33
+ # The `save` method is DEPRECATED and will be removed in a future major
34
+ # version of the library. Use the `update` method on the resource instead.
35
+ #
36
+ # Updates a singleton API resource.
37
+ #
38
+ # If the resource doesn't yet have an assigned ID and the resource is one
39
+ # that can be created, then the method attempts to create the resource.
40
+ # The resource is updated otherwise.
41
+ #
42
+ # ==== Attributes
43
+ #
44
+ # * +params+ - Overrides any parameters in the resource's serialized data
45
+ # and includes them in the create or update. If +:req_url:+ is included
46
+ # in the list, it overrides the update URL used for the create or
47
+ # update.
48
+ # * +opts+ - A Hash of additional options (separate from the params /
49
+ # object values) to be added to the request. E.g. to allow for an
50
+ # idempotency_key to be passed in the request headers, or for the
51
+ # api_key to be overwritten. See
52
+ # {APIOperations::Request.execute_resource_request}.
53
+ def save(params = {}, opts = {})
54
+ # We started unintentionally (sort of) allowing attributes sent to
55
+ # +save+ to override values used during the update. So as not to break
56
+ # the API, this makes that official here.
57
+ update_attributes(params)
58
+
59
+ # Now remove any parameters that look like object attributes.
60
+ params = params.reject { |k, _| respond_to?(k) }
61
+
62
+ values = serialize_params(self).merge(params)
63
+
64
+ resp, opts = execute_resource_request(:post, resource_url, values, opts, ["save"])
65
+ initialize_from(resp.data, opts, resp)
66
+ end
67
+ extend Gem::Deprecate
68
+ deprecate :save, "the `update` class method (for examples " \
69
+ "see https://github.com/stripe/stripe-ruby" \
70
+ "/wiki/Migration-guide-for-v8)", 2022, 11
71
+
72
+ def self.included(base)
73
+ # Set `metadata` as additive so that when it's set directly we remember
74
+ # to clear keys that may have been previously set by sending empty
75
+ # values for them.
76
+ #
77
+ # It's possible that not every object with `Save` has `metadata`, but
78
+ # it's a close enough heuristic, and having this option set when there
79
+ # is no `metadata` field is not harmful.
80
+ base.additive_object_param(:metadata)
81
+
82
+ base.extend(ClassMethods)
83
+ end
84
+ end
85
+ end
86
+ end
@@ -11,6 +11,15 @@ module Stripe
11
11
  # for example, where this is allowed.
12
12
  attr_accessor :save_with_parent
13
13
 
14
+ # TODO: (major) Remove OBJECT_NAME and stop using const_get here
15
+ # This is a workaround to avoid breaking users who have defined their own
16
+ # APIResource subclasses with a custom OBJECT_NAME. We should never fallback
17
+ # on this case otherwise.
18
+ OBJECT_NAME = ""
19
+ def self.object_name
20
+ const_get(:OBJECT_NAME)
21
+ end
22
+
14
23
  def self.class_name
15
24
  name.split("::")[-1]
16
25
  end
@@ -23,7 +32,7 @@ module Stripe
23
32
  end
24
33
  # Namespaces are separated in object names with periods (.) and in URLs
25
34
  # with forward slashes (/), so replace the former with the latter.
26
- "/v1/#{self::OBJECT_NAME.downcase.tr('.', '/')}s"
35
+ "/v1/#{object_name.downcase.tr('.', '/')}s"
27
36
  end
28
37
 
29
38
  # A metaprogramming call that specifies that a field of a resource can be
@@ -80,7 +89,7 @@ module Stripe
80
89
  def refresh
81
90
  resp, opts = execute_resource_request(:get, resource_url,
82
91
  @retrieve_params)
83
- initialize_from(resp.data, opts)
92
+ initialize_from(resp.data, opts, resp)
84
93
  end
85
94
 
86
95
  def self.retrieve(id, opts = {})
@@ -95,9 +104,9 @@ module Stripe
95
104
 
96
105
  # If we're getting back this thing, update; otherwise, instantiate.
97
106
  if Util.object_name_matches_class?(resp.data[:object], self.class)
98
- initialize_from(resp.data, opts)
107
+ initialize_from(resp.data, opts, resp)
99
108
  else
100
- Util.convert_to_stripe_object_with_params(resp.data, params, opts)
109
+ Util.convert_to_stripe_object_with_params(resp.data, params, opts, resp)
101
110
  end
102
111
  end
103
112
 
@@ -14,6 +14,10 @@ module Stripe
14
14
  @resource = resource
15
15
  end
16
16
 
17
+ def self.resource_class
18
+ nil
19
+ end
20
+
17
21
  # Adds a custom method to a test helper. This is used to add support for
18
22
  # non-CRUDL API requests, e.g. capturing charges. custom_method takes the
19
23
  # following parameters:
@@ -27,12 +31,12 @@ module Stripe
27
31
  # adds a `capture` class method to the resource class that, when called,
28
32
  # will send a POST request to `/v1/<object_name>/capture`.
29
33
  def self.custom_method(name, http_verb:, http_path: nil)
30
- Util.custom_method self::RESOURCE_CLASS, self, name, http_verb, http_path
34
+ Util.custom_method resource_class, self, name, http_verb, http_path
31
35
  end
32
36
 
33
37
  def self.resource_url
34
- "/v1/test_helpers/"\
35
- "#{self::RESOURCE_CLASS::OBJECT_NAME.downcase.tr('.', '/')}s"
38
+ "/v1/test_helpers/" \
39
+ "#{resource_class.object_name.downcase.tr('.', '/')}s"
36
40
  end
37
41
 
38
42
  def resource_url
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Stripe
5
5
  module ApiVersion
6
- CURRENT = "2023-10-16"
6
+ CURRENT = "2024-06-20"
7
7
  end
8
8
  end
@@ -157,9 +157,7 @@ module Stripe
157
157
 
158
158
  connection.open_timeout = config.open_timeout
159
159
  connection.read_timeout = config.read_timeout
160
- if connection.respond_to?(:write_timeout=)
161
- connection.write_timeout = config.write_timeout
162
- end
160
+ connection.write_timeout = config.write_timeout if connection.respond_to?(:write_timeout=)
163
161
 
164
162
  connection.use_ssl = uri.scheme == "https"
165
163
 
@@ -192,9 +190,9 @@ module Stripe
192
190
 
193
191
  @verify_ssl_warned = true
194
192
  warn("WARNING: Running without SSL cert verification. " \
195
- "You should never do this in production. " \
196
- "Execute `Stripe.verify_ssl_certs = true` to enable " \
197
- "verification.")
193
+ "You should never do this in production. " \
194
+ "Execute `Stripe.verify_ssl_certs = true` to enable " \
195
+ "verification.")
198
196
  end
199
197
  end
200
198
  end
data/lib/stripe/errors.rb CHANGED
@@ -4,22 +4,14 @@ module Stripe
4
4
  # StripeError is the base error from which all other more specific Stripe
5
5
  # errors derive.
6
6
  class StripeError < StandardError
7
- attr_reader :message
7
+ attr_reader :message, :code, :error, :http_body, :http_headers, :http_status, :json_body, :request_id
8
8
 
9
9
  # Response contains a StripeResponse object that has some basic information
10
10
  # about the response that conveyed the error.
11
- attr_accessor :response
12
-
13
- attr_reader :code
14
- attr_reader :error
15
- attr_reader :http_body
16
- attr_reader :http_headers
17
- attr_reader :http_status
18
- attr_reader :json_body # equivalent to #data
19
- attr_reader :request_id
11
+ attr_accessor :response # equivalent to #data
20
12
 
21
13
  # Initializes a StripeError.
22
- def initialize(message = nil, http_status: nil, http_body: nil,
14
+ def initialize(message = nil, http_status: nil, http_body: nil, # rubocop:todo Lint/MissingSuper
23
15
  json_body: nil, http_headers: nil, code: nil)
24
16
  @message = message
25
17
  @http_status = http_status
@@ -4,8 +4,7 @@ module Stripe
4
4
  class Instrumentation
5
5
  # Event emitted on `request_begin` callback.
6
6
  class RequestBeginEvent
7
- attr_reader :method
8
- attr_reader :path
7
+ attr_reader :method, :path
9
8
 
10
9
  # Arbitrary user-provided data in the form of a Ruby hash that's passed
11
10
  # from subscribers on `request_begin` to subscribers on `request_end`.
@@ -27,16 +26,8 @@ module Stripe
27
26
 
28
27
  # Event emitted on `request_end` callback.
29
28
  class RequestEndEvent
30
- attr_reader :duration
31
- attr_reader :http_status
32
- attr_reader :method
33
- attr_reader :num_retries
34
- attr_reader :path
35
- attr_reader :request_id
36
- attr_reader :response_header
37
- attr_reader :response_body
38
- attr_reader :request_header
39
- attr_reader :request_body
29
+ attr_reader :duration, :http_status, :method, :num_retries, :path, :request_id, :response_header, :response_body,
30
+ :request_header, :request_body
40
31
 
41
32
  # Arbitrary user-provided data in the form of a Ruby hash that's passed
42
33
  # from subscribers on `request_begin` to subscribers on `request_end`.
@@ -62,12 +53,7 @@ module Stripe
62
53
  end
63
54
 
64
55
  class RequestContext
65
- attr_reader :duration
66
- attr_reader :method
67
- attr_reader :path
68
- attr_reader :request_id
69
- attr_reader :body
70
- attr_reader :header
56
+ attr_reader :duration, :method, :path, :request_id, :body, :header
71
57
 
72
58
  def initialize(duration:, context:, header:)
73
59
  @duration = duration
@@ -80,9 +66,7 @@ module Stripe
80
66
  end
81
67
 
82
68
  class ResponseContext
83
- attr_reader :http_status
84
- attr_reader :body
85
- attr_reader :header
69
+ attr_reader :http_status, :body, :header
86
70
 
87
71
  def initialize(http_status:, response:)
88
72
  @http_status = http_status
@@ -8,6 +8,9 @@ module Stripe
8
8
  include Stripe::APIOperations::Create
9
9
 
10
10
  OBJECT_NAME = "list"
11
+ def self.object_name
12
+ "list"
13
+ end
11
14
 
12
15
  # This accessor allows a `ListObject` to inherit various filters that were
13
16
  # given to a predecessor. This allows for things like consistent limits,
@@ -106,22 +106,22 @@ module Stripe
106
106
  end
107
107
 
108
108
  private def write_field(name, data, filename:)
109
- if !@first_field
110
- @body << "\r\n"
111
- else
109
+ if @first_field
112
110
  @first_field = false
111
+ else
112
+ @body << "\r\n"
113
113
  end
114
114
 
115
115
  @body << "--#{@boundary}\r\n"
116
116
 
117
117
  if filename
118
- @body << %(Content-Disposition: form-data) +
118
+ @body << (%(Content-Disposition: form-data) +
119
119
  %(; name="#{escape(name.to_s)}") +
120
- %(; filename="#{escape(filename)}"\r\n)
120
+ %(; filename="#{escape(filename)}"\r\n))
121
121
  @body << %(Content-Type: application/octet-stream\r\n)
122
122
  else
123
- @body << %(Content-Disposition: form-data) +
124
- %(; name="#{escape(name.to_s)}"\r\n)
123
+ @body << (%(Content-Disposition: form-data) +
124
+ %(; name="#{escape(name.to_s)}"\r\n))
125
125
  end
126
126
 
127
127
  @body << "\r\n"
data/lib/stripe/oauth.rb CHANGED
@@ -18,12 +18,12 @@ module Stripe
18
18
  client_id = params[:client_id] || Stripe.client_id
19
19
  unless client_id
20
20
  raise AuthenticationError, "No client_id provided. " \
21
- 'Set your client_id using "Stripe.client_id = <CLIENT-ID>". ' \
22
- "You can find your client_ids in your Stripe dashboard at " \
23
- "https://dashboard.stripe.com/account/applications/settings, " \
24
- "after registering your account as a platform. See " \
25
- "https://stripe.com/docs/connect/standalone-accounts for details, " \
26
- "or email support@stripe.com if you have any questions."
21
+ 'Set your client_id using "Stripe.client_id = <CLIENT-ID>". ' \
22
+ "You can find your client_ids in your Stripe dashboard at " \
23
+ "https://dashboard.stripe.com/account/applications/settings, " \
24
+ "after registering your account as a platform. See " \
25
+ "https://stripe.com/docs/connect/standalone-accounts for details, " \
26
+ "or email support@stripe.com if you have any questions."
27
27
  end
28
28
  client_id
29
29
  end