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
@@ -10,5 +10,20 @@ module Stripe
10
10
  extend Stripe::APIOperations::List
11
11
 
12
12
  OBJECT_NAME = "balance_transaction"
13
+ def self.object_name
14
+ "balance_transaction"
15
+ end
16
+
17
+ # Returns a list of transactions that have contributed to the Stripe account balance (e.g., charges, transfers, and so forth). The transactions are returned in sorted order, with the most recent transactions appearing first.
18
+ #
19
+ # Note that this endpoint was previously called “Balance history” and used the path /v1/balance/history.
20
+ def self.list(filters = {}, opts = {})
21
+ request_stripe_object(
22
+ method: :get,
23
+ path: "/v1/balance_transactions",
24
+ params: filters,
25
+ opts: opts
26
+ )
27
+ end
13
28
  end
14
29
  end
@@ -4,21 +4,37 @@
4
4
  module Stripe
5
5
  # These bank accounts are payment methods on `Customer` objects.
6
6
  #
7
- # On the other hand [External Accounts](https://stripe.com/docs/api#external_accounts) are transfer
8
- # destinations on `Account` objects for [Custom accounts](https://stripe.com/docs/connect/custom-accounts).
7
+ # On the other hand [External Accounts](https://stripe.com/api#external_accounts) are transfer
8
+ # destinations on `Account` objects for connected accounts.
9
9
  # They can be bank accounts or debit cards as well, and are documented in the links above.
10
10
  #
11
- # Related guide: [Bank debits and transfers](https://stripe.com/docs/payments/bank-debits-transfers)
11
+ # Related guide: [Bank debits and transfers](https://stripe.com/payments/bank-debits-transfers)
12
12
  class BankAccount < APIResource
13
13
  include Stripe::APIOperations::Delete
14
14
  extend Stripe::APIOperations::List
15
15
  include Stripe::APIOperations::Save
16
16
 
17
17
  OBJECT_NAME = "bank_account"
18
+ def self.object_name
19
+ "bank_account"
20
+ end
18
21
 
19
22
  def verify(params = {}, opts = {})
20
- resp, opts = execute_resource_request(:post, resource_url + "/verify", params, opts)
21
- initialize_from(resp.data, opts)
23
+ request_stripe_object(
24
+ method: :post,
25
+ path: "#{Customer.resource_url}/#{customer}/sources/#{id}/verify",
26
+ params: params,
27
+ opts: opts
28
+ )
29
+ end
30
+
31
+ def self.verify(customer, id, params = {}, opts = {})
32
+ request_stripe_object(
33
+ method: :post,
34
+ path: "#{Customer.resource_url}/#{customer}/sources/#{id}/verify",
35
+ params: params,
36
+ opts: opts
37
+ )
22
38
  end
23
39
 
24
40
  def resource_url
@@ -31,8 +47,8 @@ module Stripe
31
47
 
32
48
  def self.update(_id, _params = nil, _opts = nil)
33
49
  raise NotImplementedError,
34
- "Bank accounts cannot be updated without a customer ID or an " \
35
- " account ID. Update a bank account using " \
50
+ "Bank accounts cannot be updated without a customer ID or an " \
51
+ "account ID. Update a bank account using " \
36
52
  "`Customer.update_source('customer_id', 'bank_account_id', " \
37
53
  "update_params)` or `Account.update_external_account(" \
38
54
  "'account_id', 'bank_account_id', update_params)`"
@@ -46,5 +62,31 @@ module Stripe
46
62
  "or `Account.retrieve_external_account('account_id', " \
47
63
  "'bank_account_id')`"
48
64
  end
65
+
66
+ def self.delete(id, params = {}, opts = {})
67
+ raise NotImplementedError,
68
+ "Bank accounts cannot be deleted without a customer ID or an " \
69
+ "account ID. Delete a bank account using " \
70
+ "`Customer.delete_source('customer_id', 'bank_account_id')` " \
71
+ "or `Account.delete_external_account('account_id', " \
72
+ "'bank_account_id')`"
73
+ end
74
+
75
+ def delete(params = {}, opts = {})
76
+ request_stripe_object(
77
+ method: :delete,
78
+ path: resource_url.to_s,
79
+ params: params,
80
+ opts: opts
81
+ )
82
+ end
83
+
84
+ def self.list(filters = {}, opts = {})
85
+ raise NotImplementedError,
86
+ "Bank accounts cannot be listed without a customer ID or an " \
87
+ "account ID. List bank accounts using " \
88
+ "`Customer.list_sources('customer_id')` " \
89
+ "or `Account.list_external_accounts('account_id')`"
90
+ end
49
91
  end
50
92
  end
@@ -0,0 +1,87 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Billing
6
+ # A billing alert is a resource that notifies you when a certain usage threshold on a meter is crossed. For example, you might create a billing alert to notify you when a certain user made 100 API requests.
7
+ class Alert < APIResource
8
+ extend Stripe::APIOperations::Create
9
+ extend Stripe::APIOperations::List
10
+
11
+ OBJECT_NAME = "billing.alert"
12
+ def self.object_name
13
+ "billing.alert"
14
+ end
15
+
16
+ # Reactivates this alert, allowing it to trigger again.
17
+ def activate(params = {}, opts = {})
18
+ request_stripe_object(
19
+ method: :post,
20
+ path: format("/v1/billing/alerts/%<id>s/activate", { id: CGI.escape(self["id"]) }),
21
+ params: params,
22
+ opts: opts
23
+ )
24
+ end
25
+
26
+ # Reactivates this alert, allowing it to trigger again.
27
+ def self.activate(id, params = {}, opts = {})
28
+ request_stripe_object(
29
+ method: :post,
30
+ path: format("/v1/billing/alerts/%<id>s/activate", { id: CGI.escape(id) }),
31
+ params: params,
32
+ opts: opts
33
+ )
34
+ end
35
+
36
+ # Archives this alert, removing it from the list view and APIs. This is non-reversible.
37
+ def archive(params = {}, opts = {})
38
+ request_stripe_object(
39
+ method: :post,
40
+ path: format("/v1/billing/alerts/%<id>s/archive", { id: CGI.escape(self["id"]) }),
41
+ params: params,
42
+ opts: opts
43
+ )
44
+ end
45
+
46
+ # Archives this alert, removing it from the list view and APIs. This is non-reversible.
47
+ def self.archive(id, params = {}, opts = {})
48
+ request_stripe_object(
49
+ method: :post,
50
+ path: format("/v1/billing/alerts/%<id>s/archive", { id: CGI.escape(id) }),
51
+ params: params,
52
+ opts: opts
53
+ )
54
+ end
55
+
56
+ # Creates a billing alert
57
+ def self.create(params = {}, opts = {})
58
+ request_stripe_object(method: :post, path: "/v1/billing/alerts", params: params, opts: opts)
59
+ end
60
+
61
+ # Deactivates this alert, preventing it from triggering.
62
+ def deactivate(params = {}, opts = {})
63
+ request_stripe_object(
64
+ method: :post,
65
+ path: format("/v1/billing/alerts/%<id>s/deactivate", { id: CGI.escape(self["id"]) }),
66
+ params: params,
67
+ opts: opts
68
+ )
69
+ end
70
+
71
+ # Deactivates this alert, preventing it from triggering.
72
+ def self.deactivate(id, params = {}, opts = {})
73
+ request_stripe_object(
74
+ method: :post,
75
+ path: format("/v1/billing/alerts/%<id>s/deactivate", { id: CGI.escape(id) }),
76
+ params: params,
77
+ opts: opts
78
+ )
79
+ end
80
+
81
+ # Lists billing active and inactive alerts
82
+ def self.list(filters = {}, opts = {})
83
+ request_stripe_object(method: :get, path: "/v1/billing/alerts", params: filters, opts: opts)
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,83 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Billing
6
+ # A billing meter is a resource that allows you to track usage of a particular event. For example, you might create a billing meter to track the number of API calls made by a particular user. You can then attach the billing meter to a price and attach the price to a subscription to charge the user for the number of API calls they make.
7
+ class Meter < APIResource
8
+ extend Stripe::APIOperations::Create
9
+ extend Stripe::APIOperations::List
10
+ extend Stripe::APIOperations::NestedResource
11
+ include Stripe::APIOperations::Save
12
+
13
+ OBJECT_NAME = "billing.meter"
14
+ def self.object_name
15
+ "billing.meter"
16
+ end
17
+
18
+ nested_resource_class_methods :event_summary,
19
+ operations: %i[list],
20
+ resource_plural: "event_summaries"
21
+
22
+ # Creates a billing meter
23
+ def self.create(params = {}, opts = {})
24
+ request_stripe_object(method: :post, path: "/v1/billing/meters", params: params, opts: opts)
25
+ end
26
+
27
+ # Deactivates a billing meter
28
+ def deactivate(params = {}, opts = {})
29
+ request_stripe_object(
30
+ method: :post,
31
+ path: format("/v1/billing/meters/%<id>s/deactivate", { id: CGI.escape(self["id"]) }),
32
+ params: params,
33
+ opts: opts
34
+ )
35
+ end
36
+
37
+ # Deactivates a billing meter
38
+ def self.deactivate(id, params = {}, opts = {})
39
+ request_stripe_object(
40
+ method: :post,
41
+ path: format("/v1/billing/meters/%<id>s/deactivate", { id: CGI.escape(id) }),
42
+ params: params,
43
+ opts: opts
44
+ )
45
+ end
46
+
47
+ # Retrieve a list of billing meters.
48
+ def self.list(filters = {}, opts = {})
49
+ request_stripe_object(method: :get, path: "/v1/billing/meters", params: filters, opts: opts)
50
+ end
51
+
52
+ # Reactivates a billing meter
53
+ def reactivate(params = {}, opts = {})
54
+ request_stripe_object(
55
+ method: :post,
56
+ path: format("/v1/billing/meters/%<id>s/reactivate", { id: CGI.escape(self["id"]) }),
57
+ params: params,
58
+ opts: opts
59
+ )
60
+ end
61
+
62
+ # Reactivates a billing meter
63
+ def self.reactivate(id, params = {}, opts = {})
64
+ request_stripe_object(
65
+ method: :post,
66
+ path: format("/v1/billing/meters/%<id>s/reactivate", { id: CGI.escape(id) }),
67
+ params: params,
68
+ opts: opts
69
+ )
70
+ end
71
+
72
+ # Updates a billing meter
73
+ def self.update(id, params = {}, opts = {})
74
+ request_stripe_object(
75
+ method: :post,
76
+ path: format("/v1/billing/meters/%<id>s", { id: CGI.escape(id) }),
77
+ params: params,
78
+ opts: opts
79
+ )
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,27 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Billing
6
+ # A billing meter event represents a customer's usage of a product. Meter events are used to bill a customer based on their usage.
7
+ # Meter events are associated with billing meters, which define the shape of the event's payload and how those events are aggregated for billing.
8
+ class MeterEvent < APIResource
9
+ extend Stripe::APIOperations::Create
10
+
11
+ OBJECT_NAME = "billing.meter_event"
12
+ def self.object_name
13
+ "billing.meter_event"
14
+ end
15
+
16
+ # Creates a billing meter event
17
+ def self.create(params = {}, opts = {})
18
+ request_stripe_object(
19
+ method: :post,
20
+ path: "/v1/billing/meter_events",
21
+ params: params,
22
+ opts: opts
23
+ )
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Billing
6
+ # A billing meter event adjustment is a resource that allows you to cancel a meter event. For example, you might create a billing meter event adjustment to cancel a meter event that was created in error or attached to the wrong customer.
7
+ class MeterEventAdjustment < APIResource
8
+ extend Stripe::APIOperations::Create
9
+
10
+ OBJECT_NAME = "billing.meter_event_adjustment"
11
+ def self.object_name
12
+ "billing.meter_event_adjustment"
13
+ end
14
+
15
+ # Creates a billing meter event adjustment
16
+ def self.create(params = {}, opts = {})
17
+ request_stripe_object(
18
+ method: :post,
19
+ path: "/v1/billing/meter_event_adjustments",
20
+ params: params,
21
+ opts: opts
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,15 @@
1
+ # File generated from our OpenAPI spec
2
+ # frozen_string_literal: true
3
+
4
+ module Stripe
5
+ module Billing
6
+ # A billing meter event summary represents an aggregated view of a customer's billing meter events within a specified timeframe. It indicates how much
7
+ # usage was accrued by a customer for that period.
8
+ class MeterEventSummary < APIResource
9
+ OBJECT_NAME = "billing.meter_event_summary"
10
+ def self.object_name
11
+ "billing.meter_event_summary"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -10,6 +10,39 @@ module Stripe
10
10
  include Stripe::APIOperations::Save
11
11
 
12
12
  OBJECT_NAME = "billing_portal.configuration"
13
+ def self.object_name
14
+ "billing_portal.configuration"
15
+ end
16
+
17
+ # Creates a configuration that describes the functionality and behavior of a PortalSession
18
+ def self.create(params = {}, opts = {})
19
+ request_stripe_object(
20
+ method: :post,
21
+ path: "/v1/billing_portal/configurations",
22
+ params: params,
23
+ opts: opts
24
+ )
25
+ end
26
+
27
+ # Returns a list of configurations that describe the functionality of the customer portal.
28
+ def self.list(filters = {}, opts = {})
29
+ request_stripe_object(
30
+ method: :get,
31
+ path: "/v1/billing_portal/configurations",
32
+ params: filters,
33
+ opts: opts
34
+ )
35
+ end
36
+
37
+ # Updates a configuration that describes the functionality of the customer portal.
38
+ def self.update(id, params = {}, opts = {})
39
+ request_stripe_object(
40
+ method: :post,
41
+ path: format("/v1/billing_portal/configurations/%<id>s", { id: CGI.escape(id) }),
42
+ params: params,
43
+ opts: opts
44
+ )
45
+ end
13
46
  end
14
47
  end
15
48
  end
@@ -16,11 +16,24 @@ module Stripe
16
16
  # Create sessions on-demand when customers intend to manage their subscriptions
17
17
  # and billing details.
18
18
  #
19
- # Learn more in the [integration guide](https://stripe.com/docs/billing/subscriptions/integrating-customer-portal).
19
+ # Related guide: [Customer management](https://stripe.com/customer-management)
20
20
  class Session < APIResource
21
21
  extend Stripe::APIOperations::Create
22
22
 
23
23
  OBJECT_NAME = "billing_portal.session"
24
+ def self.object_name
25
+ "billing_portal.session"
26
+ end
27
+
28
+ # Creates a session of the customer portal.
29
+ def self.create(params = {}, opts = {})
30
+ request_stripe_object(
31
+ method: :post,
32
+ path: "/v1/billing_portal/sessions",
33
+ params: params,
34
+ opts: opts
35
+ )
36
+ end
24
37
  end
25
38
  end
26
39
  end
@@ -6,10 +6,12 @@ module Stripe
6
6
  #
7
7
  # Related guide: [Account capabilities](https://stripe.com/docs/connect/account-capabilities)
8
8
  class Capability < APIResource
9
- extend Stripe::APIOperations::List
10
9
  include Stripe::APIOperations::Save
11
10
 
12
11
  OBJECT_NAME = "capability"
12
+ def self.object_name
13
+ "capability"
14
+ end
13
15
 
14
16
  def resource_url
15
17
  if !respond_to?(:account) || account.nil?
@@ -17,7 +19,7 @@ module Stripe
17
19
  "Capabilities cannot be accessed without an account ID."
18
20
  end
19
21
  "#{Account.resource_url}/#{CGI.escape(account)}/capabilities" \
20
- "/#{CGI.escape(id)}"
22
+ "/#{CGI.escape(id)}"
21
23
  end
22
24
 
23
25
  def self.retrieve(_id, _opts = {})
@@ -13,6 +13,9 @@ module Stripe
13
13
  include Stripe::APIOperations::Save
14
14
 
15
15
  OBJECT_NAME = "card"
16
+ def self.object_name
17
+ "card"
18
+ end
16
19
 
17
20
  def resource_url
18
21
  if respond_to?(:customer) && !customer.nil? && !customer.empty?
@@ -37,5 +40,30 @@ module Stripe
37
40
  "'customer_id', 'card_id')` or " \
38
41
  "`Account.retrieve_external_account('account_id', 'card_id')`"
39
42
  end
43
+
44
+ def self.delete(id, params = {}, opts = {})
45
+ raise NotImplementedError,
46
+ "Card cannot be deleted without a customer ID or an account " \
47
+ "ID. Delete a card using `Customer.delete_source(" \
48
+ "'customer_id', 'card_id')` or " \
49
+ "`Account.delete_external_account('account_id', 'card_id')`"
50
+ end
51
+
52
+ def delete(params = {}, opts = {})
53
+ request_stripe_object(
54
+ method: :delete,
55
+ path: resource_url.to_s,
56
+ params: params,
57
+ opts: opts
58
+ )
59
+ end
60
+
61
+ def self.list(filters = {}, opts = {})
62
+ raise NotImplementedError,
63
+ "Cards cannot be listed without a customer ID or an account " \
64
+ "ID. List cards using `Customer.list_sources(" \
65
+ "'customer_id')` or " \
66
+ "`Account.list_external_accounts('account_id')`"
67
+ end
40
68
  end
41
69
  end
@@ -5,6 +5,9 @@ module Stripe
5
5
  # A customer's `Cash balance` represents real funds. Customers can add funds to their cash balance by sending a bank transfer. These funds can be used for payment and can eventually be paid out to your bank account.
6
6
  class CashBalance < APIResource
7
7
  OBJECT_NAME = "cash_balance"
8
+ def self.object_name
9
+ "cash_balance"
10
+ end
8
11
 
9
12
  def resource_url
10
13
  if !respond_to?(:customer) || customer.nil?
@@ -9,11 +9,22 @@ module Stripe
9
9
  class Charge < APIResource
10
10
  extend Stripe::APIOperations::Create
11
11
  extend Stripe::APIOperations::List
12
+ extend Stripe::APIOperations::NestedResource
12
13
  extend Stripe::APIOperations::Search
13
14
  include Stripe::APIOperations::Save
14
15
 
15
16
  OBJECT_NAME = "charge"
17
+ def self.object_name
18
+ "charge"
19
+ end
20
+
21
+ nested_resource_class_methods :refund, operations: %i[retrieve list]
16
22
 
23
+ # Capture the payment of an existing, uncaptured charge that was created with the capture option set to false.
24
+ #
25
+ # Uncaptured payments expire a set number of days after they are created ([7 by default](https://stripe.com/docs/charges/placing-a-hold)), after which they are marked as refunded and capture attempts will fail.
26
+ #
27
+ # Don't use this method to capture a PaymentIntent-initiated charge. Use [Capture a PaymentIntent](https://stripe.com/docs/api/payment_intents/capture).
17
28
  def capture(params = {}, opts = {})
18
29
  request_stripe_object(
19
30
  method: :post,
@@ -23,6 +34,11 @@ module Stripe
23
34
  )
24
35
  end
25
36
 
37
+ # Capture the payment of an existing, uncaptured charge that was created with the capture option set to false.
38
+ #
39
+ # Uncaptured payments expire a set number of days after they are created ([7 by default](https://stripe.com/docs/charges/placing-a-hold)), after which they are marked as refunded and capture attempts will fail.
40
+ #
41
+ # Don't use this method to capture a PaymentIntent-initiated charge. Use [Capture a PaymentIntent](https://stripe.com/docs/api/payment_intents/capture).
26
42
  def self.capture(charge, params = {}, opts = {})
27
43
  request_stripe_object(
28
44
  method: :post,
@@ -32,12 +48,34 @@ module Stripe
32
48
  )
33
49
  end
34
50
 
51
+ # This method is no longer recommended—use the [Payment Intents API](https://stripe.com/docs/api/payment_intents)
52
+ # to initiate a new payment instead. Confirmation of the PaymentIntent creates the Charge
53
+ # object used to request payment.
54
+ def self.create(params = {}, opts = {})
55
+ request_stripe_object(method: :post, path: "/v1/charges", params: params, opts: opts)
56
+ end
57
+
58
+ # Returns a list of charges you've previously created. The charges are returned in sorted order, with the most recent charges appearing first.
59
+ def self.list(filters = {}, opts = {})
60
+ request_stripe_object(method: :get, path: "/v1/charges", params: filters, opts: opts)
61
+ end
62
+
35
63
  def self.search(params = {}, opts = {})
36
- _search("/v1/charges/search", params, opts)
64
+ request_stripe_object(method: :get, path: "/v1/charges/search", params: params, opts: opts)
37
65
  end
38
66
 
39
67
  def self.search_auto_paging_each(params = {}, opts = {}, &blk)
40
68
  search(params, opts).auto_paging_each(&blk)
41
69
  end
70
+
71
+ # Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
72
+ def self.update(id, params = {}, opts = {})
73
+ request_stripe_object(
74
+ method: :post,
75
+ path: format("/v1/charges/%<id>s", { id: CGI.escape(id) }),
76
+ params: params,
77
+ opts: opts
78
+ )
79
+ end
42
80
  end
43
81
  end
@@ -20,27 +20,38 @@ module Stripe
20
20
  class Session < APIResource
21
21
  extend Stripe::APIOperations::Create
22
22
  extend Stripe::APIOperations::List
23
+ include Stripe::APIOperations::Save
23
24
 
24
25
  OBJECT_NAME = "checkout.session"
26
+ def self.object_name
27
+ "checkout.session"
28
+ end
25
29
 
26
- def expire(params = {}, opts = {})
30
+ # Creates a Session object.
31
+ def self.create(params = {}, opts = {})
27
32
  request_stripe_object(
28
33
  method: :post,
29
- path: format("/v1/checkout/sessions/%<session>s/expire", { session: CGI.escape(self["id"]) }),
34
+ path: "/v1/checkout/sessions",
30
35
  params: params,
31
36
  opts: opts
32
37
  )
33
38
  end
34
39
 
35
- def list_line_items(params = {}, opts = {})
40
+ # A Session can be expired when it is in one of these statuses: open
41
+ #
42
+ # After it expires, a customer can't complete a Session and customers loading the Session see a message saying the Session is expired.
43
+ def expire(params = {}, opts = {})
36
44
  request_stripe_object(
37
- method: :get,
38
- path: format("/v1/checkout/sessions/%<session>s/line_items", { session: CGI.escape(self["id"]) }),
45
+ method: :post,
46
+ path: format("/v1/checkout/sessions/%<session>s/expire", { session: CGI.escape(self["id"]) }),
39
47
  params: params,
40
48
  opts: opts
41
49
  )
42
50
  end
43
51
 
52
+ # A Session can be expired when it is in one of these statuses: open
53
+ #
54
+ # After it expires, a customer can't complete a Session and customers loading the Session see a message saying the Session is expired.
44
55
  def self.expire(session, params = {}, opts = {})
45
56
  request_stripe_object(
46
57
  method: :post,
@@ -50,6 +61,27 @@ module Stripe
50
61
  )
51
62
  end
52
63
 
64
+ # Returns a list of Checkout Sessions.
65
+ def self.list(filters = {}, opts = {})
66
+ request_stripe_object(
67
+ method: :get,
68
+ path: "/v1/checkout/sessions",
69
+ params: filters,
70
+ opts: opts
71
+ )
72
+ end
73
+
74
+ # When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
75
+ def list_line_items(params = {}, opts = {})
76
+ request_stripe_object(
77
+ method: :get,
78
+ path: format("/v1/checkout/sessions/%<session>s/line_items", { session: CGI.escape(self["id"]) }),
79
+ params: params,
80
+ opts: opts
81
+ )
82
+ end
83
+
84
+ # When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
53
85
  def self.list_line_items(session, params = {}, opts = {})
54
86
  request_stripe_object(
55
87
  method: :get,
@@ -58,6 +90,16 @@ module Stripe
58
90
  opts: opts
59
91
  )
60
92
  end
93
+
94
+ # Updates a Session object.
95
+ def self.update(id, params = {}, opts = {})
96
+ request_stripe_object(
97
+ method: :post,
98
+ path: format("/v1/checkout/sessions/%<id>s", { id: CGI.escape(id) }),
99
+ params: params,
100
+ opts: opts
101
+ )
102
+ end
61
103
  end
62
104
  end
63
105
  end