stripe 5.55.0 → 8.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +122 -2
- data/Gemfile +1 -0
- data/Makefile +1 -1
- data/OPENAPI_VERSION +1 -0
- data/README.md +37 -3
- data/VERSION +1 -1
- data/lib/data/ca-certificates.crt +1241 -1937
- data/lib/stripe/api_operations/create.rb +6 -2
- data/lib/stripe/api_operations/delete.rb +12 -7
- data/lib/stripe/api_operations/list.rb +6 -9
- data/lib/stripe/api_operations/nested_resource.rb +62 -34
- data/lib/stripe/api_operations/request.rb +10 -0
- data/lib/stripe/api_operations/save.rb +11 -3
- data/lib/stripe/api_operations/search.rb +6 -9
- data/lib/stripe/api_resource.rb +1 -1
- data/lib/stripe/api_resource_test_helpers.rb +2 -0
- data/lib/stripe/api_version.rb +8 -0
- data/lib/stripe/instrumentation.rb +45 -7
- data/lib/stripe/object_types.rb +12 -10
- data/lib/stripe/resources/account.rb +36 -9
- data/lib/stripe/resources/account_link.rb +4 -0
- data/lib/stripe/resources/application_fee_refund.rb +5 -0
- data/lib/stripe/resources/apps/secret.rb +40 -0
- data/lib/stripe/resources/balance.rb +11 -0
- data/lib/stripe/resources/balance_transaction.rb +4 -0
- data/lib/stripe/resources/bank_account.rb +7 -0
- data/lib/stripe/resources/billing_portal/configuration.rb +1 -0
- data/lib/stripe/resources/billing_portal/session.rb +14 -0
- data/lib/stripe/resources/capability.rb +3 -0
- data/lib/stripe/resources/card.rb +6 -3
- data/lib/stripe/resources/cash_balance.rb +1 -0
- data/lib/stripe/resources/charge.rb +15 -3
- data/lib/stripe/resources/checkout/session.rb +41 -5
- data/lib/stripe/resources/country_spec.rb +6 -0
- data/lib/stripe/resources/coupon.rb +3 -0
- data/lib/stripe/resources/credit_note.rb +27 -9
- data/lib/stripe/resources/customer.rb +109 -19
- data/lib/stripe/resources/customer_balance_transaction.rb +6 -0
- data/lib/stripe/resources/customer_cash_balance_transaction.rb +14 -0
- data/lib/stripe/resources/discount.rb +4 -0
- data/lib/stripe/resources/dispute.rb +17 -3
- data/lib/stripe/resources/event.rb +29 -0
- data/lib/stripe/resources/exchange_rate.rb +11 -0
- data/lib/stripe/resources/file.rb +7 -0
- data/lib/stripe/resources/file_link.rb +3 -0
- data/lib/stripe/resources/financial_connections/account.rb +42 -6
- data/lib/stripe/resources/financial_connections/account_ownership.rb +1 -0
- data/lib/stripe/resources/financial_connections/session.rb +1 -0
- data/lib/stripe/resources/funding_instructions.rb +5 -0
- data/lib/stripe/resources/identity/verification_report.rb +11 -0
- data/lib/stripe/resources/identity/verification_session.rb +31 -5
- data/lib/stripe/resources/invoice.rb +96 -17
- data/lib/stripe/resources/invoice_item.rb +11 -0
- data/lib/stripe/resources/issuing/authorization.rb +25 -5
- data/lib/stripe/resources/issuing/card.rb +78 -8
- data/lib/stripe/resources/issuing/cardholder.rb +3 -0
- data/lib/stripe/resources/issuing/dispute.rb +13 -3
- data/lib/stripe/resources/issuing/transaction.rb +5 -0
- data/lib/stripe/resources/line_item.rb +1 -0
- data/lib/stripe/resources/mandate.rb +1 -0
- data/lib/stripe/resources/payment_intent.rb +71 -13
- data/lib/stripe/resources/payment_link.rb +15 -3
- data/lib/stripe/resources/payment_method.rb +25 -5
- data/lib/stripe/resources/payout.rb +28 -5
- data/lib/stripe/resources/person.rb +6 -0
- data/lib/stripe/resources/plan.rb +8 -0
- data/lib/stripe/resources/price.rb +6 -0
- data/lib/stripe/resources/product.rb +8 -0
- data/lib/stripe/resources/promotion_code.rb +2 -0
- data/lib/stripe/resources/quote.rb +52 -11
- data/lib/stripe/resources/radar/early_fraud_warning.rb +4 -0
- data/lib/stripe/resources/radar/value_list.rb +3 -0
- data/lib/stripe/resources/radar/value_list_item.rb +3 -0
- data/lib/stripe/resources/refund.rb +24 -5
- data/lib/stripe/resources/reporting/report_run.rb +8 -0
- data/lib/stripe/resources/reporting/report_type.rb +8 -1
- data/lib/stripe/resources/reversal.rb +13 -0
- data/lib/stripe/resources/review.rb +14 -3
- data/lib/stripe/resources/setup_attempt.rb +4 -0
- data/lib/stripe/resources/setup_intent.rb +52 -7
- data/lib/stripe/resources/shipping_rate.rb +3 -0
- data/lib/stripe/resources/sigma/scheduled_query_run.rb +4 -0
- data/lib/stripe/resources/source.rb +26 -6
- data/lib/stripe/resources/source_transaction.rb +4 -0
- data/lib/stripe/resources/subscription.rb +48 -3
- data/lib/stripe/resources/subscription_item.rb +2 -7
- data/lib/stripe/resources/subscription_schedule.rb +23 -5
- data/lib/stripe/resources/tax_code.rb +1 -0
- data/lib/stripe/resources/tax_id.rb +4 -0
- data/lib/stripe/resources/tax_rate.rb +3 -0
- data/lib/stripe/resources/terminal/configuration.rb +1 -0
- data/lib/stripe/resources/terminal/connection_token.rb +3 -0
- data/lib/stripe/resources/terminal/location.rb +3 -0
- data/lib/stripe/resources/terminal/reader.rb +70 -11
- data/lib/stripe/resources/test_helpers/test_clock.rb +13 -3
- data/lib/stripe/resources/token.rb +22 -0
- data/lib/stripe/resources/topup.rb +15 -3
- data/lib/stripe/resources/transfer.rb +10 -11
- data/lib/stripe/resources/treasury/credit_reversal.rb +14 -0
- data/lib/stripe/resources/treasury/debit_reversal.rb +14 -0
- data/lib/stripe/resources/treasury/financial_account.rb +52 -0
- data/lib/stripe/resources/treasury/inbound_transfer.rb +94 -0
- data/lib/stripe/resources/treasury/outbound_payment.rb +96 -0
- data/lib/stripe/resources/treasury/outbound_transfer.rb +100 -0
- data/lib/stripe/resources/treasury/received_credit.rb +30 -0
- data/lib/stripe/resources/treasury/received_debit.rb +30 -0
- data/lib/stripe/resources/treasury/transaction.rb +13 -0
- data/lib/stripe/resources/treasury/transaction_entry.rb +17 -0
- data/lib/stripe/resources/usage_record.rb +4 -0
- data/lib/stripe/resources/webhook_endpoint.rb +7 -0
- data/lib/stripe/resources.rb +12 -10
- data/lib/stripe/stripe_client.rb +25 -17
- data/lib/stripe/stripe_object.rb +2 -2
- data/lib/stripe/util.rb +38 -3
- data/lib/stripe/version.rb +1 -1
- metadata +17 -11
- data/lib/stripe/resources/bitcoin_receiver.rb +0 -24
- data/lib/stripe/resources/bitcoin_transaction.rb +0 -16
- data/lib/stripe/resources/issuing/card_details.rb +0 -10
- data/lib/stripe/resources/order.rb +0 -33
- data/lib/stripe/resources/order_return.rb +0 -10
- data/lib/stripe/resources/recipient.rb +0 -14
- data/lib/stripe/resources/sku.rb +0 -13
- data/lib/stripe/resources/three_d_secure.rb +0 -14
@@ -0,0 +1,96 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
module Treasury
|
6
|
+
# Use OutboundPayments to send funds to another party's external bank account or [FinancialAccount](https://stripe.com/docs/api#financial_accounts). To send money to an account belonging to the same user, use an [OutboundTransfer](https://stripe.com/docs/api#outbound_transfers).
|
7
|
+
#
|
8
|
+
# Simulate OutboundPayment state changes with the `/v1/test_helpers/treasury/outbound_payments` endpoints. These methods can only be called on test mode objects.
|
9
|
+
class OutboundPayment < APIResource
|
10
|
+
extend Stripe::APIOperations::Create
|
11
|
+
extend Stripe::APIOperations::List
|
12
|
+
|
13
|
+
OBJECT_NAME = "treasury.outbound_payment"
|
14
|
+
|
15
|
+
def cancel(params = {}, opts = {})
|
16
|
+
request_stripe_object(
|
17
|
+
method: :post,
|
18
|
+
path: format("/v1/treasury/outbound_payments/%<id>s/cancel", { id: CGI.escape(self["id"]) }),
|
19
|
+
params: params,
|
20
|
+
opts: opts
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.cancel(id, params = {}, opts = {})
|
25
|
+
request_stripe_object(
|
26
|
+
method: :post,
|
27
|
+
path: format("/v1/treasury/outbound_payments/%<id>s/cancel", { id: CGI.escape(id) }),
|
28
|
+
params: params,
|
29
|
+
opts: opts
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_helpers
|
34
|
+
TestHelpers.new(self)
|
35
|
+
end
|
36
|
+
|
37
|
+
class TestHelpers < APIResourceTestHelpers
|
38
|
+
RESOURCE_CLASS = OutboundPayment
|
39
|
+
|
40
|
+
def self.fail(id, params = {}, opts = {})
|
41
|
+
request_stripe_object(
|
42
|
+
method: :post,
|
43
|
+
path: format("/v1/test_helpers/treasury/outbound_payments/%<id>s/fail", { id: CGI.escape(id) }),
|
44
|
+
params: params,
|
45
|
+
opts: opts
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.post(id, params = {}, opts = {})
|
50
|
+
request_stripe_object(
|
51
|
+
method: :post,
|
52
|
+
path: format("/v1/test_helpers/treasury/outbound_payments/%<id>s/post", { id: CGI.escape(id) }),
|
53
|
+
params: params,
|
54
|
+
opts: opts
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.return_outbound_payment(id, params = {}, opts = {})
|
59
|
+
request_stripe_object(
|
60
|
+
method: :post,
|
61
|
+
path: format("/v1/test_helpers/treasury/outbound_payments/%<id>s/return", { id: CGI.escape(id) }),
|
62
|
+
params: params,
|
63
|
+
opts: opts
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
def fail(params = {}, opts = {})
|
68
|
+
@resource.request_stripe_object(
|
69
|
+
method: :post,
|
70
|
+
path: format("/v1/test_helpers/treasury/outbound_payments/%<id>s/fail", { id: CGI.escape(@resource["id"]) }),
|
71
|
+
params: params,
|
72
|
+
opts: opts
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
def post(params = {}, opts = {})
|
77
|
+
@resource.request_stripe_object(
|
78
|
+
method: :post,
|
79
|
+
path: format("/v1/test_helpers/treasury/outbound_payments/%<id>s/post", { id: CGI.escape(@resource["id"]) }),
|
80
|
+
params: params,
|
81
|
+
opts: opts
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
def return_outbound_payment(params = {}, opts = {})
|
86
|
+
@resource.request_stripe_object(
|
87
|
+
method: :post,
|
88
|
+
path: format("/v1/test_helpers/treasury/outbound_payments/%<id>s/return", { id: CGI.escape(@resource["id"]) }),
|
89
|
+
params: params,
|
90
|
+
opts: opts
|
91
|
+
)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
module Treasury
|
6
|
+
# Use OutboundTransfers to transfer funds from a [FinancialAccount](https://stripe.com/docs/api#financial_accounts) to a PaymentMethod belonging to the same entity. To send funds to a different party, use [OutboundPayments](https://stripe.com/docs/api#outbound_payments) instead. You can send funds over ACH rails or through a domestic wire transfer to a user's own external bank account.
|
7
|
+
#
|
8
|
+
# Simulate OutboundTransfer state changes with the `/v1/test_helpers/treasury/outbound_transfers` endpoints. These methods can only be called on test mode objects.
|
9
|
+
class OutboundTransfer < APIResource
|
10
|
+
extend Stripe::APIOperations::Create
|
11
|
+
extend Stripe::APIOperations::List
|
12
|
+
|
13
|
+
OBJECT_NAME = "treasury.outbound_transfer"
|
14
|
+
|
15
|
+
def cancel(params = {}, opts = {})
|
16
|
+
request_stripe_object(
|
17
|
+
method: :post,
|
18
|
+
path: format("/v1/treasury/outbound_transfers/%<outbound_transfer>s/cancel", { outbound_transfer: CGI.escape(self["id"]) }),
|
19
|
+
params: params,
|
20
|
+
opts: opts
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.cancel(outbound_transfer, params = {}, opts = {})
|
25
|
+
request_stripe_object(
|
26
|
+
method: :post,
|
27
|
+
path: format("/v1/treasury/outbound_transfers/%<outbound_transfer>s/cancel", { outbound_transfer: CGI.escape(outbound_transfer) }),
|
28
|
+
params: params,
|
29
|
+
opts: opts
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_helpers
|
34
|
+
TestHelpers.new(self)
|
35
|
+
end
|
36
|
+
|
37
|
+
class TestHelpers < APIResourceTestHelpers
|
38
|
+
RESOURCE_CLASS = OutboundTransfer
|
39
|
+
|
40
|
+
def self.fail(outbound_transfer, params = {}, opts = {})
|
41
|
+
request_stripe_object(
|
42
|
+
method: :post,
|
43
|
+
path: format("/v1/test_helpers/treasury/outbound_transfers/%<outbound_transfer>s/fail", { outbound_transfer: CGI.escape(outbound_transfer) }),
|
44
|
+
params: params,
|
45
|
+
opts: opts
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.post(outbound_transfer, params = {}, opts = {})
|
50
|
+
request_stripe_object(
|
51
|
+
method: :post,
|
52
|
+
path: format("/v1/test_helpers/treasury/outbound_transfers/%<outbound_transfer>s/post", { outbound_transfer: CGI.escape(outbound_transfer) }),
|
53
|
+
params: params,
|
54
|
+
opts: opts
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.return_outbound_transfer(
|
59
|
+
outbound_transfer,
|
60
|
+
params = {},
|
61
|
+
opts = {}
|
62
|
+
)
|
63
|
+
request_stripe_object(
|
64
|
+
method: :post,
|
65
|
+
path: format("/v1/test_helpers/treasury/outbound_transfers/%<outbound_transfer>s/return", { outbound_transfer: CGI.escape(outbound_transfer) }),
|
66
|
+
params: params,
|
67
|
+
opts: opts
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
def fail(params = {}, opts = {})
|
72
|
+
@resource.request_stripe_object(
|
73
|
+
method: :post,
|
74
|
+
path: format("/v1/test_helpers/treasury/outbound_transfers/%<outbound_transfer>s/fail", { outbound_transfer: CGI.escape(@resource["id"]) }),
|
75
|
+
params: params,
|
76
|
+
opts: opts
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
def post(params = {}, opts = {})
|
81
|
+
@resource.request_stripe_object(
|
82
|
+
method: :post,
|
83
|
+
path: format("/v1/test_helpers/treasury/outbound_transfers/%<outbound_transfer>s/post", { outbound_transfer: CGI.escape(@resource["id"]) }),
|
84
|
+
params: params,
|
85
|
+
opts: opts
|
86
|
+
)
|
87
|
+
end
|
88
|
+
|
89
|
+
def return_outbound_transfer(params = {}, opts = {})
|
90
|
+
@resource.request_stripe_object(
|
91
|
+
method: :post,
|
92
|
+
path: format("/v1/test_helpers/treasury/outbound_transfers/%<outbound_transfer>s/return", { outbound_transfer: CGI.escape(@resource["id"]) }),
|
93
|
+
params: params,
|
94
|
+
opts: opts
|
95
|
+
)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
module Treasury
|
6
|
+
# ReceivedCredits represent funds sent to a [FinancialAccount](https://stripe.com/docs/api#financial_accounts) (for example, via ACH or wire). These money movements are not initiated from the FinancialAccount.
|
7
|
+
class ReceivedCredit < APIResource
|
8
|
+
extend Stripe::APIOperations::List
|
9
|
+
|
10
|
+
OBJECT_NAME = "treasury.received_credit"
|
11
|
+
|
12
|
+
def test_helpers
|
13
|
+
TestHelpers.new(self)
|
14
|
+
end
|
15
|
+
|
16
|
+
class TestHelpers < APIResourceTestHelpers
|
17
|
+
RESOURCE_CLASS = ReceivedCredit
|
18
|
+
|
19
|
+
def self.create(params = {}, opts = {})
|
20
|
+
request_stripe_object(
|
21
|
+
method: :post,
|
22
|
+
path: "/v1/test_helpers/treasury/received_credits",
|
23
|
+
params: params,
|
24
|
+
opts: opts
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
module Treasury
|
6
|
+
# ReceivedDebits represent funds pulled from a [FinancialAccount](https://stripe.com/docs/api#financial_accounts). These are not initiated from the FinancialAccount.
|
7
|
+
class ReceivedDebit < APIResource
|
8
|
+
extend Stripe::APIOperations::List
|
9
|
+
|
10
|
+
OBJECT_NAME = "treasury.received_debit"
|
11
|
+
|
12
|
+
def test_helpers
|
13
|
+
TestHelpers.new(self)
|
14
|
+
end
|
15
|
+
|
16
|
+
class TestHelpers < APIResourceTestHelpers
|
17
|
+
RESOURCE_CLASS = ReceivedDebit
|
18
|
+
|
19
|
+
def self.create(params = {}, opts = {})
|
20
|
+
request_stripe_object(
|
21
|
+
method: :post,
|
22
|
+
path: "/v1/test_helpers/treasury/received_debits",
|
23
|
+
params: params,
|
24
|
+
opts: opts
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
module Treasury
|
6
|
+
# Transactions represent changes to a [FinancialAccount's](https://stripe.com/docs/api#financial_accounts) balance.
|
7
|
+
class Transaction < APIResource
|
8
|
+
extend Stripe::APIOperations::List
|
9
|
+
|
10
|
+
OBJECT_NAME = "treasury.transaction"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
module Treasury
|
6
|
+
# TransactionEntries represent individual units of money movements within a single [Transaction](https://stripe.com/docs/api#transactions).
|
7
|
+
class TransactionEntry < APIResource
|
8
|
+
extend Stripe::APIOperations::List
|
9
|
+
|
10
|
+
OBJECT_NAME = "treasury.transaction_entry"
|
11
|
+
|
12
|
+
def self.resource_url
|
13
|
+
"/v1/treasury/transaction_entries"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -2,6 +2,10 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module Stripe
|
5
|
+
# Usage records allow you to report customer usage and metrics to Stripe for
|
6
|
+
# metered billing of subscription prices.
|
7
|
+
#
|
8
|
+
# Related guide: [Metered Billing](https://stripe.com/docs/billing/subscriptions/metered-billing).
|
5
9
|
class UsageRecord < APIResource
|
6
10
|
OBJECT_NAME = "usage_record"
|
7
11
|
end
|
@@ -2,6 +2,13 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module Stripe
|
5
|
+
# You can configure [webhook endpoints](https://stripe.com/docs/webhooks/) via the API to be
|
6
|
+
# notified about events that happen in your Stripe account or connected
|
7
|
+
# accounts.
|
8
|
+
#
|
9
|
+
# Most users configure webhooks from [the dashboard](https://dashboard.stripe.com/webhooks), which provides a user interface for registering and testing your webhook endpoints.
|
10
|
+
#
|
11
|
+
# Related guide: [Setting up Webhooks](https://stripe.com/docs/webhooks/configure).
|
5
12
|
class WebhookEndpoint < APIResource
|
6
13
|
extend Stripe::APIOperations::Create
|
7
14
|
include Stripe::APIOperations::Delete
|
data/lib/stripe/resources.rb
CHANGED
@@ -3,17 +3,15 @@
|
|
3
3
|
|
4
4
|
require "stripe/resources/account"
|
5
5
|
require "stripe/resources/account_link"
|
6
|
-
require "stripe/resources/alipay_account"
|
7
6
|
require "stripe/resources/apple_pay_domain"
|
8
7
|
require "stripe/resources/application_fee"
|
9
8
|
require "stripe/resources/application_fee_refund"
|
9
|
+
require "stripe/resources/apps/secret"
|
10
10
|
require "stripe/resources/balance"
|
11
11
|
require "stripe/resources/balance_transaction"
|
12
12
|
require "stripe/resources/bank_account"
|
13
13
|
require "stripe/resources/billing_portal/configuration"
|
14
14
|
require "stripe/resources/billing_portal/session"
|
15
|
-
require "stripe/resources/bitcoin_receiver"
|
16
|
-
require "stripe/resources/bitcoin_transaction"
|
17
15
|
require "stripe/resources/capability"
|
18
16
|
require "stripe/resources/card"
|
19
17
|
require "stripe/resources/cash_balance"
|
@@ -25,6 +23,7 @@ require "stripe/resources/credit_note"
|
|
25
23
|
require "stripe/resources/credit_note_line_item"
|
26
24
|
require "stripe/resources/customer"
|
27
25
|
require "stripe/resources/customer_balance_transaction"
|
26
|
+
require "stripe/resources/customer_cash_balance_transaction"
|
28
27
|
require "stripe/resources/discount"
|
29
28
|
require "stripe/resources/dispute"
|
30
29
|
require "stripe/resources/ephemeral_key"
|
@@ -44,15 +43,12 @@ require "stripe/resources/invoice_item"
|
|
44
43
|
require "stripe/resources/invoice_line_item"
|
45
44
|
require "stripe/resources/issuing/authorization"
|
46
45
|
require "stripe/resources/issuing/card"
|
47
|
-
require "stripe/resources/issuing/card_details"
|
48
46
|
require "stripe/resources/issuing/cardholder"
|
49
47
|
require "stripe/resources/issuing/dispute"
|
50
48
|
require "stripe/resources/issuing/transaction"
|
51
49
|
require "stripe/resources/line_item"
|
52
50
|
require "stripe/resources/login_link"
|
53
51
|
require "stripe/resources/mandate"
|
54
|
-
require "stripe/resources/order"
|
55
|
-
require "stripe/resources/order_return"
|
56
52
|
require "stripe/resources/payment_intent"
|
57
53
|
require "stripe/resources/payment_link"
|
58
54
|
require "stripe/resources/payment_method"
|
@@ -66,8 +62,6 @@ require "stripe/resources/quote"
|
|
66
62
|
require "stripe/resources/radar/early_fraud_warning"
|
67
63
|
require "stripe/resources/radar/value_list"
|
68
64
|
require "stripe/resources/radar/value_list_item"
|
69
|
-
require "stripe/resources/recipient"
|
70
|
-
require "stripe/resources/recipient_transfer"
|
71
65
|
require "stripe/resources/refund"
|
72
66
|
require "stripe/resources/reporting/report_run"
|
73
67
|
require "stripe/resources/reporting/report_type"
|
@@ -77,7 +71,6 @@ require "stripe/resources/setup_attempt"
|
|
77
71
|
require "stripe/resources/setup_intent"
|
78
72
|
require "stripe/resources/shipping_rate"
|
79
73
|
require "stripe/resources/sigma/scheduled_query_run"
|
80
|
-
require "stripe/resources/sku"
|
81
74
|
require "stripe/resources/source"
|
82
75
|
require "stripe/resources/source_transaction"
|
83
76
|
require "stripe/resources/subscription"
|
@@ -91,10 +84,19 @@ require "stripe/resources/terminal/connection_token"
|
|
91
84
|
require "stripe/resources/terminal/location"
|
92
85
|
require "stripe/resources/terminal/reader"
|
93
86
|
require "stripe/resources/test_helpers/test_clock"
|
94
|
-
require "stripe/resources/three_d_secure"
|
95
87
|
require "stripe/resources/token"
|
96
88
|
require "stripe/resources/topup"
|
97
89
|
require "stripe/resources/transfer"
|
90
|
+
require "stripe/resources/treasury/credit_reversal"
|
91
|
+
require "stripe/resources/treasury/debit_reversal"
|
92
|
+
require "stripe/resources/treasury/financial_account"
|
93
|
+
require "stripe/resources/treasury/inbound_transfer"
|
94
|
+
require "stripe/resources/treasury/outbound_payment"
|
95
|
+
require "stripe/resources/treasury/outbound_transfer"
|
96
|
+
require "stripe/resources/treasury/received_credit"
|
97
|
+
require "stripe/resources/treasury/received_debit"
|
98
|
+
require "stripe/resources/treasury/transaction"
|
99
|
+
require "stripe/resources/treasury/transaction_entry"
|
98
100
|
require "stripe/resources/usage_record"
|
99
101
|
require "stripe/resources/usage_record_summary"
|
100
102
|
require "stripe/resources/webhook_endpoint"
|
data/lib/stripe/stripe_client.rb
CHANGED
@@ -494,15 +494,16 @@ module Stripe
|
|
494
494
|
end
|
495
495
|
end
|
496
496
|
|
497
|
-
http_resp =
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
497
|
+
http_resp =
|
498
|
+
execute_request_with_rescues(method, api_base, headers, context) do
|
499
|
+
self.class
|
500
|
+
.default_connection_manager(config)
|
501
|
+
.execute_request(method, url,
|
502
|
+
body: body,
|
503
|
+
headers: headers,
|
504
|
+
query: query,
|
505
|
+
&response_block)
|
506
|
+
end
|
506
507
|
|
507
508
|
[http_resp, api_key]
|
508
509
|
end
|
@@ -564,7 +565,7 @@ module Stripe
|
|
564
565
|
http_status >= 400
|
565
566
|
end
|
566
567
|
|
567
|
-
private def execute_request_with_rescues(method, api_base, context)
|
568
|
+
private def execute_request_with_rescues(method, api_base, headers, context)
|
568
569
|
num_retries = 0
|
569
570
|
|
570
571
|
begin
|
@@ -587,7 +588,7 @@ module Stripe
|
|
587
588
|
|
588
589
|
log_response(context, request_start, http_status, resp.body, resp)
|
589
590
|
notify_request_end(context, request_duration, http_status,
|
590
|
-
num_retries, user_data)
|
591
|
+
num_retries, user_data, resp, headers)
|
591
592
|
|
592
593
|
if config.enable_telemetry? && context.request_id
|
593
594
|
request_duration_ms = (request_duration * 1000).to_i
|
@@ -614,7 +615,7 @@ module Stripe
|
|
614
615
|
log_response_error(error_context, request_start, e)
|
615
616
|
end
|
616
617
|
notify_request_end(context, request_duration, http_status, num_retries,
|
617
|
-
user_data)
|
618
|
+
user_data, resp, headers)
|
618
619
|
|
619
620
|
if self.class.should_retry?(e,
|
620
621
|
method: method,
|
@@ -657,17 +658,24 @@ module Stripe
|
|
657
658
|
end
|
658
659
|
|
659
660
|
private def notify_request_end(context, duration, http_status, num_retries,
|
660
|
-
user_data)
|
661
|
+
user_data, resp, headers)
|
661
662
|
return if !Instrumentation.any_subscribers?(:request_end) &&
|
662
663
|
!Instrumentation.any_subscribers?(:request)
|
663
664
|
|
664
|
-
|
665
|
+
request_context = Stripe::Instrumentation::RequestContext.new(
|
665
666
|
duration: duration,
|
667
|
+
context: context,
|
668
|
+
header: headers
|
669
|
+
)
|
670
|
+
response_context = Stripe::Instrumentation::ResponseContext.new(
|
666
671
|
http_status: http_status,
|
667
|
-
|
672
|
+
response: resp
|
673
|
+
)
|
674
|
+
|
675
|
+
event = Instrumentation::RequestEndEvent.new(
|
676
|
+
request_context: request_context,
|
677
|
+
response_context: response_context,
|
668
678
|
num_retries: num_retries,
|
669
|
-
path: context.path,
|
670
|
-
request_id: context.request_id,
|
671
679
|
user_data: user_data || {}
|
672
680
|
)
|
673
681
|
Stripe::Instrumentation.notify(:request_end, event)
|
data/lib/stripe/stripe_object.rb
CHANGED
@@ -429,13 +429,13 @@ module Stripe
|
|
429
429
|
# * +:opts:+ Options for StripeObject like an API key.
|
430
430
|
# * +:partial:+ Indicates that the re-initialization should not attempt to
|
431
431
|
# remove accessors.
|
432
|
-
protected def initialize_from(values, opts
|
432
|
+
protected def initialize_from(values, opts)
|
433
433
|
@opts = Util.normalize_opts(opts)
|
434
434
|
|
435
435
|
# the `#send` is here so that we can keep this method private
|
436
436
|
@original_values = self.class.send(:deep_copy, values)
|
437
437
|
|
438
|
-
removed =
|
438
|
+
removed = Set.new(@values.keys - values.keys)
|
439
439
|
added = Set.new(values.keys - @values.keys)
|
440
440
|
|
441
441
|
# Wipe old state before setting new. This is useful for e.g. updating a
|
data/lib/stripe/util.rb
CHANGED
@@ -90,7 +90,7 @@ module Stripe
|
|
90
90
|
opts
|
91
91
|
)
|
92
92
|
|
93
|
-
Util.
|
93
|
+
Util.convert_to_stripe_object_with_params(resp.data, params, opts)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -104,9 +104,27 @@ module Stripe
|
|
104
104
|
# ==== Attributes
|
105
105
|
#
|
106
106
|
# * +data+ - Hash of fields and values to be converted into a StripeObject.
|
107
|
+
# * +params+ - Params for +StripeObject+ like filters used in search that
|
108
|
+
# will be reused on subsequent API calls.
|
107
109
|
# * +opts+ - Options for +StripeObject+ like an API key that will be reused
|
108
110
|
# on subsequent API calls.
|
109
111
|
def self.convert_to_stripe_object(data, opts = {})
|
112
|
+
convert_to_stripe_object_with_params(data, {}, opts)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Converts a hash of fields or an array of hashes into a +StripeObject+ or
|
116
|
+
# array of +StripeObject+s. These new objects will be created as a concrete
|
117
|
+
# type as dictated by their `object` field (e.g. an `object` value of
|
118
|
+
# `charge` would create an instance of +Charge+), but if `object` is not
|
119
|
+
# present or of an unknown type, the newly created instance will fall back
|
120
|
+
# to being a +StripeObject+.
|
121
|
+
#
|
122
|
+
# ==== Attributes
|
123
|
+
#
|
124
|
+
# * +data+ - Hash of fields and values to be converted into a StripeObject.
|
125
|
+
# * +opts+ - Options for +StripeObject+ like an API key that will be reused
|
126
|
+
# on subsequent API calls.
|
127
|
+
def self.convert_to_stripe_object_with_params(data, params, opts = {})
|
110
128
|
opts = normalize_opts(opts)
|
111
129
|
|
112
130
|
case data
|
@@ -115,8 +133,16 @@ module Stripe
|
|
115
133
|
when Hash
|
116
134
|
# Try converting to a known object class. If none available, fall back
|
117
135
|
# to generic StripeObject
|
118
|
-
object_classes.fetch(data[:object], StripeObject)
|
119
|
-
|
136
|
+
obj = object_classes.fetch(data[:object], StripeObject)
|
137
|
+
.construct_from(data, opts)
|
138
|
+
|
139
|
+
# set filters so that we can fetch the same limit, expansions, and
|
140
|
+
# predicates when accessing the next and previous pages
|
141
|
+
if obj && (obj.is_a?(SearchResultObject) || obj.is_a?(ListObject))
|
142
|
+
obj.filters = params.dup
|
143
|
+
end
|
144
|
+
|
145
|
+
obj
|
120
146
|
else
|
121
147
|
data
|
122
148
|
end
|
@@ -390,6 +416,15 @@ module Stripe
|
|
390
416
|
# Hopefully val is a string, but protect in case it's not.
|
391
417
|
val = val.to_s
|
392
418
|
|
419
|
+
# Some values returned by the server are encoded in ASCII-8BIT before
|
420
|
+
# being parsed as UTF-8 by Marshal. If we don't transform these here, then
|
421
|
+
# puts will fail as it tries to render UTF-8 characters as ASCII-8BIT
|
422
|
+
# which is not valid.
|
423
|
+
if val && val.encoding == Encoding::ASCII_8BIT
|
424
|
+
# Dup the string as it is a frozen literal.
|
425
|
+
val = val.dup.force_encoding("UTF-8")
|
426
|
+
end
|
427
|
+
|
393
428
|
if %r{[^\w\-/]} =~ val
|
394
429
|
# If the string contains any special characters, escape any double
|
395
430
|
# quotes it has, remove newlines, and wrap the whole thing in quotes.
|
data/lib/stripe/version.rb
CHANGED