stripe 4.18.1 → 5.42.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 +232 -1
- data/CODE_OF_CONDUCT.md +77 -0
- data/Gemfile +10 -16
- data/README.md +168 -63
- 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_resource.rb +27 -2
- 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 +108 -0
- data/lib/stripe/{account.rb → resources/account.rb} +23 -26
- data/lib/stripe/{account_link.rb → resources/account_link.rb} +2 -1
- data/lib/stripe/{alipay_account.rb → resources/alipay_account.rb} +1 -1
- data/lib/stripe/{apple_pay_domain.rb → resources/apple_pay_domain.rb} +2 -1
- data/lib/stripe/resources/application_fee.rb +14 -0
- data/lib/stripe/{application_fee_refund.rb → resources/application_fee_refund.rb} +3 -2
- data/lib/stripe/{balance.rb → resources/balance.rb} +2 -1
- data/lib/stripe/{balance_transaction.rb → resources/balance_transaction.rb} +2 -5
- data/lib/stripe/{bank_account.rb → resources/bank_account.rb} +5 -6
- data/lib/stripe/{issuing/dispute.rb → resources/billing_portal/configuration.rb} +4 -3
- data/lib/stripe/{checkout → resources/billing_portal}/session.rb +3 -2
- data/lib/stripe/{bitcoin_receiver.rb → resources/bitcoin_receiver.rb} +5 -5
- data/lib/stripe/resources/bitcoin_transaction.rb +16 -0
- data/lib/stripe/{capability.rb → resources/capability.rb} +3 -2
- data/lib/stripe/{card.rb → resources/card.rb} +5 -7
- data/lib/stripe/resources/charge.rb +23 -0
- data/lib/stripe/resources/checkout/session.rb +27 -0
- data/lib/stripe/{country_spec.rb → resources/country_spec.rb} +2 -1
- data/lib/stripe/{coupon.rb → resources/coupon.rb} +2 -1
- data/lib/stripe/resources/credit_note.rb +33 -0
- data/lib/stripe/resources/credit_note_line_item.rb +8 -0
- data/lib/stripe/resources/customer.rb +52 -0
- data/lib/stripe/resources/customer_balance_transaction.rb +31 -0
- data/lib/stripe/{discount.rb → resources/discount.rb} +2 -1
- data/lib/stripe/resources/dispute.rb +22 -0
- data/lib/stripe/{ephemeral_key.rb → resources/ephemeral_key.rb} +2 -1
- data/lib/stripe/{event.rb → resources/event.rb} +2 -1
- data/lib/stripe/{exchange_rate.rb → resources/exchange_rate.rb} +2 -1
- data/lib/stripe/{file.rb → resources/file.rb} +7 -12
- data/lib/stripe/{file_link.rb → resources/file_link.rb} +2 -1
- 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 +74 -0
- data/lib/stripe/{invoice_item.rb → resources/invoice_item.rb} +2 -1
- data/lib/stripe/{invoice_line_item.rb → resources/invoice_line_item.rb} +2 -1
- data/lib/stripe/{issuing → resources/issuing}/authorization.rb +14 -5
- data/lib/stripe/{issuing → resources/issuing}/card.rb +8 -3
- data/lib/stripe/resources/issuing/card_details.rb +10 -0
- data/lib/stripe/{issuing → resources/issuing}/cardholder.rb +2 -1
- data/lib/stripe/resources/issuing/dispute.rb +25 -0
- data/lib/stripe/{issuing → resources/issuing}/transaction.rb +2 -1
- data/lib/stripe/resources/line_item.rb +8 -0
- data/lib/stripe/{login_link.rb → resources/login_link.rb} +2 -1
- data/lib/stripe/resources/mandate.rb +8 -0
- data/lib/stripe/resources/order.rb +33 -0
- data/lib/stripe/{order_return.rb → resources/order_return.rb} +2 -1
- data/lib/stripe/resources/payment_intent.rb +43 -0
- data/lib/stripe/{payment_method.rb → resources/payment_method.rb} +14 -5
- data/lib/stripe/resources/payout.rb +33 -0
- data/lib/stripe/{person.rb → resources/person.rb} +2 -1
- data/lib/stripe/{plan.rb → resources/plan.rb} +2 -1
- data/lib/stripe/resources/price.rb +12 -0
- data/lib/stripe/{product.rb → resources/product.rb} +2 -1
- data/lib/stripe/resources/promotion_code.rb +12 -0
- data/lib/stripe/resources/quote.rb +105 -0
- data/lib/stripe/{radar → resources/radar}/early_fraud_warning.rb +2 -1
- data/lib/stripe/{radar → resources/radar}/value_list.rb +2 -1
- data/lib/stripe/{radar → resources/radar}/value_list_item.rb +2 -1
- data/lib/stripe/{recipient.rb → resources/recipient.rb} +2 -5
- data/lib/stripe/{recipient_transfer.rb → resources/recipient_transfer.rb} +1 -1
- data/lib/stripe/{refund.rb → resources/refund.rb} +2 -1
- data/lib/stripe/{reporting → resources/reporting}/report_run.rb +2 -1
- data/lib/stripe/{reporting → resources/reporting}/report_type.rb +2 -1
- data/lib/stripe/{reversal.rb → resources/reversal.rb} +4 -3
- data/lib/stripe/{review.rb → resources/review.rb} +8 -3
- data/lib/stripe/resources/setup_attempt.rb +10 -0
- data/lib/stripe/resources/setup_intent.rb +33 -0
- data/lib/stripe/resources/shipping_rate.rb +12 -0
- data/lib/stripe/{sigma → resources/sigma}/scheduled_query_run.rb +2 -1
- data/lib/stripe/{sku.rb → resources/sku.rb} +2 -1
- data/lib/stripe/{source.rb → resources/source.rb} +20 -15
- data/lib/stripe/{source_transaction.rb → resources/source_transaction.rb} +2 -1
- data/lib/stripe/{subscription.rb → resources/subscription.rb} +12 -11
- data/lib/stripe/resources/subscription_item.rb +26 -0
- data/lib/stripe/resources/subscription_schedule.rb +33 -0
- data/lib/stripe/resources/tax_code.rb +10 -0
- data/lib/stripe/{tax_id.rb → resources/tax_id.rb} +2 -1
- data/lib/stripe/{tax_rate.rb → resources/tax_rate.rb} +2 -1
- data/lib/stripe/{terminal → resources/terminal}/connection_token.rb +2 -1
- data/lib/stripe/{terminal → resources/terminal}/location.rb +2 -1
- data/lib/stripe/{terminal → resources/terminal}/reader.rb +2 -1
- data/lib/stripe/{three_d_secure.rb → resources/three_d_secure.rb} +2 -1
- data/lib/stripe/{token.rb → resources/token.rb} +2 -1
- data/lib/stripe/{topup.rb → resources/topup.rb} +8 -3
- data/lib/stripe/{transfer.rb → resources/transfer.rb} +9 -8
- data/lib/stripe/resources/usage_record.rb +8 -0
- data/lib/stripe/{usage_record_summary.rb → resources/usage_record_summary.rb} +2 -1
- data/lib/stripe/{webhook_endpoint.rb → resources/webhook_endpoint.rb} +2 -1
- data/lib/stripe/resources.rb +91 -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 +43 -103
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +39 -8
- data/lib/stripe.rb +41 -205
- data/stripe.gemspec +19 -5
- metadata +109 -287
- data/.editorconfig +0 -10
- data/.gitattributes +0 -4
- data/.github/ISSUE_TEMPLATE.md +0 -5
- data/.gitignore +0 -8
- data/.rubocop.yml +0 -42
- 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/application_fee.rb +0 -24
- data/lib/stripe/bitcoin_transaction.rb +0 -15
- data/lib/stripe/charge.rb +0 -84
- data/lib/stripe/credit_note.rb +0 -18
- data/lib/stripe/customer.rb +0 -93
- data/lib/stripe/dispute.rb +0 -23
- data/lib/stripe/invoice.rb +0 -49
- data/lib/stripe/issuer_fraud_record.rb +0 -9
- data/lib/stripe/issuing/card_details.rb +0 -9
- data/lib/stripe/order.rb +0 -32
- data/lib/stripe/payment_intent.rb +0 -30
- data/lib/stripe/payout.rb +0 -24
- data/lib/stripe/subscription_item.rb +0 -18
- data/lib/stripe/subscription_schedule.rb +0 -35
- data/lib/stripe/subscription_schedule_revision.rb +0 -34
- data/lib/stripe/usage_record.rb +0 -23
- 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 -523
- 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_card_test.rb +0 -42
- data/test/stripe/customer_test.rb +0 -226
- 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/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
data/lib/stripe/list_object.rb
CHANGED
@@ -7,7 +7,7 @@ module Stripe
|
|
7
7
|
include Stripe::APIOperations::Request
|
8
8
|
include Stripe::APIOperations::Create
|
9
9
|
|
10
|
-
OBJECT_NAME = "list"
|
10
|
+
OBJECT_NAME = "list"
|
11
11
|
|
12
12
|
# This accessor allows a `ListObject` to inherit various filters that were
|
13
13
|
# given to a predecessor. This allows for things like consistent limits,
|
@@ -51,6 +51,16 @@ module Stripe
|
|
51
51
|
# Iterates through each resource in all pages, making additional fetches to
|
52
52
|
# the API as necessary.
|
53
53
|
#
|
54
|
+
# The default iteration direction is forwards according to Stripe's API
|
55
|
+
# "natural" ordering direction -- newer objects first, and moving towards
|
56
|
+
# older objects.
|
57
|
+
#
|
58
|
+
# However, if the initial list object was fetched using an `ending_before`
|
59
|
+
# cursor (and only `ending_before`, `starting_after` cannot also be
|
60
|
+
# included), the method assumes that the user is trying to iterate
|
61
|
+
# backwards compared to natural ordering and returns results that way --
|
62
|
+
# older objects first, and moving towards newer objects.
|
63
|
+
#
|
54
64
|
# Note that this method will make as many API calls as necessary to fetch
|
55
65
|
# all resources. For more granular control, please see +each+ and
|
56
66
|
# +next_page+.
|
@@ -59,8 +69,18 @@ module Stripe
|
|
59
69
|
|
60
70
|
page = self
|
61
71
|
loop do
|
62
|
-
|
63
|
-
|
72
|
+
# Backward iterating activates if we have an `ending_before` constraint
|
73
|
+
# and _just_ an `ending_before` constraint. If `starting_after` was
|
74
|
+
# also used, we iterate forwards normally.
|
75
|
+
if filters.include?(:ending_before) &&
|
76
|
+
!filters.include?(:starting_after)
|
77
|
+
page.reverse_each(&blk)
|
78
|
+
page = page.previous_page
|
79
|
+
else
|
80
|
+
page.each(&blk)
|
81
|
+
page = page.next_page
|
82
|
+
end
|
83
|
+
|
64
84
|
break if page.empty?
|
65
85
|
end
|
66
86
|
end
|
@@ -72,8 +92,8 @@ module Stripe
|
|
72
92
|
|
73
93
|
def retrieve(id, opts = {})
|
74
94
|
id, retrieve_params = Util.normalize_id(id)
|
75
|
-
|
76
|
-
|
95
|
+
url = "#{resource_url}/#{CGI.escape(id)}"
|
96
|
+
resp, opts = execute_resource_request(:get, url, retrieve_params, opts)
|
77
97
|
Util.convert_to_stripe_object(resp.data, opts)
|
78
98
|
end
|
79
99
|
|
@@ -83,6 +103,7 @@ module Stripe
|
|
83
103
|
# was given, the default limit will be fetched again.
|
84
104
|
def next_page(params = {}, opts = {})
|
85
105
|
return self.class.empty_list(opts) unless has_more
|
106
|
+
|
86
107
|
last_id = data.last.id
|
87
108
|
|
88
109
|
params = filters.merge(starting_after: last_id).merge(params)
|
@@ -95,6 +116,8 @@ module Stripe
|
|
95
116
|
# This method will try to respect the limit of the current page. If none
|
96
117
|
# was given, the default limit will be fetched again.
|
97
118
|
def previous_page(params = {}, opts = {})
|
119
|
+
return self.class.empty_list(opts) unless has_more
|
120
|
+
|
98
121
|
first_id = data.first.id
|
99
122
|
|
100
123
|
params = filters.merge(ending_before: first_id).merge(params)
|
@@ -106,5 +129,11 @@ module Stripe
|
|
106
129
|
url ||
|
107
130
|
raise(ArgumentError, "List object does not contain a 'url' field.")
|
108
131
|
end
|
132
|
+
|
133
|
+
# Iterates through each resource in the page represented by the current
|
134
|
+
# `ListObject` in reverse.
|
135
|
+
def reverse_each(&blk)
|
136
|
+
data.reverse_each(&blk)
|
137
|
+
end
|
109
138
|
end
|
110
139
|
end
|
@@ -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
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# rubocop:disable Metrics/MethodLength
|
5
|
+
|
6
|
+
module Stripe
|
7
|
+
module ObjectTypes
|
8
|
+
def self.object_names_to_classes
|
9
|
+
{
|
10
|
+
# data structures
|
11
|
+
ListObject::OBJECT_NAME => ListObject,
|
12
|
+
|
13
|
+
# business objects
|
14
|
+
Account::OBJECT_NAME => Account,
|
15
|
+
AccountLink::OBJECT_NAME => AccountLink,
|
16
|
+
AlipayAccount::OBJECT_NAME => AlipayAccount,
|
17
|
+
ApplePayDomain::OBJECT_NAME => ApplePayDomain,
|
18
|
+
ApplicationFee::OBJECT_NAME => ApplicationFee,
|
19
|
+
ApplicationFeeRefund::OBJECT_NAME => ApplicationFeeRefund,
|
20
|
+
Balance::OBJECT_NAME => Balance,
|
21
|
+
BalanceTransaction::OBJECT_NAME => BalanceTransaction,
|
22
|
+
BankAccount::OBJECT_NAME => BankAccount,
|
23
|
+
BillingPortal::Configuration::OBJECT_NAME => BillingPortal::Configuration,
|
24
|
+
BillingPortal::Session::OBJECT_NAME => BillingPortal::Session,
|
25
|
+
BitcoinReceiver::OBJECT_NAME => BitcoinReceiver,
|
26
|
+
BitcoinTransaction::OBJECT_NAME => BitcoinTransaction,
|
27
|
+
Capability::OBJECT_NAME => Capability,
|
28
|
+
Card::OBJECT_NAME => Card,
|
29
|
+
Charge::OBJECT_NAME => Charge,
|
30
|
+
Checkout::Session::OBJECT_NAME => Checkout::Session,
|
31
|
+
CountrySpec::OBJECT_NAME => CountrySpec,
|
32
|
+
Coupon::OBJECT_NAME => Coupon,
|
33
|
+
CreditNote::OBJECT_NAME => CreditNote,
|
34
|
+
CreditNoteLineItem::OBJECT_NAME => CreditNoteLineItem,
|
35
|
+
Customer::OBJECT_NAME => Customer,
|
36
|
+
CustomerBalanceTransaction::OBJECT_NAME => CustomerBalanceTransaction,
|
37
|
+
Discount::OBJECT_NAME => Discount,
|
38
|
+
Dispute::OBJECT_NAME => Dispute,
|
39
|
+
EphemeralKey::OBJECT_NAME => EphemeralKey,
|
40
|
+
Event::OBJECT_NAME => Event,
|
41
|
+
ExchangeRate::OBJECT_NAME => ExchangeRate,
|
42
|
+
File::OBJECT_NAME => File,
|
43
|
+
File::OBJECT_NAME_ALT => File,
|
44
|
+
FileLink::OBJECT_NAME => FileLink,
|
45
|
+
Identity::VerificationReport::OBJECT_NAME => Identity::VerificationReport,
|
46
|
+
Identity::VerificationSession::OBJECT_NAME => Identity::VerificationSession,
|
47
|
+
Invoice::OBJECT_NAME => Invoice,
|
48
|
+
InvoiceItem::OBJECT_NAME => InvoiceItem,
|
49
|
+
InvoiceLineItem::OBJECT_NAME => InvoiceLineItem,
|
50
|
+
Issuing::Authorization::OBJECT_NAME => Issuing::Authorization,
|
51
|
+
Issuing::Card::OBJECT_NAME => Issuing::Card,
|
52
|
+
Issuing::CardDetails::OBJECT_NAME => Issuing::CardDetails,
|
53
|
+
Issuing::Cardholder::OBJECT_NAME => Issuing::Cardholder,
|
54
|
+
Issuing::Dispute::OBJECT_NAME => Issuing::Dispute,
|
55
|
+
Issuing::Transaction::OBJECT_NAME => Issuing::Transaction,
|
56
|
+
LineItem::OBJECT_NAME => LineItem,
|
57
|
+
LoginLink::OBJECT_NAME => LoginLink,
|
58
|
+
Mandate::OBJECT_NAME => Mandate,
|
59
|
+
Order::OBJECT_NAME => Order,
|
60
|
+
OrderReturn::OBJECT_NAME => OrderReturn,
|
61
|
+
PaymentIntent::OBJECT_NAME => PaymentIntent,
|
62
|
+
PaymentMethod::OBJECT_NAME => PaymentMethod,
|
63
|
+
Payout::OBJECT_NAME => Payout,
|
64
|
+
Person::OBJECT_NAME => Person,
|
65
|
+
Plan::OBJECT_NAME => Plan,
|
66
|
+
Price::OBJECT_NAME => Price,
|
67
|
+
Product::OBJECT_NAME => Product,
|
68
|
+
PromotionCode::OBJECT_NAME => PromotionCode,
|
69
|
+
Quote::OBJECT_NAME => Quote,
|
70
|
+
Radar::EarlyFraudWarning::OBJECT_NAME => Radar::EarlyFraudWarning,
|
71
|
+
Radar::ValueList::OBJECT_NAME => Radar::ValueList,
|
72
|
+
Radar::ValueListItem::OBJECT_NAME => Radar::ValueListItem,
|
73
|
+
Recipient::OBJECT_NAME => Recipient,
|
74
|
+
RecipientTransfer::OBJECT_NAME => RecipientTransfer,
|
75
|
+
Refund::OBJECT_NAME => Refund,
|
76
|
+
Reporting::ReportRun::OBJECT_NAME => Reporting::ReportRun,
|
77
|
+
Reporting::ReportType::OBJECT_NAME => Reporting::ReportType,
|
78
|
+
Reversal::OBJECT_NAME => Reversal,
|
79
|
+
Review::OBJECT_NAME => Review,
|
80
|
+
SetupAttempt::OBJECT_NAME => SetupAttempt,
|
81
|
+
SetupIntent::OBJECT_NAME => SetupIntent,
|
82
|
+
ShippingRate::OBJECT_NAME => ShippingRate,
|
83
|
+
Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun,
|
84
|
+
SKU::OBJECT_NAME => SKU,
|
85
|
+
Source::OBJECT_NAME => Source,
|
86
|
+
SourceTransaction::OBJECT_NAME => SourceTransaction,
|
87
|
+
Subscription::OBJECT_NAME => Subscription,
|
88
|
+
SubscriptionItem::OBJECT_NAME => SubscriptionItem,
|
89
|
+
SubscriptionSchedule::OBJECT_NAME => SubscriptionSchedule,
|
90
|
+
TaxCode::OBJECT_NAME => TaxCode,
|
91
|
+
TaxId::OBJECT_NAME => TaxId,
|
92
|
+
TaxRate::OBJECT_NAME => TaxRate,
|
93
|
+
Terminal::ConnectionToken::OBJECT_NAME => Terminal::ConnectionToken,
|
94
|
+
Terminal::Location::OBJECT_NAME => Terminal::Location,
|
95
|
+
Terminal::Reader::OBJECT_NAME => Terminal::Reader,
|
96
|
+
ThreeDSecure::OBJECT_NAME => ThreeDSecure,
|
97
|
+
Token::OBJECT_NAME => Token,
|
98
|
+
Topup::OBJECT_NAME => Topup,
|
99
|
+
Transfer::OBJECT_NAME => Transfer,
|
100
|
+
UsageRecord::OBJECT_NAME => UsageRecord,
|
101
|
+
UsageRecordSummary::OBJECT_NAME => UsageRecordSummary,
|
102
|
+
WebhookEndpoint::OBJECT_NAME => WebhookEndpoint,
|
103
|
+
}
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# rubocop:enable Metrics/MethodLength
|
@@ -1,33 +1,40 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
4
5
|
class Account < APIResource
|
5
6
|
extend Gem::Deprecate
|
6
7
|
extend Stripe::APIOperations::Create
|
7
|
-
extend Stripe::APIOperations::List
|
8
8
|
include Stripe::APIOperations::Delete
|
9
|
+
extend Stripe::APIOperations::List
|
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
|
|
16
|
-
save_nested_resource :external_account
|
17
17
|
nested_resource_class_methods :capability,
|
18
18
|
operations: %i[retrieve update list],
|
19
19
|
resource_plural: "capabilities"
|
20
|
-
nested_resource_class_methods :external_account,
|
21
|
-
operations: %i[create retrieve update delete
|
22
|
-
list]
|
23
|
-
nested_resource_class_methods :login_link, operations: %i[create]
|
24
20
|
nested_resource_class_methods :person,
|
25
|
-
operations: %i[create retrieve update delete
|
26
|
-
list]
|
21
|
+
operations: %i[create retrieve update delete list]
|
27
22
|
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
def reject(params = {}, opts = {})
|
24
|
+
request_stripe_object(
|
25
|
+
method: :post,
|
26
|
+
path: resource_url + "/reject",
|
27
|
+
params: params,
|
28
|
+
opts: opts
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
save_nested_resource :external_account
|
33
|
+
|
34
|
+
nested_resource_class_methods :external_account,
|
35
|
+
operations: %i[create retrieve update delete list]
|
36
|
+
|
37
|
+
nested_resource_class_methods :login_link, operations: %i[create]
|
31
38
|
|
32
39
|
def resource_url
|
33
40
|
if self["id"]
|
@@ -38,12 +45,8 @@ module Stripe
|
|
38
45
|
end
|
39
46
|
|
40
47
|
# @override To make id optional
|
41
|
-
def self.retrieve(id =
|
42
|
-
id
|
43
|
-
nil
|
44
|
-
else
|
45
|
-
Util.check_string_argument!(id)
|
46
|
-
end
|
48
|
+
def self.retrieve(id = nil, opts = {})
|
49
|
+
Util.check_string_argument!(id) if id
|
47
50
|
|
48
51
|
# Account used to be a singleton, where this method's signature was
|
49
52
|
# `(opts={})`. For the sake of not breaking folks who pass in an OAuth
|
@@ -58,7 +61,7 @@ module Stripe
|
|
58
61
|
end
|
59
62
|
|
60
63
|
def persons(params = {}, opts = {})
|
61
|
-
resp, opts =
|
64
|
+
resp, opts = execute_resource_request(:get, resource_url + "/persons", params, opts)
|
62
65
|
Util.convert_to_stripe_object(resp.data, opts)
|
63
66
|
end
|
64
67
|
|
@@ -66,11 +69,6 @@ module Stripe
|
|
66
69
|
# already has a capabilities property which is a hash and not the sub-list
|
67
70
|
# of capabilities.
|
68
71
|
|
69
|
-
def reject(params = {}, opts = {})
|
70
|
-
resp, opts = request(:post, resource_url + "/reject", params, opts)
|
71
|
-
initialize_from(resp.data, opts)
|
72
|
-
end
|
73
|
-
|
74
72
|
# Somewhat unfortunately, we attempt to do a special encoding trick when
|
75
73
|
# serializing `additional_owners` under an account: when updating a value,
|
76
74
|
# we actually send the update parameters up as an integer-indexed hash
|
@@ -134,11 +132,10 @@ module Stripe
|
|
134
132
|
client_id: client_id,
|
135
133
|
stripe_user_id: id,
|
136
134
|
}
|
135
|
+
opts = @opts.merge(Util.normalize_opts(opts))
|
137
136
|
OAuth.deauthorize(params, opts)
|
138
137
|
end
|
139
138
|
|
140
|
-
ARGUMENT_NOT_PROVIDED = Object.new
|
141
|
-
|
142
139
|
private def serialize_additional_owners(legal_entity, additional_owners)
|
143
140
|
original_value =
|
144
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"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
class ApplicationFee < APIResource
|
6
|
+
extend Stripe::APIOperations::List
|
7
|
+
extend Stripe::APIOperations::NestedResource
|
8
|
+
|
9
|
+
OBJECT_NAME = "application_fee"
|
10
|
+
|
11
|
+
nested_resource_class_methods :refund,
|
12
|
+
operations: %i[create retrieve update list]
|
13
|
+
end
|
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,20 +7,18 @@ 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
|
|
16
17
|
def resource_url
|
17
18
|
if respond_to?(:customer)
|
18
|
-
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources"
|
19
|
-
"/#{CGI.escape(id)}"
|
19
|
+
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
|
20
20
|
elsif respond_to?(:account)
|
21
|
-
"#{Account.resource_url}/#{CGI.escape(account)}/external_accounts"
|
22
|
-
"/#{CGI.escape(id)}"
|
21
|
+
"#{Account.resource_url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
@@ -1,13 +1,14 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Stripe
|
4
|
-
module
|
5
|
-
class
|
5
|
+
module BillingPortal
|
6
|
+
class Configuration < APIResource
|
6
7
|
extend Stripe::APIOperations::Create
|
7
8
|
extend Stripe::APIOperations::List
|
8
9
|
include Stripe::APIOperations::Save
|
9
10
|
|
10
|
-
OBJECT_NAME = "
|
11
|
+
OBJECT_NAME = "billing_portal.configuration"
|
11
12
|
end
|
12
13
|
end
|
13
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
|
-
module
|
5
|
+
module BillingPortal
|
5
6
|
class Session < APIResource
|
6
7
|
extend Stripe::APIOperations::Create
|
7
8
|
|
8
|
-
OBJECT_NAME = "
|
9
|
+
OBJECT_NAME = "billing_portal.session"
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -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 creating or retrieving BitcoinReceivers is deprecated. Please use
|
6
|
+
# the Sources API instead: https://stripe.com/docs/sources/bitcoin
|
4
7
|
class BitcoinReceiver < APIResource
|
5
|
-
# Directly creating or retrieving BitcoinReceivers is deprecated. Please use
|
6
|
-
# the Sources API instead: https://stripe.com/docs/sources/bitcoin
|
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"
|
@@ -14,8 +15,7 @@ module Stripe
|
|
14
15
|
|
15
16
|
def resource_url
|
16
17
|
if respond_to?(:customer) && !customer.nil? && customer != ""
|
17
|
-
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources"
|
18
|
-
"/#{CGI.escape(id)}"
|
18
|
+
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
|
19
19
|
else
|
20
20
|
"#{self.class.resource_url}/#{CGI.escape(id)}"
|
21
21
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
# Directly retrieving BitcoinTransactions is deprecated. Please use
|
6
|
+
# the Sources API instead: https://stripe.com/docs/sources/bitcoin
|
7
|
+
class BitcoinTransaction < APIResource
|
8
|
+
extend Stripe::APIOperations::List
|
9
|
+
|
10
|
+
OBJECT_NAME = "bitcoin_transaction"
|
11
|
+
|
12
|
+
def self.resource_url
|
13
|
+
"/v1/bitcoin/transactions"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|