stripe 4.21.3 → 5.52.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 +254 -1
- data/CODE_OF_CONDUCT.md +77 -0
- data/Gemfile +10 -16
- data/Makefile +7 -0
- data/README.md +115 -47
- data/Rakefile +8 -7
- data/VERSION +1 -1
- data/lib/stripe/api_operations/create.rb +1 -1
- data/lib/stripe/api_operations/delete.rb +7 -3
- data/lib/stripe/api_operations/list.rb +1 -12
- data/lib/stripe/api_operations/nested_resource.rb +29 -26
- data/lib/stripe/api_operations/request.rb +82 -6
- data/lib/stripe/api_operations/save.rb +7 -4
- data/lib/stripe/api_operations/search.rb +19 -0
- data/lib/stripe/api_resource.rb +22 -17
- data/lib/stripe/api_resource_test_helpers.rb +47 -0
- data/lib/stripe/connection_manager.rb +200 -0
- data/lib/stripe/error_object.rb +93 -0
- data/lib/stripe/errors.rb +24 -3
- data/lib/stripe/instrumentation.rb +84 -0
- data/lib/stripe/list_object.rb +34 -5
- data/lib/stripe/multipart_encoder.rb +131 -0
- data/lib/stripe/oauth.rb +8 -6
- data/lib/stripe/object_types.rb +20 -5
- data/lib/stripe/resources/account.rb +12 -16
- data/lib/stripe/resources/account_link.rb +2 -1
- data/lib/stripe/resources/alipay_account.rb +1 -1
- data/lib/stripe/resources/apple_pay_domain.rb +2 -1
- data/lib/stripe/resources/application_fee.rb +2 -12
- data/lib/stripe/resources/application_fee_refund.rb +3 -2
- data/lib/stripe/resources/balance.rb +2 -1
- data/lib/stripe/resources/balance_transaction.rb +2 -5
- data/lib/stripe/resources/bank_account.rb +3 -2
- data/lib/stripe/resources/billing_portal/configuration.rb +14 -0
- data/lib/stripe/resources/billing_portal/session.rb +12 -0
- data/lib/stripe/resources/bitcoin_receiver.rb +2 -1
- data/lib/stripe/resources/bitcoin_transaction.rb +4 -3
- data/lib/stripe/resources/capability.rb +3 -2
- data/lib/stripe/resources/card.rb +2 -1
- data/lib/stripe/resources/charge.rb +13 -65
- data/lib/stripe/resources/checkout/session.rb +17 -1
- data/lib/stripe/resources/country_spec.rb +2 -1
- data/lib/stripe/resources/coupon.rb +2 -1
- data/lib/stripe/resources/credit_note.rb +18 -3
- data/lib/stripe/resources/credit_note_line_item.rb +8 -0
- data/lib/stripe/resources/customer.rb +35 -59
- data/lib/stripe/resources/customer_balance_transaction.rb +4 -3
- data/lib/stripe/resources/discount.rb +2 -1
- data/lib/stripe/resources/dispute.rb +8 -9
- data/lib/stripe/resources/ephemeral_key.rb +2 -1
- data/lib/stripe/resources/event.rb +2 -1
- data/lib/stripe/resources/exchange_rate.rb +2 -1
- data/lib/stripe/resources/file.rb +6 -14
- data/lib/stripe/resources/file_link.rb +2 -1
- data/lib/stripe/resources/funding_instructions.rb +16 -0
- data/lib/stripe/resources/identity/verification_report.rb +12 -0
- data/lib/stripe/resources/identity/verification_session.rb +35 -0
- data/lib/stripe/resources/invoice.rb +47 -12
- data/lib/stripe/resources/invoice_item.rb +2 -1
- data/lib/stripe/resources/invoice_line_item.rb +2 -1
- data/lib/stripe/resources/issuing/authorization.rb +14 -5
- data/lib/stripe/resources/issuing/card.rb +8 -3
- data/lib/stripe/resources/issuing/card_details.rb +3 -2
- data/lib/stripe/resources/issuing/cardholder.rb +2 -1
- data/lib/stripe/resources/issuing/dispute.rb +13 -1
- data/lib/stripe/resources/issuing/transaction.rb +2 -1
- data/lib/stripe/resources/line_item.rb +8 -0
- data/lib/stripe/resources/login_link.rb +2 -1
- data/lib/stripe/resources/mandate.rb +8 -0
- data/lib/stripe/resources/order.rb +14 -13
- data/lib/stripe/resources/order_return.rb +2 -1
- data/lib/stripe/resources/payment_intent.rb +59 -7
- data/lib/stripe/resources/payment_link.rb +23 -0
- data/lib/stripe/resources/payment_method.rb +14 -5
- data/lib/stripe/resources/payout.rb +16 -7
- data/lib/stripe/resources/person.rb +2 -1
- data/lib/stripe/resources/plan.rb +2 -1
- data/lib/stripe/resources/price.rb +21 -0
- data/lib/stripe/resources/product.rb +11 -1
- data/lib/stripe/resources/promotion_code.rb +12 -0
- data/lib/stripe/resources/quote.rb +105 -0
- data/lib/stripe/resources/radar/early_fraud_warning.rb +2 -1
- data/lib/stripe/resources/radar/value_list.rb +2 -1
- data/lib/stripe/resources/radar/value_list_item.rb +2 -1
- data/lib/stripe/resources/recipient.rb +2 -5
- data/lib/stripe/resources/recipient_transfer.rb +1 -1
- data/lib/stripe/resources/refund.rb +13 -1
- data/lib/stripe/resources/reporting/report_run.rb +2 -1
- data/lib/stripe/resources/reporting/report_type.rb +2 -1
- data/lib/stripe/resources/reversal.rb +4 -3
- data/lib/stripe/resources/review.rb +8 -3
- data/lib/stripe/resources/setup_attempt.rb +10 -0
- data/lib/stripe/resources/setup_intent.rb +24 -5
- data/lib/stripe/resources/shipping_rate.rb +12 -0
- data/lib/stripe/resources/sigma/scheduled_query_run.rb +2 -1
- data/lib/stripe/resources/sku.rb +2 -1
- data/lib/stripe/resources/source.rb +17 -12
- data/lib/stripe/resources/source_transaction.rb +2 -1
- data/lib/stripe/resources/subscription.rb +16 -6
- data/lib/stripe/resources/subscription_item.rb +11 -2
- data/lib/stripe/resources/subscription_schedule.rb +14 -13
- data/lib/stripe/resources/tax_code.rb +10 -0
- data/lib/stripe/resources/tax_id.rb +2 -1
- data/lib/stripe/resources/tax_rate.rb +2 -1
- data/lib/stripe/resources/terminal/configuration.rb +15 -0
- data/lib/stripe/resources/terminal/connection_token.rb +2 -1
- data/lib/stripe/resources/terminal/location.rb +2 -1
- data/lib/stripe/resources/terminal/reader.rb +62 -1
- data/lib/stripe/resources/test_helpers/test_clock.rb +25 -0
- data/lib/stripe/resources/three_d_secure.rb +2 -1
- data/lib/stripe/resources/token.rb +2 -1
- data/lib/stripe/resources/topup.rb +8 -3
- data/lib/stripe/resources/transfer.rb +8 -8
- data/lib/stripe/resources/usage_record.rb +2 -17
- data/lib/stripe/resources/usage_record_summary.rb +2 -1
- data/lib/stripe/resources/webhook_endpoint.rb +2 -1
- data/lib/stripe/resources.rb +18 -2
- data/lib/stripe/search_result_object.rb +86 -0
- data/lib/stripe/stripe_client.rb +617 -243
- data/lib/stripe/stripe_configuration.rb +194 -0
- data/lib/stripe/stripe_object.rb +30 -25
- data/lib/stripe/stripe_response.rb +87 -27
- data/lib/stripe/util.rb +88 -18
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +39 -8
- data/lib/stripe.rb +43 -131
- data/stripe.gemspec +17 -13
- metadata +36 -220
- data/.editorconfig +0 -10
- data/.gitattributes +0 -4
- data/.github/ISSUE_TEMPLATE.md +0 -5
- data/.gitignore +0 -8
- data/.rubocop.yml +0 -43
- data/.rubocop_todo.yml +0 -38
- data/.travis.yml +0 -43
- data/.vscode/extensions.json +0 -7
- data/.vscode/settings.json +0 -8
- data/lib/stripe/resources/issuer_fraud_record.rb +0 -9
- data/lib/stripe/resources/subscription_schedule_revision.rb +0 -34
- data/test/api_stub_helpers.rb +0 -1
- data/test/openapi/README.md +0 -9
- data/test/stripe/account_link_test.rb +0 -18
- data/test/stripe/account_test.rb +0 -428
- data/test/stripe/alipay_account_test.rb +0 -37
- data/test/stripe/api_operations_test.rb +0 -80
- data/test/stripe/api_resource_test.rb +0 -544
- data/test/stripe/apple_pay_domain_test.rb +0 -46
- data/test/stripe/application_fee_refund_test.rb +0 -37
- data/test/stripe/application_fee_test.rb +0 -58
- data/test/stripe/balance_test.rb +0 -13
- data/test/stripe/bank_account_test.rb +0 -36
- data/test/stripe/capability_test.rb +0 -45
- data/test/stripe/charge_test.rb +0 -80
- data/test/stripe/checkout/session_test.rb +0 -41
- data/test/stripe/country_spec_test.rb +0 -20
- data/test/stripe/coupon_test.rb +0 -61
- data/test/stripe/credit_note_test.rb +0 -61
- data/test/stripe/customer_balance_transaction_test.rb +0 -37
- data/test/stripe/customer_card_test.rb +0 -42
- data/test/stripe/customer_test.rb +0 -269
- data/test/stripe/dispute_test.rb +0 -51
- data/test/stripe/ephemeral_key_test.rb +0 -93
- data/test/stripe/errors_test.rb +0 -20
- data/test/stripe/exchange_rate_test.rb +0 -20
- data/test/stripe/file_link_test.rb +0 -41
- data/test/stripe/file_test.rb +0 -97
- data/test/stripe/file_upload_test.rb +0 -79
- data/test/stripe/invoice_item_test.rb +0 -66
- data/test/stripe/invoice_line_item_test.rb +0 -8
- data/test/stripe/invoice_test.rb +0 -213
- data/test/stripe/issuer_fraud_record_test.rb +0 -20
- data/test/stripe/issuing/authorization_test.rb +0 -72
- data/test/stripe/issuing/card_test.rb +0 -62
- data/test/stripe/issuing/cardholder_test.rb +0 -53
- data/test/stripe/issuing/dispute_test.rb +0 -45
- data/test/stripe/issuing/transaction_test.rb +0 -48
- data/test/stripe/list_object_test.rb +0 -156
- data/test/stripe/login_link_test.rb +0 -37
- data/test/stripe/oauth_test.rb +0 -88
- data/test/stripe/order_return_test.rb +0 -21
- data/test/stripe/order_test.rb +0 -82
- data/test/stripe/payment_intent_test.rb +0 -107
- data/test/stripe/payment_method_test.rb +0 -84
- data/test/stripe/payout_test.rb +0 -57
- data/test/stripe/person_test.rb +0 -46
- data/test/stripe/plan_test.rb +0 -98
- data/test/stripe/product_test.rb +0 -59
- data/test/stripe/radar/early_fraud_warning_test.rb +0 -22
- data/test/stripe/radar/value_list_item_test.rb +0 -48
- data/test/stripe/radar/value_list_test.rb +0 -61
- data/test/stripe/recipient_test.rb +0 -62
- data/test/stripe/refund_test.rb +0 -39
- data/test/stripe/reporting/report_run_test.rb +0 -33
- data/test/stripe/reporting/report_type_test.rb +0 -22
- data/test/stripe/reversal_test.rb +0 -43
- data/test/stripe/review_test.rb +0 -27
- data/test/stripe/setup_intent_test.rb +0 -84
- data/test/stripe/sigma/scheduled_query_run_test.rb +0 -22
- data/test/stripe/sku_test.rb +0 -60
- data/test/stripe/source_test.rb +0 -99
- data/test/stripe/source_transaction_test.rb +0 -19
- data/test/stripe/stripe_client_test.rb +0 -842
- data/test/stripe/stripe_object_test.rb +0 -525
- data/test/stripe/stripe_response_test.rb +0 -49
- data/test/stripe/subscription_item_test.rb +0 -63
- data/test/stripe/subscription_schedule_revision_test.rb +0 -37
- data/test/stripe/subscription_schedule_test.rb +0 -116
- data/test/stripe/subscription_test.rb +0 -80
- data/test/stripe/tax_id_test.rb +0 -31
- data/test/stripe/tax_rate_test.rb +0 -43
- data/test/stripe/terminal/connection_token_test.rb +0 -16
- data/test/stripe/terminal/location_test.rb +0 -68
- data/test/stripe/terminal/reader_test.rb +0 -62
- data/test/stripe/three_d_secure_test.rb +0 -23
- data/test/stripe/topup_test.rb +0 -62
- data/test/stripe/transfer_test.rb +0 -88
- data/test/stripe/usage_record_summary_test.rb +0 -19
- data/test/stripe/usage_record_test.rb +0 -28
- data/test/stripe/util_test.rb +0 -402
- data/test/stripe/webhook_endpoint_test.rb +0 -59
- data/test/stripe/webhook_test.rb +0 -96
- data/test/stripe_mock.rb +0 -77
- data/test/stripe_test.rb +0 -63
- data/test/test_data.rb +0 -61
- data/test/test_helper.rb +0 -71
@@ -0,0 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "securerandom"
|
4
|
+
require "tempfile"
|
5
|
+
|
6
|
+
module Stripe
|
7
|
+
# Encodes parameters into a `multipart/form-data` payload as described by RFC
|
8
|
+
# 2388:
|
9
|
+
#
|
10
|
+
# https://tools.ietf.org/html/rfc2388
|
11
|
+
#
|
12
|
+
# This is most useful for transferring file-like objects.
|
13
|
+
#
|
14
|
+
# Parameters should be added with `#encode`. When ready, use `#body` to get
|
15
|
+
# the encoded result and `#content_type` to get the value that should be
|
16
|
+
# placed in the `Content-Type` header of a subsequent request (which includes
|
17
|
+
# a boundary value).
|
18
|
+
class MultipartEncoder
|
19
|
+
MULTIPART_FORM_DATA = "multipart/form-data"
|
20
|
+
|
21
|
+
# A shortcut for encoding a single set of parameters and finalizing a
|
22
|
+
# result.
|
23
|
+
#
|
24
|
+
# Returns an encoded body and the value that should be set in the content
|
25
|
+
# type header of a subsequent request.
|
26
|
+
def self.encode(params)
|
27
|
+
encoder = MultipartEncoder.new
|
28
|
+
encoder.encode(params)
|
29
|
+
encoder.close
|
30
|
+
[encoder.body, encoder.content_type]
|
31
|
+
end
|
32
|
+
|
33
|
+
# Gets the object's randomly generated boundary string.
|
34
|
+
attr_reader :boundary
|
35
|
+
|
36
|
+
# Initializes a new multipart encoder.
|
37
|
+
def initialize
|
38
|
+
# Kind of weird, but required by Rubocop because the unary plus operator
|
39
|
+
# is considered faster than `Stripe.new`.
|
40
|
+
@body = +""
|
41
|
+
|
42
|
+
# Chose the same number of random bytes that Go uses in its standard
|
43
|
+
# library implementation. Easily enough entropy to ensure that it won't
|
44
|
+
# be present in a file we're sending.
|
45
|
+
@boundary = SecureRandom.hex(30)
|
46
|
+
|
47
|
+
@closed = false
|
48
|
+
@first_field = true
|
49
|
+
end
|
50
|
+
|
51
|
+
# Gets the encoded body. `#close` must be called first.
|
52
|
+
def body
|
53
|
+
raise "object must be closed before getting body" unless @closed
|
54
|
+
|
55
|
+
@body
|
56
|
+
end
|
57
|
+
|
58
|
+
# Finalizes the object by writing the final boundary.
|
59
|
+
def close
|
60
|
+
raise "object already closed" if @closed
|
61
|
+
|
62
|
+
@body << "\r\n"
|
63
|
+
@body << "--#{@boundary}--"
|
64
|
+
|
65
|
+
@closed = true
|
66
|
+
|
67
|
+
nil
|
68
|
+
end
|
69
|
+
|
70
|
+
# Gets the value including boundary that should be put into a multipart
|
71
|
+
# request's `Content-Type`.
|
72
|
+
def content_type
|
73
|
+
"#{MULTIPART_FORM_DATA}; boundary=#{@boundary}"
|
74
|
+
end
|
75
|
+
|
76
|
+
# Encodes a set of parameters to the body.
|
77
|
+
#
|
78
|
+
# Note that parameters are expected to be a hash, but a "flat" hash such
|
79
|
+
# that complex substructures like hashes and arrays have already been
|
80
|
+
# appropriately Stripe-encoded. Pass a complex structure through
|
81
|
+
# `Util.flatten_params` first before handing it off to this method.
|
82
|
+
def encode(params)
|
83
|
+
raise "no more parameters can be written to closed object" if @closed
|
84
|
+
|
85
|
+
params.each do |name, val|
|
86
|
+
if val.is_a?(::File) || val.is_a?(::Tempfile)
|
87
|
+
write_field(name, val.read, filename: ::File.basename(val.path))
|
88
|
+
elsif val.respond_to?(:read)
|
89
|
+
write_field(name, val.read, filename: "blob")
|
90
|
+
else
|
91
|
+
write_field(name, val, filename: nil)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
nil
|
96
|
+
end
|
97
|
+
|
98
|
+
#
|
99
|
+
# private
|
100
|
+
#
|
101
|
+
|
102
|
+
# Escapes double quotes so that the given value can be used in a
|
103
|
+
# double-quoted string and replaces any linebreak characters with spaces.
|
104
|
+
private def escape(str)
|
105
|
+
str.gsub('"', "%22").tr("\n", " ").tr("\r", " ")
|
106
|
+
end
|
107
|
+
|
108
|
+
private def write_field(name, data, filename:)
|
109
|
+
if !@first_field
|
110
|
+
@body << "\r\n"
|
111
|
+
else
|
112
|
+
@first_field = false
|
113
|
+
end
|
114
|
+
|
115
|
+
@body << "--#{@boundary}\r\n"
|
116
|
+
|
117
|
+
if filename
|
118
|
+
@body << %(Content-Disposition: form-data) +
|
119
|
+
%(; name="#{escape(name.to_s)}") +
|
120
|
+
%(; filename="#{escape(filename)}"\r\n)
|
121
|
+
@body << %(Content-Type: application/octet-stream\r\n)
|
122
|
+
else
|
123
|
+
@body << %(Content-Disposition: form-data) +
|
124
|
+
%(; name="#{escape(name.to_s)}"\r\n)
|
125
|
+
end
|
126
|
+
|
127
|
+
@body << "\r\n"
|
128
|
+
@body << data.to_s
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
data/lib/stripe/oauth.rb
CHANGED
@@ -5,10 +5,10 @@ module Stripe
|
|
5
5
|
module OAuthOperations
|
6
6
|
extend APIOperations::Request::ClassMethods
|
7
7
|
|
8
|
-
def self.
|
8
|
+
def self.execute_resource_request(method, url, params, opts)
|
9
9
|
opts = Util.normalize_opts(opts)
|
10
|
-
opts[:client] ||= StripeClient.active_client
|
11
|
-
opts[:api_base] ||=
|
10
|
+
opts[:client] ||= opts[:client] || StripeClient.active_client
|
11
|
+
opts[:api_base] ||= opts[:client].config.connect_base
|
12
12
|
|
13
13
|
super(method, url, params, opts)
|
14
14
|
end
|
@@ -29,7 +29,8 @@ module Stripe
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.authorize_url(params = {}, opts = {})
|
32
|
-
|
32
|
+
client = opts[:client] || StripeClient.active_client
|
33
|
+
base = opts[:connect_base] || client.config.connect_base
|
33
34
|
|
34
35
|
path = "/oauth/authorize"
|
35
36
|
path = "/express" + path if opts[:express]
|
@@ -43,7 +44,8 @@ module Stripe
|
|
43
44
|
|
44
45
|
def self.token(params = {}, opts = {})
|
45
46
|
opts = Util.normalize_opts(opts)
|
46
|
-
|
47
|
+
opts[:api_key] = params[:client_secret] if params[:client_secret]
|
48
|
+
resp, opts = OAuthOperations.execute_resource_request(
|
47
49
|
:post, "/oauth/token", params, opts
|
48
50
|
)
|
49
51
|
# This is just going to return a generic StripeObject, but that's okay
|
@@ -53,7 +55,7 @@ module Stripe
|
|
53
55
|
def self.deauthorize(params = {}, opts = {})
|
54
56
|
opts = Util.normalize_opts(opts)
|
55
57
|
params[:client_id] = get_client_id(params)
|
56
|
-
resp, opts = OAuthOperations.
|
58
|
+
resp, opts = OAuthOperations.execute_resource_request(
|
57
59
|
:post, "/oauth/deauthorize", params, opts
|
58
60
|
)
|
59
61
|
# This is just going to return a generic StripeObject, but that's okay
|
data/lib/stripe/object_types.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
|
-
# rubocop:disable Metrics/LineLength
|
4
4
|
# rubocop:disable Metrics/MethodLength
|
5
5
|
|
6
6
|
module Stripe
|
@@ -9,6 +9,7 @@ module Stripe
|
|
9
9
|
{
|
10
10
|
# data structures
|
11
11
|
ListObject::OBJECT_NAME => ListObject,
|
12
|
+
SearchResultObject::OBJECT_NAME => SearchResultObject,
|
12
13
|
|
13
14
|
# business objects
|
14
15
|
Account::OBJECT_NAME => Account,
|
@@ -20,6 +21,8 @@ module Stripe
|
|
20
21
|
Balance::OBJECT_NAME => Balance,
|
21
22
|
BalanceTransaction::OBJECT_NAME => BalanceTransaction,
|
22
23
|
BankAccount::OBJECT_NAME => BankAccount,
|
24
|
+
BillingPortal::Configuration::OBJECT_NAME => BillingPortal::Configuration,
|
25
|
+
BillingPortal::Session::OBJECT_NAME => BillingPortal::Session,
|
23
26
|
BitcoinReceiver::OBJECT_NAME => BitcoinReceiver,
|
24
27
|
BitcoinTransaction::OBJECT_NAME => BitcoinTransaction,
|
25
28
|
Capability::OBJECT_NAME => Capability,
|
@@ -29,6 +32,7 @@ module Stripe
|
|
29
32
|
CountrySpec::OBJECT_NAME => CountrySpec,
|
30
33
|
Coupon::OBJECT_NAME => Coupon,
|
31
34
|
CreditNote::OBJECT_NAME => CreditNote,
|
35
|
+
CreditNoteLineItem::OBJECT_NAME => CreditNoteLineItem,
|
32
36
|
Customer::OBJECT_NAME => Customer,
|
33
37
|
CustomerBalanceTransaction::OBJECT_NAME => CustomerBalanceTransaction,
|
34
38
|
Discount::OBJECT_NAME => Discount,
|
@@ -39,25 +43,33 @@ module Stripe
|
|
39
43
|
File::OBJECT_NAME => File,
|
40
44
|
File::OBJECT_NAME_ALT => File,
|
41
45
|
FileLink::OBJECT_NAME => FileLink,
|
46
|
+
FundingInstructions::OBJECT_NAME => FundingInstructions,
|
47
|
+
Identity::VerificationReport::OBJECT_NAME => Identity::VerificationReport,
|
48
|
+
Identity::VerificationSession::OBJECT_NAME => Identity::VerificationSession,
|
42
49
|
Invoice::OBJECT_NAME => Invoice,
|
43
50
|
InvoiceItem::OBJECT_NAME => InvoiceItem,
|
44
51
|
InvoiceLineItem::OBJECT_NAME => InvoiceLineItem,
|
45
|
-
IssuerFraudRecord::OBJECT_NAME => IssuerFraudRecord,
|
46
52
|
Issuing::Authorization::OBJECT_NAME => Issuing::Authorization,
|
47
53
|
Issuing::Card::OBJECT_NAME => Issuing::Card,
|
48
54
|
Issuing::CardDetails::OBJECT_NAME => Issuing::CardDetails,
|
49
55
|
Issuing::Cardholder::OBJECT_NAME => Issuing::Cardholder,
|
50
56
|
Issuing::Dispute::OBJECT_NAME => Issuing::Dispute,
|
51
57
|
Issuing::Transaction::OBJECT_NAME => Issuing::Transaction,
|
58
|
+
LineItem::OBJECT_NAME => LineItem,
|
52
59
|
LoginLink::OBJECT_NAME => LoginLink,
|
60
|
+
Mandate::OBJECT_NAME => Mandate,
|
53
61
|
Order::OBJECT_NAME => Order,
|
54
62
|
OrderReturn::OBJECT_NAME => OrderReturn,
|
55
63
|
PaymentIntent::OBJECT_NAME => PaymentIntent,
|
64
|
+
PaymentLink::OBJECT_NAME => PaymentLink,
|
56
65
|
PaymentMethod::OBJECT_NAME => PaymentMethod,
|
57
66
|
Payout::OBJECT_NAME => Payout,
|
58
67
|
Person::OBJECT_NAME => Person,
|
59
68
|
Plan::OBJECT_NAME => Plan,
|
69
|
+
Price::OBJECT_NAME => Price,
|
60
70
|
Product::OBJECT_NAME => Product,
|
71
|
+
PromotionCode::OBJECT_NAME => PromotionCode,
|
72
|
+
Quote::OBJECT_NAME => Quote,
|
61
73
|
Radar::EarlyFraudWarning::OBJECT_NAME => Radar::EarlyFraudWarning,
|
62
74
|
Radar::ValueList::OBJECT_NAME => Radar::ValueList,
|
63
75
|
Radar::ValueListItem::OBJECT_NAME => Radar::ValueListItem,
|
@@ -68,20 +80,24 @@ module Stripe
|
|
68
80
|
Reporting::ReportType::OBJECT_NAME => Reporting::ReportType,
|
69
81
|
Reversal::OBJECT_NAME => Reversal,
|
70
82
|
Review::OBJECT_NAME => Review,
|
71
|
-
|
83
|
+
SetupAttempt::OBJECT_NAME => SetupAttempt,
|
72
84
|
SetupIntent::OBJECT_NAME => SetupIntent,
|
85
|
+
ShippingRate::OBJECT_NAME => ShippingRate,
|
73
86
|
Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun,
|
87
|
+
SKU::OBJECT_NAME => SKU,
|
74
88
|
Source::OBJECT_NAME => Source,
|
75
89
|
SourceTransaction::OBJECT_NAME => SourceTransaction,
|
76
90
|
Subscription::OBJECT_NAME => Subscription,
|
77
91
|
SubscriptionItem::OBJECT_NAME => SubscriptionItem,
|
78
92
|
SubscriptionSchedule::OBJECT_NAME => SubscriptionSchedule,
|
79
|
-
|
93
|
+
TaxCode::OBJECT_NAME => TaxCode,
|
80
94
|
TaxId::OBJECT_NAME => TaxId,
|
81
95
|
TaxRate::OBJECT_NAME => TaxRate,
|
96
|
+
Terminal::Configuration::OBJECT_NAME => Terminal::Configuration,
|
82
97
|
Terminal::ConnectionToken::OBJECT_NAME => Terminal::ConnectionToken,
|
83
98
|
Terminal::Location::OBJECT_NAME => Terminal::Location,
|
84
99
|
Terminal::Reader::OBJECT_NAME => Terminal::Reader,
|
100
|
+
TestHelpers::TestClock::OBJECT_NAME => TestHelpers::TestClock,
|
85
101
|
ThreeDSecure::OBJECT_NAME => ThreeDSecure,
|
86
102
|
Token::OBJECT_NAME => Token,
|
87
103
|
Topup::OBJECT_NAME => Topup,
|
@@ -94,5 +110,4 @@ module Stripe
|
|
94
110
|
end
|
95
111
|
end
|
96
112
|
|
97
|
-
# rubocop:enable Metrics/LineLength
|
98
113
|
# rubocop:enable Metrics/MethodLength
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -9,7 +10,7 @@ module Stripe
|
|
9
10
|
include Stripe::APIOperations::Save
|
10
11
|
extend Stripe::APIOperations::NestedResource
|
11
12
|
|
12
|
-
OBJECT_NAME = "account"
|
13
|
+
OBJECT_NAME = "account"
|
13
14
|
|
14
15
|
custom_method :reject, http_verb: :post
|
15
16
|
|
@@ -20,8 +21,12 @@ module Stripe
|
|
20
21
|
operations: %i[create retrieve update delete list]
|
21
22
|
|
22
23
|
def reject(params = {}, opts = {})
|
23
|
-
|
24
|
-
|
24
|
+
request_stripe_object(
|
25
|
+
method: :post,
|
26
|
+
path: resource_url + "/reject",
|
27
|
+
params: params,
|
28
|
+
opts: opts
|
29
|
+
)
|
25
30
|
end
|
26
31
|
|
27
32
|
save_nested_resource :external_account
|
@@ -31,10 +36,6 @@ module Stripe
|
|
31
36
|
|
32
37
|
nested_resource_class_methods :login_link, operations: %i[create]
|
33
38
|
|
34
|
-
# This method is deprecated. Please use `#external_account=` instead.
|
35
|
-
save_nested_resource :bank_account
|
36
|
-
deprecate :bank_account=, "#external_account=", 2017, 8
|
37
|
-
|
38
39
|
def resource_url
|
39
40
|
if self["id"]
|
40
41
|
super
|
@@ -44,12 +45,8 @@ module Stripe
|
|
44
45
|
end
|
45
46
|
|
46
47
|
# @override To make id optional
|
47
|
-
def self.retrieve(id =
|
48
|
-
id
|
49
|
-
nil
|
50
|
-
else
|
51
|
-
Util.check_string_argument!(id)
|
52
|
-
end
|
48
|
+
def self.retrieve(id = nil, opts = {})
|
49
|
+
Util.check_string_argument!(id) if id
|
53
50
|
|
54
51
|
# Account used to be a singleton, where this method's signature was
|
55
52
|
# `(opts={})`. For the sake of not breaking folks who pass in an OAuth
|
@@ -64,7 +61,7 @@ module Stripe
|
|
64
61
|
end
|
65
62
|
|
66
63
|
def persons(params = {}, opts = {})
|
67
|
-
resp, opts =
|
64
|
+
resp, opts = execute_resource_request(:get, resource_url + "/persons", params, opts)
|
68
65
|
Util.convert_to_stripe_object(resp.data, opts)
|
69
66
|
end
|
70
67
|
|
@@ -135,11 +132,10 @@ module Stripe
|
|
135
132
|
client_id: client_id,
|
136
133
|
stripe_user_id: id,
|
137
134
|
}
|
135
|
+
opts = @opts.merge(Util.normalize_opts(opts))
|
138
136
|
OAuth.deauthorize(params, opts)
|
139
137
|
end
|
140
138
|
|
141
|
-
ARGUMENT_NOT_PROVIDED = Object.new
|
142
|
-
|
143
139
|
private def serialize_additional_owners(legal_entity, additional_owners)
|
144
140
|
original_value =
|
145
141
|
legal_entity
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -7,7 +8,7 @@ module Stripe
|
|
7
8
|
include Stripe::APIOperations::Delete
|
8
9
|
extend Stripe::APIOperations::List
|
9
10
|
|
10
|
-
OBJECT_NAME = "apple_pay_domain"
|
11
|
+
OBJECT_NAME = "apple_pay_domain"
|
11
12
|
|
12
13
|
def self.resource_url
|
13
14
|
"/v1/apple_pay/domains"
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -5,20 +6,9 @@ module Stripe
|
|
5
6
|
extend Stripe::APIOperations::List
|
6
7
|
extend Stripe::APIOperations::NestedResource
|
7
8
|
|
8
|
-
OBJECT_NAME = "application_fee"
|
9
|
+
OBJECT_NAME = "application_fee"
|
9
10
|
|
10
11
|
nested_resource_class_methods :refund,
|
11
12
|
operations: %i[create retrieve update list]
|
12
|
-
|
13
|
-
# If you don't need access to an updated fee object after the refund, it's
|
14
|
-
# more performant to just call `fee.refunds.create` directly.
|
15
|
-
def refund(params = {}, opts = {})
|
16
|
-
refunds.create(params, opts)
|
17
|
-
|
18
|
-
# now that a refund has been created, we expect the state of this object
|
19
|
-
# to change as well (i.e. `refunded` will now be `true`) so refresh it
|
20
|
-
# from the server
|
21
|
-
refresh
|
22
|
-
end
|
23
13
|
end
|
24
14
|
end
|
@@ -1,11 +1,12 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
4
5
|
class ApplicationFeeRefund < APIResource
|
5
|
-
include Stripe::APIOperations::Save
|
6
6
|
extend Stripe::APIOperations::List
|
7
|
+
include Stripe::APIOperations::Save
|
7
8
|
|
8
|
-
OBJECT_NAME = "fee_refund"
|
9
|
+
OBJECT_NAME = "fee_refund"
|
9
10
|
|
10
11
|
def resource_url
|
11
12
|
"#{ApplicationFee.resource_url}/#{CGI.escape(fee)}/refunds" \
|
@@ -1,13 +1,10 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
4
5
|
class BalanceTransaction < APIResource
|
5
6
|
extend Stripe::APIOperations::List
|
6
7
|
|
7
|
-
OBJECT_NAME = "balance_transaction"
|
8
|
-
|
9
|
-
def self.resource_url
|
10
|
-
"/v1/balance/history"
|
11
|
-
end
|
8
|
+
OBJECT_NAME = "balance_transaction"
|
12
9
|
end
|
13
10
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -6,10 +7,10 @@ module Stripe
|
|
6
7
|
extend Stripe::APIOperations::List
|
7
8
|
include Stripe::APIOperations::Save
|
8
9
|
|
9
|
-
OBJECT_NAME = "bank_account"
|
10
|
+
OBJECT_NAME = "bank_account"
|
10
11
|
|
11
12
|
def verify(params = {}, opts = {})
|
12
|
-
resp, opts =
|
13
|
+
resp, opts = execute_resource_request(:post, resource_url + "/verify", params, opts)
|
13
14
|
initialize_from(resp.data, opts)
|
14
15
|
end
|
15
16
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
module BillingPortal
|
6
|
+
class Configuration < APIResource
|
7
|
+
extend Stripe::APIOperations::Create
|
8
|
+
extend Stripe::APIOperations::List
|
9
|
+
include Stripe::APIOperations::Save
|
10
|
+
|
11
|
+
OBJECT_NAME = "billing_portal.configuration"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -6,7 +7,7 @@ module Stripe
|
|
6
7
|
class BitcoinReceiver < APIResource
|
7
8
|
extend Stripe::APIOperations::List
|
8
9
|
|
9
|
-
OBJECT_NAME = "bitcoin_receiver"
|
10
|
+
OBJECT_NAME = "bitcoin_receiver"
|
10
11
|
|
11
12
|
def self.resource_url
|
12
13
|
"/v1/bitcoin/receivers"
|
@@ -1,12 +1,13 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
5
|
+
# Directly retrieving BitcoinTransactions is deprecated. Please use
|
6
|
+
# the Sources API instead: https://stripe.com/docs/sources/bitcoin
|
4
7
|
class BitcoinTransaction < APIResource
|
5
|
-
# Directly retrieving BitcoinTransactions is deprecated. Please use the
|
6
|
-
# Sources API instead: https://stripe.com/docs/sources/bitcoin
|
7
8
|
extend Stripe::APIOperations::List
|
8
9
|
|
9
|
-
OBJECT_NAME = "bitcoin_transaction"
|
10
|
+
OBJECT_NAME = "bitcoin_transaction"
|
10
11
|
|
11
12
|
def self.resource_url
|
12
13
|
"/v1/bitcoin/transactions"
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -5,7 +6,7 @@ module Stripe
|
|
5
6
|
extend Stripe::APIOperations::List
|
6
7
|
include Stripe::APIOperations::Save
|
7
8
|
|
8
|
-
OBJECT_NAME = "capability"
|
9
|
+
OBJECT_NAME = "capability"
|
9
10
|
|
10
11
|
def resource_url
|
11
12
|
if !respond_to?(:account) || account.nil?
|
@@ -26,7 +27,7 @@ module Stripe
|
|
26
27
|
def self.update(_id, _params = nil, _opts = nil)
|
27
28
|
raise NotImplementedError,
|
28
29
|
"Capabilities cannot be updated without an account ID. Update a " \
|
29
|
-
"capability using Account.update_capability('account_id', " \
|
30
|
+
"capability using `Account.update_capability('account_id', " \
|
30
31
|
"'capability_id', update_params)`"
|
31
32
|
end
|
32
33
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
@@ -6,7 +7,7 @@ module Stripe
|
|
6
7
|
extend Stripe::APIOperations::List
|
7
8
|
include Stripe::APIOperations::Save
|
8
9
|
|
9
|
-
OBJECT_NAME = "card"
|
10
|
+
OBJECT_NAME = "card"
|
10
11
|
|
11
12
|
def resource_url
|
12
13
|
if respond_to?(:recipient) && !recipient.nil? && !recipient.empty?
|
@@ -1,84 +1,32 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
4
5
|
class Charge < APIResource
|
5
6
|
extend Stripe::APIOperations::Create
|
6
7
|
extend Stripe::APIOperations::List
|
8
|
+
extend Stripe::APIOperations::Search
|
7
9
|
include Stripe::APIOperations::Save
|
8
10
|
|
9
|
-
OBJECT_NAME = "charge"
|
11
|
+
OBJECT_NAME = "charge"
|
10
12
|
|
11
13
|
custom_method :capture, http_verb: :post
|
12
14
|
|
13
|
-
def refund(params = {}, opts = {})
|
14
|
-
# Old versions of charge objects included a `refunds` field that was just
|
15
|
-
# a vanilla array instead of a Stripe list object.
|
16
|
-
#
|
17
|
-
# Where possible, we'd still like to use the new refund endpoint (thus
|
18
|
-
# `self.refunds.create`), but detect the old API version by looking for
|
19
|
-
# an `Array` and fall back to the old refund URL if necessary so as to
|
20
|
-
# maintain internal compatibility.
|
21
|
-
if refunds.is_a?(Array)
|
22
|
-
resp, opts = request(:post, refund_url, params, opts)
|
23
|
-
initialize_from(resp.data, opts)
|
24
|
-
else
|
25
|
-
refunds.create(params, opts)
|
26
|
-
|
27
|
-
# now that a refund has been created, we expect the state of this object
|
28
|
-
# to change as well (i.e. `refunded` will now be `true`) so refresh it
|
29
|
-
# from the server
|
30
|
-
refresh
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
15
|
def capture(params = {}, opts = {})
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
initialize_from({ dispute: resp.data }, opts, true)
|
42
|
-
dispute
|
43
|
-
end
|
44
|
-
|
45
|
-
def close_dispute(params = {}, opts = {})
|
46
|
-
resp, opts = request(:post, close_dispute_url, params, opts)
|
47
|
-
initialize_from(resp.data, opts)
|
48
|
-
end
|
49
|
-
|
50
|
-
def mark_as_fraudulent
|
51
|
-
params = {
|
52
|
-
fraud_details: { user_report: "fraudulent" },
|
53
|
-
}
|
54
|
-
resp, opts = request(:post, resource_url, params)
|
55
|
-
initialize_from(resp.data, opts)
|
56
|
-
end
|
57
|
-
|
58
|
-
def mark_as_safe
|
59
|
-
params = {
|
60
|
-
fraud_details: { user_report: "safe" },
|
61
|
-
}
|
62
|
-
resp, opts = request(:post, resource_url, params)
|
63
|
-
initialize_from(resp.data, opts)
|
64
|
-
end
|
65
|
-
|
66
|
-
private def capture_url
|
67
|
-
resource_url + "/capture"
|
68
|
-
end
|
69
|
-
|
70
|
-
private def dispute_url
|
71
|
-
resource_url + "/dispute"
|
16
|
+
request_stripe_object(
|
17
|
+
method: :post,
|
18
|
+
path: resource_url + "/capture",
|
19
|
+
params: params,
|
20
|
+
opts: opts
|
21
|
+
)
|
72
22
|
end
|
73
23
|
|
74
|
-
|
75
|
-
|
24
|
+
def self.search(params = {}, opts = {})
|
25
|
+
_search("/v1/charges/search", params, opts)
|
76
26
|
end
|
77
27
|
|
78
|
-
|
79
|
-
|
80
|
-
private def refund_url
|
81
|
-
resource_url + "/refund"
|
28
|
+
def self.search_auto_paging_each(params = {}, opts = {}, &blk)
|
29
|
+
search(params, opts).auto_paging_each(&blk)
|
82
30
|
end
|
83
31
|
end
|
84
32
|
end
|