stripe 4.10.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +10 -0
- data/.rubocop.yml +28 -4
- data/.rubocop_todo.yml +11 -22
- data/.travis.yml +3 -6
- data/.vscode/extensions.json +7 -0
- data/.vscode/settings.json +8 -0
- data/CHANGELOG.md +86 -1
- data/Gemfile +2 -10
- data/README.md +96 -40
- data/Rakefile +8 -7
- data/VERSION +1 -1
- data/lib/stripe/api_operations/delete.rb +23 -1
- data/lib/stripe/api_operations/list.rb +0 -6
- data/lib/stripe/api_operations/nested_resource.rb +14 -7
- data/lib/stripe/api_operations/request.rb +3 -7
- data/lib/stripe/api_operations/save.rb +1 -3
- data/lib/stripe/api_resource.rb +50 -2
- data/lib/stripe/connection_manager.rb +131 -0
- data/lib/stripe/error_object.rb +94 -0
- data/lib/stripe/errors.rb +22 -9
- data/lib/stripe/list_object.rb +11 -5
- data/lib/stripe/multipart_encoder.rb +131 -0
- data/lib/stripe/object_types.rb +94 -0
- data/lib/stripe/{account.rb → resources/account.rb} +49 -27
- data/lib/stripe/{account_link.rb → resources/account_link.rb} +1 -1
- data/lib/stripe/resources/alipay_account.rb +34 -0
- data/lib/stripe/{apple_pay_domain.rb → resources/apple_pay_domain.rb} +1 -1
- data/lib/stripe/resources/application_fee.rb +13 -0
- data/lib/stripe/resources/application_fee_refund.rb +30 -0
- data/lib/stripe/{balance.rb → resources/balance.rb} +1 -1
- data/lib/stripe/{balance_transaction.rb → resources/balance_transaction.rb} +1 -5
- data/lib/stripe/{bank_account.rb → resources/bank_account.rb} +14 -4
- data/lib/stripe/{bitcoin_receiver.rb → resources/bitcoin_receiver.rb} +3 -3
- data/lib/stripe/{bitcoin_transaction.rb → resources/bitcoin_transaction.rb} +1 -1
- data/lib/stripe/resources/capability.rb +33 -0
- data/lib/stripe/{card.rb → resources/card.rb} +12 -4
- data/lib/stripe/resources/charge.rb +22 -0
- data/lib/stripe/{checkout → resources/checkout}/session.rb +2 -2
- data/lib/stripe/{country_spec.rb → resources/country_spec.rb} +1 -1
- data/lib/stripe/{coupon.rb → resources/coupon.rb} +2 -2
- data/lib/stripe/resources/credit_note.rb +22 -0
- data/lib/stripe/resources/customer.rb +35 -0
- data/lib/stripe/resources/customer_balance_transaction.rb +30 -0
- data/lib/stripe/resources/discount.rb +7 -0
- data/lib/stripe/{dispute.rb → resources/dispute.rb} +9 -7
- data/lib/stripe/{ephemeral_key.rb → resources/ephemeral_key.rb} +5 -2
- data/lib/stripe/{event.rb → resources/event.rb} +1 -1
- data/lib/stripe/{exchange_rate.rb → resources/exchange_rate.rb} +1 -1
- data/lib/stripe/{file.rb → resources/file.rb} +8 -11
- data/lib/stripe/{file_link.rb → resources/file_link.rb} +2 -2
- data/lib/stripe/resources/invoice.rb +73 -0
- data/lib/stripe/{invoice_item.rb → resources/invoice_item.rb} +2 -2
- data/lib/stripe/{invoice_line_item.rb → resources/invoice_line_item.rb} +1 -1
- data/lib/stripe/resources/issuing/authorization.rb +33 -0
- data/lib/stripe/resources/issuing/card.rb +24 -0
- data/lib/stripe/{issuing → resources/issuing}/card_details.rb +1 -1
- data/lib/stripe/{issuing → resources/issuing}/cardholder.rb +2 -2
- data/lib/stripe/{issuing → resources/issuing}/dispute.rb +2 -2
- data/lib/stripe/{issuing → resources/issuing}/transaction.rb +2 -2
- data/lib/stripe/resources/login_link.rb +14 -0
- data/lib/stripe/resources/order.rb +32 -0
- data/lib/stripe/{order_return.rb → resources/order_return.rb} +1 -1
- data/lib/stripe/resources/payment_intent.rb +42 -0
- data/lib/stripe/resources/payment_method.rb +32 -0
- data/lib/stripe/resources/payout.rb +22 -0
- data/lib/stripe/{person.rb → resources/person.rb} +8 -3
- data/lib/stripe/{plan.rb → resources/plan.rb} +1 -1
- data/lib/stripe/{product.rb → resources/product.rb} +3 -3
- data/lib/stripe/resources/radar/early_fraud_warning.rb +11 -0
- data/lib/stripe/{radar → resources/radar}/value_list.rb +2 -2
- data/lib/stripe/{radar → resources/radar}/value_list_item.rb +2 -2
- data/lib/stripe/{recipient.rb → resources/recipient.rb} +2 -6
- data/lib/stripe/{recipient_transfer.rb → resources/recipient_transfer.rb} +1 -1
- data/lib/stripe/{refund.rb → resources/refund.rb} +1 -1
- data/lib/stripe/{reporting → resources/reporting}/report_run.rb +2 -2
- data/lib/stripe/{reporting → resources/reporting}/report_type.rb +2 -2
- data/lib/stripe/resources/reversal.rb +29 -0
- data/lib/stripe/resources/review.rb +20 -0
- data/lib/stripe/resources/setup_intent.rb +32 -0
- data/lib/stripe/{sigma → resources/sigma}/scheduled_query_run.rb +2 -2
- data/lib/stripe/{sku.rb → resources/sku.rb} +3 -3
- data/lib/stripe/{source.rb → resources/source.rb} +17 -15
- data/lib/stripe/{source_transaction.rb → resources/source_transaction.rb} +1 -1
- data/lib/stripe/resources/subscription.rb +25 -0
- data/lib/stripe/{subscription_item.rb → resources/subscription_item.rb} +5 -2
- data/lib/stripe/resources/subscription_schedule.rb +32 -0
- data/lib/stripe/resources/tax_id.rb +26 -0
- data/lib/stripe/resources/tax_rate.rb +11 -0
- data/lib/stripe/{terminal → resources/terminal}/connection_token.rb +2 -2
- data/lib/stripe/{terminal → resources/terminal}/location.rb +2 -2
- data/lib/stripe/{terminal → resources/terminal}/reader.rb +2 -2
- data/lib/stripe/{three_d_secure.rb → resources/three_d_secure.rb} +1 -1
- data/lib/stripe/{token.rb → resources/token.rb} +1 -1
- data/lib/stripe/resources/topup.rb +22 -0
- data/lib/stripe/resources/transfer.rb +26 -0
- data/lib/stripe/resources/usage_record.rb +7 -0
- data/lib/stripe/{usage_record_summary.rb → resources/usage_record_summary.rb} +1 -1
- data/lib/stripe/{webhook_endpoint.rb → resources/webhook_endpoint.rb} +2 -2
- data/lib/stripe/resources.rb +77 -0
- data/lib/stripe/singleton_api_resource.rb +3 -1
- data/lib/stripe/stripe_client.rb +337 -218
- data/lib/stripe/stripe_object.rb +54 -59
- data/lib/stripe/stripe_response.rb +53 -21
- data/lib/stripe/util.rb +54 -110
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +5 -3
- data/lib/stripe.rb +64 -86
- data/stripe.gemspec +14 -5
- data/test/stripe/account_link_test.rb +1 -1
- data/test/stripe/account_test.rb +186 -30
- data/test/stripe/alipay_account_test.rb +1 -1
- data/test/stripe/api_operations_test.rb +3 -4
- data/test/stripe/api_resource_test.rb +105 -18
- data/test/stripe/apple_pay_domain_test.rb +18 -5
- data/test/stripe/application_fee_refund_test.rb +1 -1
- data/test/stripe/application_fee_test.rb +45 -1
- data/test/stripe/balance_test.rb +1 -1
- data/test/stripe/balance_transaction_test.rb +20 -0
- data/test/stripe/bank_account_test.rb +1 -1
- data/test/stripe/capability_test.rb +45 -0
- data/test/stripe/charge_test.rb +13 -8
- data/test/stripe/checkout/session_test.rb +1 -1
- data/test/stripe/connection_manager_test.rb +138 -0
- data/test/stripe/country_spec_test.rb +1 -1
- data/test/stripe/coupon_test.rb +16 -6
- data/test/stripe/credit_note_test.rb +61 -0
- data/test/stripe/customer_balance_transaction_test.rb +37 -0
- data/test/stripe/customer_card_test.rb +1 -1
- data/test/stripe/customer_test.rb +151 -40
- data/test/stripe/dispute_test.rb +10 -1
- data/test/stripe/ephemeral_key_test.rb +8 -1
- data/test/stripe/errors_test.rb +30 -9
- data/test/stripe/exchange_rate_test.rb +1 -1
- data/test/stripe/file_link_test.rb +1 -1
- data/test/stripe/file_test.rb +19 -5
- data/test/stripe/invoice_item_test.rb +18 -7
- data/test/stripe/invoice_line_item_test.rb +1 -1
- data/test/stripe/invoice_test.rb +77 -9
- data/test/stripe/issuing/authorization_test.rb +33 -11
- data/test/stripe/issuing/card_test.rb +15 -6
- data/test/stripe/issuing/cardholder_test.rb +1 -1
- data/test/stripe/issuing/dispute_test.rb +1 -1
- data/test/stripe/issuing/transaction_test.rb +1 -1
- data/test/stripe/list_object_test.rb +1 -17
- data/test/stripe/login_link_test.rb +2 -2
- data/test/stripe/multipart_encoder_test.rb +130 -0
- data/test/stripe/oauth_test.rb +1 -1
- data/test/stripe/order_return_test.rb +1 -1
- data/test/stripe/order_test.rb +28 -3
- data/test/stripe/payment_intent_test.rb +31 -4
- data/test/stripe/payment_method_test.rb +19 -1
- data/test/stripe/payout_test.rb +8 -1
- data/test/stripe/person_test.rb +1 -1
- data/test/stripe/plan_test.rb +26 -20
- data/test/stripe/product_test.rb +16 -6
- data/test/stripe/radar/early_fraud_warning_test.rb +22 -0
- data/test/stripe/radar/value_list_item_test.rb +16 -6
- data/test/stripe/radar/value_list_test.rb +16 -6
- data/test/stripe/recipient_test.rb +18 -5
- data/test/stripe/refund_test.rb +1 -1
- data/test/stripe/reporting/report_run_test.rb +1 -1
- data/test/stripe/reporting/report_type_test.rb +1 -1
- data/test/stripe/reversal_test.rb +1 -1
- data/test/stripe/review_test.rb +1 -1
- data/test/stripe/setup_intent_test.rb +84 -0
- data/test/stripe/sigma/scheduled_query_run_test.rb +1 -1
- data/test/stripe/sku_test.rb +16 -6
- data/test/stripe/source_test.rb +14 -19
- data/test/stripe/source_transaction_test.rb +1 -1
- data/test/stripe/stripe_client_test.rb +230 -26
- data/test/stripe/stripe_object_test.rb +8 -36
- data/test/stripe/stripe_response_test.rb +71 -25
- data/test/stripe/subscription_item_test.rb +28 -6
- data/test/stripe/subscription_schedule_test.rb +19 -1
- data/test/stripe/subscription_test.rb +29 -9
- data/test/stripe/tax_id_test.rb +31 -0
- data/test/stripe/tax_rate_test.rb +43 -0
- data/test/stripe/terminal/connection_token_test.rb +1 -1
- data/test/stripe/terminal/location_test.rb +16 -6
- data/test/stripe/terminal/reader_test.rb +16 -6
- data/test/stripe/three_d_secure_test.rb +1 -1
- data/test/stripe/topup_test.rb +9 -1
- data/test/stripe/transfer_test.rb +46 -1
- data/test/stripe/usage_record_summary_test.rb +1 -1
- data/test/stripe/util_test.rb +1 -1
- data/test/stripe/webhook_endpoint_test.rb +18 -1
- data/test/stripe/webhook_test.rb +4 -4
- data/test/stripe_mock.rb +4 -3
- data/test/stripe_test.rb +1 -14
- data/test/test_helper.rb +14 -11
- metadata +114 -124
- data/lib/stripe/alipay_account.rb +0 -27
- data/lib/stripe/application_fee.rb +0 -23
- data/lib/stripe/application_fee_refund.rb +0 -22
- data/lib/stripe/charge.rb +0 -84
- data/lib/stripe/customer.rb +0 -90
- data/lib/stripe/invoice.rb +0 -48
- data/lib/stripe/issuer_fraud_record.rb +0 -9
- data/lib/stripe/issuing/authorization.rb +0 -22
- data/lib/stripe/issuing/card.rb +0 -18
- data/lib/stripe/login_link.rb +0 -11
- data/lib/stripe/order.rb +0 -31
- data/lib/stripe/payment_intent.rb +0 -26
- data/lib/stripe/payment_method.rb +0 -23
- data/lib/stripe/payout.rb +0 -20
- data/lib/stripe/reversal.rb +0 -22
- data/lib/stripe/review.rb +0 -14
- data/lib/stripe/subscription.rb +0 -25
- data/lib/stripe/subscription_schedule.rb +0 -32
- data/lib/stripe/subscription_schedule_revision.rb +0 -25
- data/lib/stripe/topup.rb +0 -16
- data/lib/stripe/transfer.rb +0 -23
- data/lib/stripe/usage_record.rb +0 -14
- data/test/stripe/account_external_accounts_operations_test.rb +0 -69
- data/test/stripe/account_login_links_operations_test.rb +0 -21
- data/test/stripe/account_persons_operations_test.rb +0 -70
- data/test/stripe/application_fee_refunds_operations_test.rb +0 -56
- data/test/stripe/customer_sources_operations_test.rb +0 -64
- data/test/stripe/file_upload_test.rb +0 -76
- data/test/stripe/issuer_fraud_record_test.rb +0 -20
- data/test/stripe/subscription_schedule_revision_test.rb +0 -37
- data/test/stripe/subscription_schedule_revisions_operations_test.rb +0 -35
- data/test/stripe/transfer_reversals_operations_test.rb +0 -57
- data/test/stripe/usage_record_test.rb +0 -28
data/lib/stripe.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
# Stripe Ruby bindings
|
4
4
|
# API spec at https://stripe.com/docs/api
|
5
5
|
require "cgi"
|
6
|
-
require "faraday"
|
7
6
|
require "json"
|
8
7
|
require "logger"
|
8
|
+
require "net/http"
|
9
9
|
require "openssl"
|
10
10
|
require "rbconfig"
|
11
11
|
require "securerandom"
|
@@ -26,91 +26,27 @@ require "stripe/api_operations/save"
|
|
26
26
|
|
27
27
|
# API resource support classes
|
28
28
|
require "stripe/errors"
|
29
|
+
require "stripe/object_types"
|
29
30
|
require "stripe/util"
|
31
|
+
require "stripe/connection_manager"
|
32
|
+
require "stripe/multipart_encoder"
|
30
33
|
require "stripe/stripe_client"
|
31
34
|
require "stripe/stripe_object"
|
32
35
|
require "stripe/stripe_response"
|
33
36
|
require "stripe/list_object"
|
37
|
+
require "stripe/error_object"
|
34
38
|
require "stripe/api_resource"
|
35
39
|
require "stripe/singleton_api_resource"
|
36
40
|
require "stripe/webhook"
|
37
41
|
|
38
42
|
# Named API resources
|
39
|
-
require "stripe/
|
40
|
-
require "stripe/account_link"
|
41
|
-
require "stripe/alipay_account"
|
42
|
-
require "stripe/apple_pay_domain"
|
43
|
-
require "stripe/application_fee"
|
44
|
-
require "stripe/application_fee_refund"
|
45
|
-
require "stripe/balance"
|
46
|
-
require "stripe/balance_transaction"
|
47
|
-
require "stripe/bank_account"
|
48
|
-
require "stripe/bitcoin_receiver"
|
49
|
-
require "stripe/bitcoin_transaction"
|
50
|
-
require "stripe/card"
|
51
|
-
require "stripe/charge"
|
52
|
-
require "stripe/checkout/session"
|
53
|
-
require "stripe/country_spec"
|
54
|
-
require "stripe/coupon"
|
55
|
-
require "stripe/customer"
|
56
|
-
require "stripe/dispute"
|
57
|
-
require "stripe/ephemeral_key"
|
58
|
-
require "stripe/event"
|
59
|
-
require "stripe/exchange_rate"
|
60
|
-
require "stripe/file"
|
61
|
-
require "stripe/file_link"
|
62
|
-
require "stripe/invoice"
|
63
|
-
require "stripe/invoice_item"
|
64
|
-
require "stripe/invoice_line_item"
|
65
|
-
require "stripe/issuer_fraud_record"
|
66
|
-
require "stripe/issuing/authorization"
|
67
|
-
require "stripe/issuing/card"
|
68
|
-
require "stripe/issuing/card_details"
|
69
|
-
require "stripe/issuing/cardholder"
|
70
|
-
require "stripe/issuing/dispute"
|
71
|
-
require "stripe/issuing/transaction"
|
72
|
-
require "stripe/login_link"
|
73
|
-
require "stripe/order"
|
74
|
-
require "stripe/order_return"
|
75
|
-
require "stripe/payment_intent"
|
76
|
-
require "stripe/payment_method"
|
77
|
-
require "stripe/payout"
|
78
|
-
require "stripe/person"
|
79
|
-
require "stripe/plan"
|
80
|
-
require "stripe/product"
|
81
|
-
require "stripe/radar/value_list"
|
82
|
-
require "stripe/radar/value_list_item"
|
83
|
-
require "stripe/recipient"
|
84
|
-
require "stripe/recipient_transfer"
|
85
|
-
require "stripe/refund"
|
86
|
-
require "stripe/reporting/report_run"
|
87
|
-
require "stripe/reporting/report_type"
|
88
|
-
require "stripe/reversal"
|
89
|
-
require "stripe/review"
|
90
|
-
require "stripe/sigma/scheduled_query_run"
|
91
|
-
require "stripe/sku"
|
92
|
-
require "stripe/source"
|
93
|
-
require "stripe/source_transaction"
|
94
|
-
require "stripe/subscription"
|
95
|
-
require "stripe/subscription_item"
|
96
|
-
require "stripe/subscription_schedule"
|
97
|
-
require "stripe/subscription_schedule_revision"
|
98
|
-
require "stripe/terminal/connection_token"
|
99
|
-
require "stripe/terminal/location"
|
100
|
-
require "stripe/terminal/reader"
|
101
|
-
require "stripe/three_d_secure"
|
102
|
-
require "stripe/token"
|
103
|
-
require "stripe/topup"
|
104
|
-
require "stripe/transfer"
|
105
|
-
require "stripe/usage_record"
|
106
|
-
require "stripe/usage_record_summary"
|
107
|
-
require "stripe/webhook_endpoint"
|
43
|
+
require "stripe/resources"
|
108
44
|
|
109
45
|
# OAuth
|
110
46
|
require "stripe/oauth"
|
111
47
|
|
112
48
|
module Stripe
|
113
|
-
DEFAULT_CA_BUNDLE_PATH =
|
49
|
+
DEFAULT_CA_BUNDLE_PATH = __dir__ + "/data/ca-certificates.crt"
|
114
50
|
|
115
51
|
@app_info = nil
|
116
52
|
|
@@ -121,6 +57,8 @@ module Stripe
|
|
121
57
|
@log_level = nil
|
122
58
|
@logger = nil
|
123
59
|
|
60
|
+
@proxy = nil
|
61
|
+
|
124
62
|
@max_network_retries = 0
|
125
63
|
@max_network_retry_delay = 2
|
126
64
|
@initial_network_retry_delay = 0.5
|
@@ -132,11 +70,23 @@ module Stripe
|
|
132
70
|
@open_timeout = 30
|
133
71
|
@read_timeout = 80
|
134
72
|
|
135
|
-
@enable_telemetry =
|
73
|
+
@enable_telemetry = true
|
136
74
|
|
137
75
|
class << self
|
138
|
-
attr_accessor :
|
139
|
-
|
76
|
+
attr_accessor :api_key
|
77
|
+
attr_accessor :api_version
|
78
|
+
attr_accessor :client_id
|
79
|
+
attr_accessor :stripe_account
|
80
|
+
|
81
|
+
# These all get manual attribute writers so that we can reset connections
|
82
|
+
# if they change.
|
83
|
+
attr_reader :api_base
|
84
|
+
attr_reader :connect_base
|
85
|
+
attr_reader :open_timeout
|
86
|
+
attr_reader :proxy
|
87
|
+
attr_reader :read_timeout
|
88
|
+
attr_reader :uploads_base
|
89
|
+
attr_reader :verify_ssl_certs
|
140
90
|
|
141
91
|
attr_reader :max_network_retry_delay, :initial_network_retry_delay
|
142
92
|
end
|
@@ -151,6 +101,11 @@ module Stripe
|
|
151
101
|
@app_info = info
|
152
102
|
end
|
153
103
|
|
104
|
+
def self.api_base=(api_base)
|
105
|
+
@api_base = api_base
|
106
|
+
StripeClient.clear_all_connection_managers
|
107
|
+
end
|
108
|
+
|
154
109
|
# The location of a file containing a bundle of CA certificates. By default
|
155
110
|
# the library will use an included bundle that can successfully validate
|
156
111
|
# Stripe certificates.
|
@@ -163,6 +118,8 @@ module Stripe
|
|
163
118
|
|
164
119
|
# empty this field so a new store is initialized
|
165
120
|
@ca_store = nil
|
121
|
+
|
122
|
+
StripeClient.clear_all_connection_managers
|
166
123
|
end
|
167
124
|
|
168
125
|
# A certificate store initialized from the the bundle in #ca_bundle_path and
|
@@ -182,6 +139,19 @@ module Stripe
|
|
182
139
|
end
|
183
140
|
end
|
184
141
|
|
142
|
+
def self.connection_base=(connection_base)
|
143
|
+
@connection_base = connection_base
|
144
|
+
StripeClient.clear_all_connection_managers
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.enable_telemetry?
|
148
|
+
@enable_telemetry
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.enable_telemetry=(val)
|
152
|
+
@enable_telemetry = val
|
153
|
+
end
|
154
|
+
|
185
155
|
# map to the same values as the standard library's logger
|
186
156
|
LEVEL_DEBUG = Logger::DEBUG
|
187
157
|
LEVEL_ERROR = Logger::ERROR
|
@@ -207,7 +177,8 @@ module Stripe
|
|
207
177
|
end
|
208
178
|
|
209
179
|
if !val.nil? && ![LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO].include?(val)
|
210
|
-
raise ArgumentError,
|
180
|
+
raise ArgumentError,
|
181
|
+
"log_level should only be set to `nil`, `debug` or `info`"
|
211
182
|
end
|
212
183
|
@log_level = val
|
213
184
|
end
|
@@ -235,12 +206,19 @@ module Stripe
|
|
235
206
|
@max_network_retries = val.to_i
|
236
207
|
end
|
237
208
|
|
238
|
-
def self.
|
239
|
-
@
|
209
|
+
def self.open_timeout=(open_timeout)
|
210
|
+
@open_timeout = open_timeout
|
211
|
+
StripeClient.clear_all_connection_managers
|
240
212
|
end
|
241
213
|
|
242
|
-
def self.
|
243
|
-
@
|
214
|
+
def self.proxy=(proxy)
|
215
|
+
@proxy = proxy
|
216
|
+
StripeClient.clear_all_connection_managers
|
217
|
+
end
|
218
|
+
|
219
|
+
def self.read_timeout=(read_timeout)
|
220
|
+
@read_timeout = read_timeout
|
221
|
+
StripeClient.clear_all_connection_managers
|
244
222
|
end
|
245
223
|
|
246
224
|
# Sets some basic information about the running application that's sent along
|
@@ -257,14 +235,14 @@ module Stripe
|
|
257
235
|
}
|
258
236
|
end
|
259
237
|
|
260
|
-
|
261
|
-
|
262
|
-
|
238
|
+
def self.uploads_base=(uploads_base)
|
239
|
+
@uploads_base = uploads_base
|
240
|
+
StripeClient.clear_all_connection_managers
|
263
241
|
end
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
242
|
+
|
243
|
+
def self.verify_ssl_certs=(verify_ssl_certs)
|
244
|
+
@verify_ssl_certs = verify_ssl_certs
|
245
|
+
StripeClient.clear_all_connection_managers
|
268
246
|
end
|
269
247
|
end
|
270
248
|
|
data/stripe.gemspec
CHANGED
@@ -7,19 +7,28 @@ require "stripe/version"
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "stripe"
|
9
9
|
s.version = Stripe::VERSION
|
10
|
-
s.required_ruby_version = ">= 2.
|
10
|
+
s.required_ruby_version = ">= 2.3.0"
|
11
11
|
s.summary = "Ruby bindings for the Stripe API"
|
12
|
-
s.description = "Stripe is the easiest way to accept payments online.
|
12
|
+
s.description = "Stripe is the easiest way to accept payments online. " \
|
13
|
+
"See https://stripe.com for details."
|
13
14
|
s.author = "Stripe"
|
14
15
|
s.email = "support@stripe.com"
|
15
16
|
s.homepage = "https://stripe.com/docs/api/ruby"
|
16
17
|
s.license = "MIT"
|
17
18
|
|
18
|
-
s.
|
19
|
-
|
19
|
+
s.metadata = {
|
20
|
+
"bug_tracker_uri" => "https://github.com/stripe/stripe-ruby/issues",
|
21
|
+
"changelog_uri" =>
|
22
|
+
"https://github.com/stripe/stripe-ruby/blob/master/CHANGELOG.md",
|
23
|
+
"documentation_uri" => "https://stripe.com/docs/api/ruby",
|
24
|
+
"github_repo" => "ssh://github.com/stripe/stripe-ruby",
|
25
|
+
"homepage_uri" => "https://stripe.com/docs/api/ruby",
|
26
|
+
"source_code_uri" => "https://github.com/stripe/stripe-ruby",
|
27
|
+
}
|
20
28
|
|
21
29
|
s.files = `git ls-files`.split("\n")
|
22
30
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
23
|
-
s.executables = `git ls-files -- bin/*`.split("\n")
|
31
|
+
s.executables = `git ls-files -- bin/*`.split("\n")
|
32
|
+
.map { |f| ::File.basename(f) }
|
24
33
|
s.require_paths = ["lib"]
|
25
34
|
end
|
data/test/stripe/account_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require ::File.expand_path("
|
3
|
+
require ::File.expand_path("../test_helper", __dir__)
|
4
4
|
|
5
5
|
module Stripe
|
6
6
|
class AccountTest < Test::Unit::TestCase
|
@@ -24,15 +24,18 @@ module Stripe
|
|
24
24
|
end
|
25
25
|
|
26
26
|
should "be rejectable" do
|
27
|
-
account_data = { id: "acct_foo" }
|
28
|
-
stub_request(:get, "#{Stripe.api_base}/v1/accounts/acct_foo")
|
29
|
-
.to_return(body: JSON.generate(account_data))
|
30
|
-
|
31
|
-
stub_request(:post, "#{Stripe.api_base}/v1/accounts/acct_foo/reject")
|
32
|
-
.to_return(body: JSON.generate(account_data))
|
33
|
-
|
34
27
|
account = Stripe::Account.retrieve("acct_foo")
|
35
|
-
account.reject(reason: "fraud")
|
28
|
+
account = account.reject(reason: "fraud")
|
29
|
+
assert_requested :post, "#{Stripe.api_base}/v1/accounts/#{account.id}/reject"
|
30
|
+
assert account.is_a?(Stripe::Account)
|
31
|
+
end
|
32
|
+
|
33
|
+
context ".reject" do
|
34
|
+
should "reject the account" do
|
35
|
+
account = Stripe::Account.reject("acct_foo", reason: "fraud")
|
36
|
+
assert_requested :post, "#{Stripe.api_base}/v1/accounts/#{account.id}/reject"
|
37
|
+
assert account.is_a?(Stripe::Account)
|
38
|
+
end
|
36
39
|
end
|
37
40
|
|
38
41
|
should "be creatable" do
|
@@ -54,11 +57,21 @@ module Stripe
|
|
54
57
|
assert account.is_a?(Stripe::Account)
|
55
58
|
end
|
56
59
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
context "#delete" do
|
61
|
+
should "be deletable" do
|
62
|
+
account = Stripe::Account.retrieve("acct_123")
|
63
|
+
account = account.delete
|
64
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/accounts/#{account.id}"
|
65
|
+
assert account.is_a?(Stripe::Account)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context ".delete" do
|
70
|
+
should "be deletable" do
|
71
|
+
account = Stripe::Account.delete("acct_123")
|
72
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/accounts/acct_123"
|
73
|
+
assert account.is_a?(Stripe::Account)
|
74
|
+
end
|
62
75
|
end
|
63
76
|
|
64
77
|
should "be able to list Persons" do
|
@@ -69,22 +82,6 @@ module Stripe
|
|
69
82
|
assert persons.data[0].is_a?(Stripe::Person)
|
70
83
|
end
|
71
84
|
|
72
|
-
context "#bank_account=" do
|
73
|
-
should "warn that #bank_account= is deprecated" do
|
74
|
-
old_stderr = $stderr
|
75
|
-
$stderr = StringIO.new
|
76
|
-
begin
|
77
|
-
account = Stripe::Account.retrieve("acct_123")
|
78
|
-
account.bank_account = "tok_123"
|
79
|
-
message = "NOTE: Stripe::Account#bank_account= is " \
|
80
|
-
"deprecated; use #external_account= instead"
|
81
|
-
assert_match Regexp.new(message), $stderr.string
|
82
|
-
ensure
|
83
|
-
$stderr = old_stderr
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
85
|
context "#deauthorize" do
|
89
86
|
should "deauthorize an account" do
|
90
87
|
account = Stripe::Account.retrieve("acct_123")
|
@@ -252,5 +249,164 @@ module Stripe
|
|
252
249
|
assert_equal(expected, obj.serialize_params)
|
253
250
|
end
|
254
251
|
end
|
252
|
+
|
253
|
+
context "#retrieve_capability" do
|
254
|
+
should "retrieve a capability" do
|
255
|
+
capability = Stripe::Account.retrieve_capability(
|
256
|
+
"acct_123",
|
257
|
+
"acap_123"
|
258
|
+
)
|
259
|
+
assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_123/capabilities/acap_123"
|
260
|
+
assert capability.is_a?(Stripe::Capability)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
context "#update_capability" do
|
265
|
+
should "update a capability" do
|
266
|
+
capability = Stripe::Account.update_capability(
|
267
|
+
"acct_123",
|
268
|
+
"acap_123",
|
269
|
+
requested: true
|
270
|
+
)
|
271
|
+
assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_123/capabilities/acap_123"
|
272
|
+
assert capability.is_a?(Stripe::Capability)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
context "#list_capabilities" do
|
277
|
+
should "list the account's external accounts" do
|
278
|
+
capabilities = Stripe::Account.list_capabilities(
|
279
|
+
"acct_123"
|
280
|
+
)
|
281
|
+
assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_123/capabilities"
|
282
|
+
assert capabilities.is_a?(Stripe::ListObject)
|
283
|
+
assert capabilities.data.is_a?(Array)
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
context "#create_external_account" do
|
288
|
+
should "create an external account" do
|
289
|
+
external_account = Stripe::Account.create_external_account(
|
290
|
+
"acct_123",
|
291
|
+
external_account: "btok_123"
|
292
|
+
)
|
293
|
+
assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_123/external_accounts"
|
294
|
+
assert external_account.is_a?(Stripe::BankAccount)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
context "#retrieve_external_account" do
|
299
|
+
should "retrieve an external account" do
|
300
|
+
external_account = Stripe::Account.retrieve_external_account(
|
301
|
+
"acct_123",
|
302
|
+
"ba_123"
|
303
|
+
)
|
304
|
+
assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_123/external_accounts/ba_123"
|
305
|
+
assert external_account.is_a?(Stripe::BankAccount)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
context "#update_external_account" do
|
310
|
+
should "update an external account" do
|
311
|
+
external_account = Stripe::Account.update_external_account(
|
312
|
+
"acct_123",
|
313
|
+
"ba_123",
|
314
|
+
metadata: { foo: "bar" }
|
315
|
+
)
|
316
|
+
assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_123/external_accounts/ba_123"
|
317
|
+
assert external_account.is_a?(Stripe::BankAccount)
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
context "#delete_external_account" do
|
322
|
+
should "delete an external_account" do
|
323
|
+
external_account = Stripe::Account.delete_external_account(
|
324
|
+
"acct_123",
|
325
|
+
"ba_123"
|
326
|
+
)
|
327
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/accounts/acct_123/external_accounts/ba_123"
|
328
|
+
assert external_account.deleted
|
329
|
+
assert_equal "ba_123", external_account.id
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
context "#list_external_accounts" do
|
334
|
+
should "list the account's external accounts" do
|
335
|
+
external_accounts = Stripe::Account.list_external_accounts(
|
336
|
+
"acct_123"
|
337
|
+
)
|
338
|
+
assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_123/external_accounts"
|
339
|
+
assert external_accounts.is_a?(Stripe::ListObject)
|
340
|
+
assert external_accounts.data.is_a?(Array)
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
context "#create_login_link" do
|
345
|
+
should "create a login link" do
|
346
|
+
login_link = Stripe::Account.create_login_link(
|
347
|
+
"acct_123"
|
348
|
+
)
|
349
|
+
assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_123/login_links"
|
350
|
+
assert login_link.is_a?(Stripe::LoginLink)
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
context "#create_person" do
|
355
|
+
should "create a person" do
|
356
|
+
person = Stripe::Account.create_person(
|
357
|
+
"acct_123",
|
358
|
+
first_name: "John",
|
359
|
+
last_name: "Doe"
|
360
|
+
)
|
361
|
+
assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_123/persons"
|
362
|
+
assert person.is_a?(Stripe::Person)
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
context "#retrieve_person" do
|
367
|
+
should "retrieve a person" do
|
368
|
+
person = Stripe::Account.retrieve_person(
|
369
|
+
"acct_123",
|
370
|
+
"person_123"
|
371
|
+
)
|
372
|
+
assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_123/persons/person_123"
|
373
|
+
assert person.is_a?(Stripe::Person)
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
context "#update_person" do
|
378
|
+
should "update a person" do
|
379
|
+
person = Stripe::Account.update_person(
|
380
|
+
"acct_123",
|
381
|
+
"person_123",
|
382
|
+
first_name: "John"
|
383
|
+
)
|
384
|
+
assert_requested :post, "#{Stripe.api_base}/v1/accounts/acct_123/persons/person_123"
|
385
|
+
assert person.is_a?(Stripe::Person)
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
context "#delete_person" do
|
390
|
+
should "delete an person" do
|
391
|
+
person = Stripe::Account.delete_person(
|
392
|
+
"acct_123",
|
393
|
+
"person_123"
|
394
|
+
)
|
395
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/accounts/acct_123/persons/person_123"
|
396
|
+
assert person.deleted
|
397
|
+
assert_equal "person_123", person.id
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
context "#list_persons" do
|
402
|
+
should "list the account's external accounts" do
|
403
|
+
persons = Stripe::Account.list_persons(
|
404
|
+
"acct_123"
|
405
|
+
)
|
406
|
+
assert_requested :get, "#{Stripe.api_base}/v1/accounts/acct_123/persons"
|
407
|
+
assert persons.is_a?(Stripe::ListObject)
|
408
|
+
assert persons.data.is_a?(Array)
|
409
|
+
end
|
410
|
+
end
|
255
411
|
end
|
256
412
|
end
|
@@ -1,14 +1,13 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
|
-
require ::File.expand_path("
|
3
|
+
require ::File.expand_path("../test_helper", __dir__)
|
5
4
|
|
6
5
|
module Stripe
|
7
6
|
class ApiOperationsTest < Test::Unit::TestCase
|
8
7
|
class UpdateableResource < APIResource
|
9
8
|
include Stripe::APIOperations::Save
|
10
9
|
|
11
|
-
OBJECT_NAME = "updateableresource"
|
10
|
+
OBJECT_NAME = "updateableresource"
|
12
11
|
|
13
12
|
def self.protected_fields
|
14
13
|
[:protected]
|
@@ -35,7 +34,7 @@ module Stripe
|
|
35
34
|
context ".nested_resource_class_methods" do
|
36
35
|
class MainResource < APIResource
|
37
36
|
extend Stripe::APIOperations::NestedResource
|
38
|
-
OBJECT_NAME = "mainresource"
|
37
|
+
OBJECT_NAME = "mainresource"
|
39
38
|
nested_resource_class_methods :nested,
|
40
39
|
operations: %i[create retrieve update delete list]
|
41
40
|
end
|