stripe 5.28.0 → 8.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (243) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +286 -0
  3. data/Gemfile +5 -3
  4. data/Makefile +13 -0
  5. data/OPENAPI_VERSION +1 -0
  6. data/README.md +43 -5
  7. data/VERSION +1 -1
  8. data/lib/data/ca-certificates.crt +1241 -1937
  9. data/lib/stripe/api_operations/create.rb +6 -2
  10. data/lib/stripe/api_operations/delete.rb +12 -7
  11. data/lib/stripe/api_operations/list.rb +6 -9
  12. data/lib/stripe/api_operations/nested_resource.rb +62 -34
  13. data/lib/stripe/api_operations/request.rb +45 -2
  14. data/lib/stripe/api_operations/save.rb +13 -3
  15. data/lib/stripe/api_operations/search.rb +16 -0
  16. data/lib/stripe/api_resource.rb +11 -18
  17. data/lib/stripe/api_resource_test_helpers.rb +49 -0
  18. data/lib/stripe/api_version.rb +8 -0
  19. data/lib/stripe/connection_manager.rb +49 -11
  20. data/lib/stripe/error_object.rb +2 -3
  21. data/lib/stripe/instrumentation.rb +46 -6
  22. data/lib/stripe/oauth.rb +4 -3
  23. data/lib/stripe/object_types.rb +36 -10
  24. data/lib/stripe/resources/account.rb +39 -17
  25. data/lib/stripe/resources/account_link.rb +4 -0
  26. data/lib/stripe/resources/application_fee_refund.rb +7 -1
  27. data/lib/stripe/resources/apps/secret.rb +40 -0
  28. data/lib/stripe/resources/balance.rb +11 -0
  29. data/lib/stripe/resources/balance_transaction.rb +4 -0
  30. data/lib/stripe/resources/bank_account.rb +7 -0
  31. data/lib/stripe/resources/billing_portal/configuration.rb +15 -0
  32. data/lib/stripe/resources/billing_portal/session.rb +14 -0
  33. data/lib/stripe/resources/capability.rb +5 -1
  34. data/lib/stripe/resources/card.rb +6 -3
  35. data/lib/stripe/resources/cash_balance.rb +23 -0
  36. data/lib/stripe/resources/charge.rb +23 -3
  37. data/lib/stripe/resources/checkout/session.rb +49 -2
  38. data/lib/stripe/resources/country_spec.rb +6 -0
  39. data/lib/stripe/resources/coupon.rb +3 -0
  40. data/lib/stripe/resources/credit_note.rb +27 -9
  41. data/lib/stripe/resources/credit_note_line_item.rb +2 -0
  42. data/lib/stripe/resources/customer.rb +132 -4
  43. data/lib/stripe/resources/customer_balance_transaction.rb +9 -2
  44. data/lib/stripe/resources/customer_cash_balance_transaction.rb +14 -0
  45. data/lib/stripe/resources/discount.rb +5 -0
  46. data/lib/stripe/resources/dispute.rb +17 -3
  47. data/lib/stripe/resources/event.rb +29 -0
  48. data/lib/stripe/resources/exchange_rate.rb +11 -0
  49. data/lib/stripe/resources/file.rb +9 -1
  50. data/lib/stripe/resources/file_link.rb +3 -0
  51. data/lib/stripe/resources/financial_connections/account.rb +67 -0
  52. data/lib/stripe/resources/financial_connections/account_owner.rb +11 -0
  53. data/lib/stripe/resources/financial_connections/account_ownership.rb +11 -0
  54. data/lib/stripe/resources/financial_connections/session.rb +13 -0
  55. data/lib/stripe/resources/funding_instructions.rb +21 -0
  56. data/lib/stripe/resources/identity/verification_report.rb +23 -0
  57. data/lib/stripe/resources/identity/verification_session.rb +61 -0
  58. data/lib/stripe/resources/invoice.rb +105 -17
  59. data/lib/stripe/resources/invoice_item.rb +11 -0
  60. data/lib/stripe/resources/invoice_line_item.rb +1 -0
  61. data/lib/stripe/resources/issuing/authorization.rb +25 -5
  62. data/lib/stripe/resources/issuing/card.rb +78 -8
  63. data/lib/stripe/resources/issuing/cardholder.rb +3 -0
  64. data/lib/stripe/resources/issuing/dispute.rb +13 -3
  65. data/lib/stripe/resources/issuing/transaction.rb +5 -0
  66. data/lib/stripe/resources/line_item.rb +2 -0
  67. data/lib/stripe/resources/login_link.rb +2 -0
  68. data/lib/stripe/resources/mandate.rb +1 -0
  69. data/lib/stripe/resources/payment_intent.rb +103 -6
  70. data/lib/stripe/resources/payment_link.rb +35 -0
  71. data/lib/stripe/resources/payment_method.rb +25 -5
  72. data/lib/stripe/resources/payout.rb +28 -5
  73. data/lib/stripe/resources/person.rb +7 -0
  74. data/lib/stripe/resources/plan.rb +8 -0
  75. data/lib/stripe/resources/price.rb +15 -0
  76. data/lib/stripe/resources/product.rb +17 -0
  77. data/lib/stripe/resources/promotion_code.rb +2 -0
  78. data/lib/stripe/resources/quote.rb +128 -0
  79. data/lib/stripe/resources/radar/early_fraud_warning.rb +4 -0
  80. data/lib/stripe/resources/radar/value_list.rb +3 -0
  81. data/lib/stripe/resources/radar/value_list_item.rb +3 -0
  82. data/lib/stripe/resources/refund.rb +49 -0
  83. data/lib/stripe/resources/reporting/report_run.rb +8 -0
  84. data/lib/stripe/resources/reporting/report_type.rb +8 -1
  85. data/lib/stripe/resources/reversal.rb +16 -2
  86. data/lib/stripe/resources/review.rb +14 -3
  87. data/lib/stripe/resources/setup_attempt.rb +4 -0
  88. data/lib/stripe/resources/setup_intent.rb +60 -5
  89. data/lib/stripe/resources/shipping_rate.rb +14 -0
  90. data/lib/stripe/resources/sigma/scheduled_query_run.rb +4 -0
  91. data/lib/stripe/resources/source.rb +26 -6
  92. data/lib/stripe/resources/source_transaction.rb +5 -0
  93. data/lib/stripe/resources/subscription.rb +57 -3
  94. data/lib/stripe/resources/subscription_item.rb +2 -7
  95. data/lib/stripe/resources/subscription_schedule.rb +23 -5
  96. data/lib/stripe/resources/tax/calculation.rb +33 -0
  97. data/lib/stripe/resources/tax/calculation_line_item.rb +10 -0
  98. data/lib/stripe/resources/tax/settings.rb +15 -0
  99. data/lib/stripe/resources/tax/transaction.rb +49 -0
  100. data/lib/stripe/resources/tax/transaction_line_item.rb +10 -0
  101. data/lib/stripe/resources/tax_code.rb +11 -0
  102. data/lib/stripe/resources/tax_id.rb +5 -0
  103. data/lib/stripe/resources/tax_rate.rb +3 -0
  104. data/lib/stripe/resources/terminal/configuration.rb +16 -0
  105. data/lib/stripe/resources/terminal/connection_token.rb +3 -0
  106. data/lib/stripe/resources/terminal/location.rb +3 -0
  107. data/lib/stripe/resources/terminal/reader.rb +119 -0
  108. data/lib/stripe/resources/test_helpers/test_clock.rb +35 -0
  109. data/lib/stripe/resources/token.rb +20 -0
  110. data/lib/stripe/resources/topup.rb +15 -3
  111. data/lib/stripe/resources/transfer.rb +10 -11
  112. data/lib/stripe/resources/treasury/credit_reversal.rb +14 -0
  113. data/lib/stripe/resources/treasury/debit_reversal.rb +14 -0
  114. data/lib/stripe/resources/treasury/financial_account.rb +52 -0
  115. data/lib/stripe/resources/treasury/financial_account_features.rb +12 -0
  116. data/lib/stripe/resources/treasury/inbound_transfer.rb +94 -0
  117. data/lib/stripe/resources/treasury/outbound_payment.rb +96 -0
  118. data/lib/stripe/resources/treasury/outbound_transfer.rb +100 -0
  119. data/lib/stripe/resources/treasury/received_credit.rb +30 -0
  120. data/lib/stripe/resources/treasury/received_debit.rb +30 -0
  121. data/lib/stripe/resources/treasury/transaction.rb +13 -0
  122. data/lib/stripe/resources/treasury/transaction_entry.rb +17 -0
  123. data/lib/stripe/resources/usage_record.rb +5 -0
  124. data/lib/stripe/resources/usage_record_summary.rb +1 -0
  125. data/lib/stripe/resources/webhook_endpoint.rb +7 -0
  126. data/lib/stripe/resources.rb +34 -10
  127. data/lib/stripe/search_result_object.rb +86 -0
  128. data/lib/stripe/stripe_client.rb +267 -121
  129. data/lib/stripe/stripe_configuration.rb +29 -10
  130. data/lib/stripe/stripe_object.rb +25 -2
  131. data/lib/stripe/stripe_response.rb +80 -52
  132. data/lib/stripe/util.rb +100 -9
  133. data/lib/stripe/version.rb +1 -1
  134. data/lib/stripe.rb +27 -23
  135. data/stripe.gemspec +12 -5
  136. metadata +46 -204
  137. data/.editorconfig +0 -10
  138. data/.gitattributes +0 -4
  139. data/.github/ISSUE_TEMPLATE.md +0 -5
  140. data/.gitignore +0 -8
  141. data/.rubocop.yml +0 -80
  142. data/.rubocop_todo.yml +0 -33
  143. data/.travis.yml +0 -38
  144. data/.vscode/extensions.json +0 -7
  145. data/.vscode/settings.json +0 -8
  146. data/lib/stripe/resources/bitcoin_receiver.rb +0 -24
  147. data/lib/stripe/resources/bitcoin_transaction.rb +0 -15
  148. data/lib/stripe/resources/issuing/card_details.rb +0 -9
  149. data/lib/stripe/resources/order.rb +0 -33
  150. data/lib/stripe/resources/order_return.rb +0 -10
  151. data/lib/stripe/resources/recipient.rb +0 -14
  152. data/lib/stripe/resources/sku.rb +0 -13
  153. data/lib/stripe/resources/three_d_secure.rb +0 -14
  154. data/test/openapi/README.md +0 -9
  155. data/test/stripe/account_link_test.rb +0 -18
  156. data/test/stripe/account_test.rb +0 -412
  157. data/test/stripe/alipay_account_test.rb +0 -37
  158. data/test/stripe/api_operations_test.rb +0 -80
  159. data/test/stripe/api_resource_test.rb +0 -646
  160. data/test/stripe/apple_pay_domain_test.rb +0 -46
  161. data/test/stripe/application_fee_refund_test.rb +0 -37
  162. data/test/stripe/application_fee_test.rb +0 -58
  163. data/test/stripe/balance_test.rb +0 -13
  164. data/test/stripe/balance_transaction_test.rb +0 -20
  165. data/test/stripe/bank_account_test.rb +0 -36
  166. data/test/stripe/billing_portal/session_test.rb +0 -18
  167. data/test/stripe/capability_test.rb +0 -45
  168. data/test/stripe/charge_test.rb +0 -64
  169. data/test/stripe/checkout/session_test.rb +0 -53
  170. data/test/stripe/connection_manager_test.rb +0 -167
  171. data/test/stripe/country_spec_test.rb +0 -20
  172. data/test/stripe/coupon_test.rb +0 -61
  173. data/test/stripe/credit_note_test.rb +0 -90
  174. data/test/stripe/customer_balance_transaction_test.rb +0 -37
  175. data/test/stripe/customer_card_test.rb +0 -48
  176. data/test/stripe/customer_test.rb +0 -226
  177. data/test/stripe/dispute_test.rb +0 -51
  178. data/test/stripe/ephemeral_key_test.rb +0 -93
  179. data/test/stripe/errors_test.rb +0 -53
  180. data/test/stripe/exchange_rate_test.rb +0 -20
  181. data/test/stripe/file_link_test.rb +0 -41
  182. data/test/stripe/file_test.rb +0 -87
  183. data/test/stripe/instrumentation_test.rb +0 -74
  184. data/test/stripe/invoice_item_test.rb +0 -66
  185. data/test/stripe/invoice_line_item_test.rb +0 -8
  186. data/test/stripe/invoice_test.rb +0 -229
  187. data/test/stripe/issuing/authorization_test.rb +0 -72
  188. data/test/stripe/issuing/card_test.rb +0 -74
  189. data/test/stripe/issuing/cardholder_test.rb +0 -53
  190. data/test/stripe/issuing/dispute_test.rb +0 -54
  191. data/test/stripe/issuing/transaction_test.rb +0 -48
  192. data/test/stripe/list_object_test.rb +0 -202
  193. data/test/stripe/login_link_test.rb +0 -37
  194. data/test/stripe/mandate_test.rb +0 -14
  195. data/test/stripe/multipart_encoder_test.rb +0 -130
  196. data/test/stripe/oauth_test.rb +0 -104
  197. data/test/stripe/order_return_test.rb +0 -21
  198. data/test/stripe/order_test.rb +0 -82
  199. data/test/stripe/payment_intent_test.rb +0 -107
  200. data/test/stripe/payment_method_test.rb +0 -84
  201. data/test/stripe/payout_test.rb +0 -72
  202. data/test/stripe/person_test.rb +0 -46
  203. data/test/stripe/plan_test.rb +0 -98
  204. data/test/stripe/price_test.rb +0 -48
  205. data/test/stripe/product_test.rb +0 -58
  206. data/test/stripe/promotion_code_test.rb +0 -42
  207. data/test/stripe/radar/early_fraud_warning_test.rb +0 -22
  208. data/test/stripe/radar/value_list_item_test.rb +0 -48
  209. data/test/stripe/radar/value_list_test.rb +0 -61
  210. data/test/stripe/recipient_test.rb +0 -62
  211. data/test/stripe/refund_test.rb +0 -39
  212. data/test/stripe/reporting/report_run_test.rb +0 -33
  213. data/test/stripe/reporting/report_type_test.rb +0 -22
  214. data/test/stripe/reversal_test.rb +0 -43
  215. data/test/stripe/review_test.rb +0 -27
  216. data/test/stripe/setup_attempt_test.rb +0 -16
  217. data/test/stripe/setup_intent_test.rb +0 -84
  218. data/test/stripe/sigma/scheduled_query_run_test.rb +0 -22
  219. data/test/stripe/sku_test.rb +0 -60
  220. data/test/stripe/source_test.rb +0 -119
  221. data/test/stripe/stripe_client_test.rb +0 -1291
  222. data/test/stripe/stripe_configuration_test.rb +0 -131
  223. data/test/stripe/stripe_object_test.rb +0 -500
  224. data/test/stripe/stripe_response_test.rb +0 -95
  225. data/test/stripe/subscription_item_test.rb +0 -84
  226. data/test/stripe/subscription_schedule_test.rb +0 -82
  227. data/test/stripe/subscription_test.rb +0 -80
  228. data/test/stripe/tax_id_test.rb +0 -31
  229. data/test/stripe/tax_rate_test.rb +0 -43
  230. data/test/stripe/terminal/connection_token_test.rb +0 -16
  231. data/test/stripe/terminal/location_test.rb +0 -68
  232. data/test/stripe/terminal/reader_test.rb +0 -62
  233. data/test/stripe/three_d_secure_test.rb +0 -23
  234. data/test/stripe/topup_test.rb +0 -62
  235. data/test/stripe/transfer_test.rb +0 -88
  236. data/test/stripe/usage_record_summary_test.rb +0 -29
  237. data/test/stripe/util_test.rb +0 -402
  238. data/test/stripe/webhook_endpoint_test.rb +0 -59
  239. data/test/stripe/webhook_test.rb +0 -135
  240. data/test/stripe_mock.rb +0 -78
  241. data/test/stripe_test.rb +0 -132
  242. data/test/test_data.rb +0 -61
  243. data/test/test_helper.rb +0 -77
@@ -2,10 +2,14 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # This object represents a customer of your business. It lets you create recurring charges and track payments that belong to the same customer.
6
+ #
7
+ # Related guide: [Save a card during payment](https://stripe.com/docs/payments/save-during-payment)
5
8
  class Customer < APIResource
6
9
  extend Stripe::APIOperations::Create
7
10
  include Stripe::APIOperations::Delete
8
11
  extend Stripe::APIOperations::List
12
+ extend Stripe::APIOperations::Search
9
13
  include Stripe::APIOperations::Save
10
14
  extend Stripe::APIOperations::NestedResource
11
15
 
@@ -13,10 +17,87 @@ module Stripe
13
17
 
14
18
  nested_resource_class_methods :balance_transaction,
15
19
  operations: %i[create retrieve update list]
20
+ nested_resource_class_methods :cash_balance_transaction,
21
+ operations: %i[retrieve list]
16
22
  nested_resource_class_methods :tax_id,
17
23
  operations: %i[create retrieve delete list]
18
24
 
19
- custom_method :delete_discount, http_verb: :delete, http_path: "discount"
25
+ def create_funding_instructions(params = {}, opts = {})
26
+ request_stripe_object(
27
+ method: :post,
28
+ path: format("/v1/customers/%<customer>s/funding_instructions", { customer: CGI.escape(self["id"]) }),
29
+ params: params,
30
+ opts: opts
31
+ )
32
+ end
33
+
34
+ def delete_discount(params = {}, opts = {})
35
+ request_stripe_object(
36
+ method: :delete,
37
+ path: format("/v1/customers/%<customer>s/discount", { customer: CGI.escape(self["id"]) }),
38
+ params: params,
39
+ opts: opts
40
+ )
41
+ end
42
+
43
+ def list_payment_methods(params = {}, opts = {})
44
+ request_stripe_object(
45
+ method: :get,
46
+ path: format("/v1/customers/%<customer>s/payment_methods", { customer: CGI.escape(self["id"]) }),
47
+ params: params,
48
+ opts: opts
49
+ )
50
+ end
51
+
52
+ def retrieve_payment_method(payment_method, params = {}, opts = {})
53
+ request_stripe_object(
54
+ method: :get,
55
+ path: format("/v1/customers/%<customer>s/payment_methods/%<payment_method>s", { customer: CGI.escape(self["id"]), payment_method: CGI.escape(payment_method) }),
56
+ params: params,
57
+ opts: opts
58
+ )
59
+ end
60
+
61
+ def self.create_funding_instructions(customer, params = {}, opts = {})
62
+ request_stripe_object(
63
+ method: :post,
64
+ path: format("/v1/customers/%<customer>s/funding_instructions", { customer: CGI.escape(customer) }),
65
+ params: params,
66
+ opts: opts
67
+ )
68
+ end
69
+
70
+ def self.delete_discount(customer, params = {}, opts = {})
71
+ request_stripe_object(
72
+ method: :delete,
73
+ path: format("/v1/customers/%<customer>s/discount", { customer: CGI.escape(customer) }),
74
+ params: params,
75
+ opts: opts
76
+ )
77
+ end
78
+
79
+ def self.list_payment_methods(customer, params = {}, opts = {})
80
+ request_stripe_object(
81
+ method: :get,
82
+ path: format("/v1/customers/%<customer>s/payment_methods", { customer: CGI.escape(customer) }),
83
+ params: params,
84
+ opts: opts
85
+ )
86
+ end
87
+
88
+ def self.retrieve_payment_method(
89
+ customer,
90
+ payment_method,
91
+ params = {},
92
+ opts = {}
93
+ )
94
+ request_stripe_object(
95
+ method: :get,
96
+ path: format("/v1/customers/%<customer>s/payment_methods/%<payment_method>s", { customer: CGI.escape(customer), payment_method: CGI.escape(payment_method) }),
97
+ params: params,
98
+ opts: opts
99
+ )
100
+ end
20
101
 
21
102
  save_nested_resource :source
22
103
  nested_resource_class_methods :source,
@@ -28,9 +109,56 @@ module Stripe
28
109
  alias detach_source delete_source
29
110
  end
30
111
 
31
- def delete_discount
32
- resp, opts = execute_resource_request(:delete, resource_url + "/discount")
33
- initialize_from(resp.data, opts, true)
112
+ def self.search(params = {}, opts = {})
113
+ _search("/v1/customers/search", params, opts)
114
+ end
115
+
116
+ def self.search_auto_paging_each(params = {}, opts = {}, &blk)
117
+ search(params, opts).auto_paging_each(&blk)
118
+ end
119
+
120
+ def self.retrieve_cash_balance(customer, params = {}, opts = {})
121
+ request_stripe_object(
122
+ method: :get,
123
+ path: format("/v1/customers/%<customer>s/cash_balance", { customer: CGI.escape(customer) }),
124
+ params: params,
125
+ opts: opts
126
+ )
127
+ end
128
+
129
+ def self.update_cash_balance(customer, params = {}, opts = {})
130
+ request_stripe_object(
131
+ method: :post,
132
+ path: format("/v1/customers/%<customer>s/cash_balance", { customer: CGI.escape(customer) }),
133
+ params: params,
134
+ opts: opts
135
+ )
136
+ end
137
+
138
+ def test_helpers
139
+ TestHelpers.new(self)
140
+ end
141
+
142
+ class TestHelpers < APIResourceTestHelpers
143
+ RESOURCE_CLASS = Customer
144
+
145
+ def self.fund_cash_balance(customer, params = {}, opts = {})
146
+ request_stripe_object(
147
+ method: :post,
148
+ path: format("/v1/test_helpers/customers/%<customer>s/fund_cash_balance", { customer: CGI.escape(customer) }),
149
+ params: params,
150
+ opts: opts
151
+ )
152
+ end
153
+
154
+ def fund_cash_balance(params = {}, opts = {})
155
+ @resource.request_stripe_object(
156
+ method: :post,
157
+ path: format("/v1/test_helpers/customers/%<customer>s/fund_cash_balance", { customer: CGI.escape(@resource["id"]) }),
158
+ params: params,
159
+ opts: opts
160
+ )
161
+ end
34
162
  end
35
163
  end
36
164
  end
@@ -1,6 +1,13 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
5
+ # Each customer has a [Balance](https://stripe.com/docs/api/customers/object#customer_object-balance) value,
6
+ # which denotes a debit or credit that's automatically applied to their next invoice upon finalization.
7
+ # You may modify the value directly by using the [update customer API](https://stripe.com/docs/api/customers/update),
8
+ # or by creating a Customer Balance Transaction, which increments or decrements the customer's `balance` by the specified `amount`.
9
+ #
10
+ # Related guide: [Customer balance](https://stripe.com/docs/billing/customer/balance)
4
11
  class CustomerBalanceTransaction < APIResource
5
12
  extend Stripe::APIOperations::List
6
13
  include Stripe::APIOperations::Save
@@ -18,13 +25,13 @@ module Stripe
18
25
  def self.retrieve(_id, _opts = {})
19
26
  raise NotImplementedError,
20
27
  "Customer Balance Transactions cannot be retrieved without a customer ID. " \
21
- "Retrieve a Customer Balance Transaction using Customer.retrieve_balance_transaction('cus_123', 'cbtxn_123')"
28
+ "Retrieve a Customer Balance Transaction using `Customer.retrieve_balance_transaction('cus_123', 'cbtxn_123')`"
22
29
  end
23
30
 
24
31
  def self.update(_id, _params = nil, _opts = nil)
25
32
  raise NotImplementedError,
26
33
  "Customer Balance Transactions cannot be retrieved without a customer ID. " \
27
- "Update a Customer Balance Transaction using Customer.update_balance_transaction('cus_123', 'cbtxn_123', params)"
34
+ "Update a Customer Balance Transaction using `Customer.update_balance_transaction('cus_123', 'cbtxn_123', params)`"
28
35
  end
29
36
  end
30
37
  end
@@ -0,0 +1,14 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ # Customers with certain payments enabled have a cash balance, representing funds that were paid
6
+ # by the customer to a merchant, but have not yet been allocated to a payment. Cash Balance Transactions
7
+ # represent when funds are moved into or out of this balance. This includes funding by the customer, allocation
8
+ # to payments, and refunds to the customer.
9
+ class CustomerCashBalanceTransaction < APIResource
10
+ extend Stripe::APIOperations::List
11
+
12
+ OBJECT_NAME = "customer_cash_balance_transaction"
13
+ end
14
+ end
@@ -1,6 +1,11 @@
1
+ # File generated from our OpenAPI spec
1
2
  # frozen_string_literal: true
2
3
 
3
4
  module Stripe
5
+ # A discount represents the actual application of a [coupon](https://stripe.com/docs/api#coupons) or [promotion code](https://stripe.com/docs/api#promotion_codes).
6
+ # It contains information about when the discount began, when it will end, and what it is applied to.
7
+ #
8
+ # Related guide: [Applying discounts to subscriptions](https://stripe.com/docs/billing/subscriptions/discounts)
4
9
  class Discount < StripeObject
5
10
  OBJECT_NAME = "discount"
6
11
  end
@@ -2,18 +2,32 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # A dispute occurs when a customer questions your charge with their card issuer.
6
+ # When this happens, you're given the opportunity to respond to the dispute with
7
+ # evidence that shows that the charge is legitimate. You can find more
8
+ # information about the dispute process in our [Disputes and
9
+ # Fraud](https://stripe.com/docs/disputes) documentation.
10
+ #
11
+ # Related guide: [Disputes and fraud](https://stripe.com/docs/disputes)
5
12
  class Dispute < APIResource
6
13
  extend Stripe::APIOperations::List
7
14
  include Stripe::APIOperations::Save
8
15
 
9
16
  OBJECT_NAME = "dispute"
10
17
 
11
- custom_method :close, http_verb: :post
12
-
13
18
  def close(params = {}, opts = {})
14
19
  request_stripe_object(
15
20
  method: :post,
16
- path: resource_url + "/close",
21
+ path: format("/v1/disputes/%<dispute>s/close", { dispute: CGI.escape(self["id"]) }),
22
+ params: params,
23
+ opts: opts
24
+ )
25
+ end
26
+
27
+ def self.close(dispute, params = {}, opts = {})
28
+ request_stripe_object(
29
+ method: :post,
30
+ path: format("/v1/disputes/%<dispute>s/close", { dispute: CGI.escape(dispute) }),
17
31
  params: params,
18
32
  opts: opts
19
33
  )
@@ -2,6 +2,35 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # Events are our way of letting you know when something interesting happens in
6
+ # your account. When an interesting event occurs, we create a new `Event`
7
+ # object. For example, when a charge succeeds, we create a `charge.succeeded`
8
+ # event; and when an invoice payment attempt fails, we create an
9
+ # `invoice.payment_failed` event. Note that many API requests may cause multiple
10
+ # events to be created. For example, if you create a new subscription for a
11
+ # customer, you will receive both a `customer.subscription.created` event and a
12
+ # `charge.succeeded` event.
13
+ #
14
+ # Events occur when the state of another API resource changes. The state of that
15
+ # resource at the time of the change is embedded in the event's data field. For
16
+ # example, a `charge.succeeded` event will contain a charge, and an
17
+ # `invoice.payment_failed` event will contain an invoice.
18
+ #
19
+ # As with other API resources, you can use endpoints to retrieve an
20
+ # [individual event](https://stripe.com/docs/api#retrieve_event) or a [list of events](https://stripe.com/docs/api#list_events)
21
+ # from the API. We also have a separate
22
+ # [webhooks](http://en.wikipedia.org/wiki/Webhook) system for sending the
23
+ # `Event` objects directly to an endpoint on your server. Webhooks are managed
24
+ # in your
25
+ # [account settings](https://dashboard.stripe.com/account/webhooks),
26
+ # and our [Using Webhooks](https://stripe.com/docs/webhooks) guide will help you get set up.
27
+ #
28
+ # When using [Connect](https://stripe.com/docs/connect), you can also receive notifications of
29
+ # events that occur in connected accounts. For these events, there will be an
30
+ # additional `account` attribute in the received `Event` object.
31
+ #
32
+ # **NOTE:** Right now, access to events through the [Retrieve Event API](https://stripe.com/docs/api#retrieve_event) is
33
+ # guaranteed only for 30 days.
5
34
  class Event < APIResource
6
35
  extend Stripe::APIOperations::List
7
36
 
@@ -2,6 +2,17 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # `Exchange Rate` objects allow you to determine the rates that Stripe is
6
+ # currently using to convert from one currency to another. Since this number is
7
+ # variable throughout the day, there are various reasons why you might want to
8
+ # know the current rate (for example, to dynamically price an item for a user
9
+ # with a default payment in a foreign currency).
10
+ #
11
+ # If you want a guarantee that the charge is made with a certain exchange rate
12
+ # you expect is current, you can pass in `exchange_rate` to charges endpoints.
13
+ # If the value is no longer up to date, the charge won't go through. Please
14
+ # refer to our [Exchange Rates API](https://stripe.com/docs/exchange-rates) guide for more
15
+ # details.
5
16
  class ExchangeRate < APIResource
6
17
  extend Stripe::APIOperations::List
7
18
 
@@ -2,6 +2,13 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # This is an object representing a file hosted on Stripe's servers. The
6
+ # file may have been uploaded by yourself using the [create file](https://stripe.com/docs/api#create_file)
7
+ # request (for example, when uploading dispute evidence) or it may have
8
+ # been created by Stripe (for example, the results of a [Sigma scheduled
9
+ # query](https://stripe.com/docs/api#scheduled_queries)).
10
+ #
11
+ # Related guide: [File upload guide](https://stripe.com/docs/file-upload)
5
12
  class File < APIResource
6
13
  extend Stripe::APIOperations::Create
7
14
  extend Stripe::APIOperations::List
@@ -25,8 +32,9 @@ module Stripe
25
32
  end
26
33
  end
27
34
 
35
+ config = opts[:client]&.config || Stripe.config
28
36
  opts = {
29
- api_base: Stripe.uploads_base,
37
+ api_base: config.uploads_base,
30
38
  content_type: MultipartEncoder::MULTIPART_FORM_DATA,
31
39
  }.merge(Util.normalize_opts(opts))
32
40
  super
@@ -2,6 +2,9 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Stripe
5
+ # To share the contents of a `File` object with non-Stripe users, you can
6
+ # create a `FileLink`. `FileLink`s contain a URL that can be used to
7
+ # retrieve the contents of the file without authentication.
5
8
  class FileLink < APIResource
6
9
  extend Stripe::APIOperations::Create
7
10
  extend Stripe::APIOperations::List
@@ -0,0 +1,67 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module FinancialConnections
6
+ # A Financial Connections Account represents an account that exists outside of Stripe, to which you have been granted some degree of access.
7
+ class Account < APIResource
8
+ extend Stripe::APIOperations::List
9
+
10
+ OBJECT_NAME = "financial_connections.account"
11
+
12
+ def disconnect(params = {}, opts = {})
13
+ request_stripe_object(
14
+ method: :post,
15
+ path: format("/v1/financial_connections/accounts/%<account>s/disconnect", { account: CGI.escape(self["id"]) }),
16
+ params: params,
17
+ opts: opts
18
+ )
19
+ end
20
+
21
+ def list_owners(params = {}, opts = {})
22
+ request_stripe_object(
23
+ method: :get,
24
+ path: format("/v1/financial_connections/accounts/%<account>s/owners", { account: CGI.escape(self["id"]) }),
25
+ params: params,
26
+ opts: opts
27
+ )
28
+ end
29
+
30
+ def refresh_account(params = {}, opts = {})
31
+ request_stripe_object(
32
+ method: :post,
33
+ path: format("/v1/financial_connections/accounts/%<account>s/refresh", { account: CGI.escape(self["id"]) }),
34
+ params: params,
35
+ opts: opts
36
+ )
37
+ end
38
+
39
+ def self.disconnect(account, params = {}, opts = {})
40
+ request_stripe_object(
41
+ method: :post,
42
+ path: format("/v1/financial_connections/accounts/%<account>s/disconnect", { account: CGI.escape(account) }),
43
+ params: params,
44
+ opts: opts
45
+ )
46
+ end
47
+
48
+ def self.list_owners(account, params = {}, opts = {})
49
+ request_stripe_object(
50
+ method: :get,
51
+ path: format("/v1/financial_connections/accounts/%<account>s/owners", { account: CGI.escape(account) }),
52
+ params: params,
53
+ opts: opts
54
+ )
55
+ end
56
+
57
+ def self.refresh_account(account, params = {}, opts = {})
58
+ request_stripe_object(
59
+ method: :post,
60
+ path: format("/v1/financial_connections/accounts/%<account>s/refresh", { account: CGI.escape(account) }),
61
+ params: params,
62
+ opts: opts
63
+ )
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,11 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module FinancialConnections
6
+ # Describes an owner of an account.
7
+ class AccountOwner < StripeObject
8
+ OBJECT_NAME = "financial_connections.account_owner"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module FinancialConnections
6
+ # Describes a snapshot of the owners of an account at a particular point in time.
7
+ class AccountOwnership < StripeObject
8
+ OBJECT_NAME = "financial_connections.account_ownership"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module FinancialConnections
6
+ # A Financial Connections Session is the secure way to programmatically launch the client-side Stripe.js modal that lets your users link their accounts.
7
+ class Session < APIResource
8
+ extend Stripe::APIOperations::Create
9
+
10
+ OBJECT_NAME = "financial_connections.session"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ # Each customer has a [`balance`](https://stripe.com/docs/api/customers/object#customer_object-balance) that is
6
+ # automatically applied to future invoices and payments using the `customer_balance` payment method.
7
+ # Customers can fund this balance by initiating a bank transfer to any account in the
8
+ # `financial_addresses` field.
9
+ # Related guide: [Customer balance funding instructions](https://stripe.com/docs/payments/customer-balance/funding-instructions)
10
+ class FundingInstructions < APIResource
11
+ OBJECT_NAME = "funding_instructions"
12
+
13
+ def resource_url
14
+ if !respond_to?(:customer) || customer.nil?
15
+ raise NotImplementedError,
16
+ "FundingInstructions cannot be accessed without a customer ID."
17
+ end
18
+ "#{Customer.resource_url}/#{CGI.escape(customer)}/funding_instructions" "/#{CGI.escape(id)}"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Identity
6
+ # A VerificationReport is the result of an attempt to collect and verify data from a user.
7
+ # The collection of verification checks performed is determined from the `type` and `options`
8
+ # parameters used. You can find the result of each verification check performed in the
9
+ # appropriate sub-resource: `document`, `id_number`, `selfie`.
10
+ #
11
+ # Each VerificationReport contains a copy of any data collected by the user as well as
12
+ # reference IDs which can be used to access collected images through the [FileUpload](https://stripe.com/docs/api/files)
13
+ # API. To configure and create VerificationReports, use the
14
+ # [VerificationSession](https://stripe.com/docs/api/identity/verification_sessions) API.
15
+ #
16
+ # Related guides: [Accessing verification results](https://stripe.com/docs/identity/verification-sessions#results).
17
+ class VerificationReport < APIResource
18
+ extend Stripe::APIOperations::List
19
+
20
+ OBJECT_NAME = "identity.verification_report"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,61 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Identity
6
+ # A VerificationSession guides you through the process of collecting and verifying the identities
7
+ # of your users. It contains details about the type of verification, such as what [verification
8
+ # check](https://stripe.com/docs/identity/verification-checks) to perform. Only create one VerificationSession for
9
+ # each verification in your system.
10
+ #
11
+ # A VerificationSession transitions through [multiple
12
+ # statuses](https://stripe.com/docs/identity/how-sessions-work) throughout its lifetime as it progresses through
13
+ # the verification flow. The VerificationSession contains the user's verified data after
14
+ # verification checks are complete.
15
+ #
16
+ # Related guide: [The Verification Sessions API](https://stripe.com/docs/identity/verification-sessions)
17
+ class VerificationSession < APIResource
18
+ extend Stripe::APIOperations::Create
19
+ extend Stripe::APIOperations::List
20
+ include Stripe::APIOperations::Save
21
+
22
+ OBJECT_NAME = "identity.verification_session"
23
+
24
+ def cancel(params = {}, opts = {})
25
+ request_stripe_object(
26
+ method: :post,
27
+ path: format("/v1/identity/verification_sessions/%<session>s/cancel", { session: CGI.escape(self["id"]) }),
28
+ params: params,
29
+ opts: opts
30
+ )
31
+ end
32
+
33
+ def redact(params = {}, opts = {})
34
+ request_stripe_object(
35
+ method: :post,
36
+ path: format("/v1/identity/verification_sessions/%<session>s/redact", { session: CGI.escape(self["id"]) }),
37
+ params: params,
38
+ opts: opts
39
+ )
40
+ end
41
+
42
+ def self.cancel(session, params = {}, opts = {})
43
+ request_stripe_object(
44
+ method: :post,
45
+ path: format("/v1/identity/verification_sessions/%<session>s/cancel", { session: CGI.escape(session) }),
46
+ params: params,
47
+ opts: opts
48
+ )
49
+ end
50
+
51
+ def self.redact(session, params = {}, opts = {})
52
+ request_stripe_object(
53
+ method: :post,
54
+ path: format("/v1/identity/verification_sessions/%<session>s/redact", { session: CGI.escape(session) }),
55
+ params: params,
56
+ opts: opts
57
+ )
58
+ end
59
+ end
60
+ end
61
+ end