stripe 4.21.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +17 -4
- data/.rubocop_todo.yml +10 -9
- data/.travis.yml +2 -6
- data/CHANGELOG.md +40 -1
- data/Gemfile +2 -12
- data/README.md +10 -10
- data/Rakefile +8 -7
- data/VERSION +1 -1
- data/lib/stripe/api_operations/list.rb +0 -6
- data/lib/stripe/api_resource.rb +16 -0
- data/lib/stripe/connection_manager.rb +131 -0
- data/lib/stripe/error_object.rb +94 -0
- data/lib/stripe/errors.rb +15 -2
- data/lib/stripe/list_object.rb +2 -1
- data/lib/stripe/multipart_encoder.rb +131 -0
- data/lib/stripe/object_types.rb +0 -4
- data/lib/stripe/resources/account.rb +7 -7
- data/lib/stripe/resources/account_link.rb +1 -1
- data/lib/stripe/resources/alipay_account.rb +1 -1
- data/lib/stripe/resources/apple_pay_domain.rb +1 -1
- data/lib/stripe/resources/application_fee.rb +1 -12
- data/lib/stripe/resources/application_fee_refund.rb +1 -1
- data/lib/stripe/resources/balance.rb +1 -1
- data/lib/stripe/resources/balance_transaction.rb +1 -5
- data/lib/stripe/resources/bank_account.rb +1 -1
- data/lib/stripe/resources/bitcoin_receiver.rb +1 -1
- data/lib/stripe/resources/bitcoin_transaction.rb +1 -1
- data/lib/stripe/resources/capability.rb +1 -1
- data/lib/stripe/resources/card.rb +1 -1
- data/lib/stripe/resources/charge.rb +7 -69
- data/lib/stripe/resources/checkout/session.rb +1 -1
- data/lib/stripe/resources/country_spec.rb +1 -1
- data/lib/stripe/resources/coupon.rb +1 -1
- data/lib/stripe/resources/credit_note.rb +7 -3
- data/lib/stripe/resources/customer.rb +3 -63
- data/lib/stripe/resources/customer_balance_transaction.rb +1 -1
- data/lib/stripe/resources/discount.rb +1 -1
- data/lib/stripe/resources/dispute.rb +7 -9
- data/lib/stripe/resources/ephemeral_key.rb +1 -1
- data/lib/stripe/resources/event.rb +1 -1
- data/lib/stripe/resources/exchange_rate.rb +1 -1
- data/lib/stripe/resources/file.rb +3 -13
- data/lib/stripe/resources/file_link.rb +1 -1
- data/lib/stripe/resources/invoice.rb +36 -11
- data/lib/stripe/resources/invoice_item.rb +1 -1
- data/lib/stripe/resources/invoice_line_item.rb +1 -1
- data/lib/stripe/resources/issuing/authorization.rb +13 -5
- data/lib/stripe/resources/issuing/card.rb +7 -3
- data/lib/stripe/resources/issuing/card_details.rb +1 -1
- data/lib/stripe/resources/issuing/cardholder.rb +1 -1
- data/lib/stripe/resources/issuing/dispute.rb +1 -1
- data/lib/stripe/resources/issuing/transaction.rb +1 -1
- data/lib/stripe/resources/login_link.rb +1 -1
- data/lib/stripe/resources/order.rb +13 -13
- data/lib/stripe/resources/order_return.rb +1 -1
- data/lib/stripe/resources/payment_intent.rb +19 -7
- data/lib/stripe/resources/payment_method.rb +13 -5
- data/lib/stripe/resources/payout.rb +7 -9
- data/lib/stripe/resources/person.rb +1 -1
- data/lib/stripe/resources/plan.rb +1 -1
- data/lib/stripe/resources/product.rb +1 -1
- data/lib/stripe/resources/radar/early_fraud_warning.rb +1 -1
- data/lib/stripe/resources/radar/value_list.rb +1 -1
- data/lib/stripe/resources/radar/value_list_item.rb +1 -1
- data/lib/stripe/resources/recipient.rb +1 -5
- data/lib/stripe/resources/recipient_transfer.rb +1 -1
- data/lib/stripe/resources/refund.rb +1 -1
- data/lib/stripe/resources/reporting/report_run.rb +1 -1
- data/lib/stripe/resources/reporting/report_type.rb +1 -1
- data/lib/stripe/resources/reversal.rb +1 -1
- data/lib/stripe/resources/review.rb +7 -3
- data/lib/stripe/resources/setup_intent.rb +13 -5
- data/lib/stripe/resources/sigma/scheduled_query_run.rb +1 -1
- data/lib/stripe/resources/sku.rb +1 -1
- data/lib/stripe/resources/source.rb +7 -9
- data/lib/stripe/resources/source_transaction.rb +1 -1
- data/lib/stripe/resources/subscription.rb +9 -9
- data/lib/stripe/resources/subscription_item.rb +4 -1
- data/lib/stripe/resources/subscription_schedule.rb +13 -13
- data/lib/stripe/resources/tax_id.rb +1 -1
- data/lib/stripe/resources/tax_rate.rb +1 -1
- data/lib/stripe/resources/terminal/connection_token.rb +1 -1
- data/lib/stripe/resources/terminal/location.rb +1 -1
- data/lib/stripe/resources/terminal/reader.rb +1 -1
- data/lib/stripe/resources/three_d_secure.rb +1 -1
- data/lib/stripe/resources/token.rb +1 -1
- data/lib/stripe/resources/topup.rb +7 -3
- data/lib/stripe/resources/transfer.rb +7 -8
- data/lib/stripe/resources/usage_record.rb +1 -17
- data/lib/stripe/resources/usage_record_summary.rb +1 -1
- data/lib/stripe/resources/webhook_endpoint.rb +1 -1
- data/lib/stripe/resources.rb +0 -2
- data/lib/stripe/stripe_client.rb +281 -183
- data/lib/stripe/stripe_object.rb +4 -23
- data/lib/stripe/stripe_response.rb +53 -21
- data/lib/stripe/util.rb +14 -11
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +1 -1
- data/lib/stripe.rb +56 -15
- data/stripe.gemspec +6 -9
- data/test/stripe/account_test.rb +0 -16
- data/test/stripe/api_operations_test.rb +2 -2
- data/test/stripe/api_resource_test.rb +98 -8
- data/test/stripe/balance_transaction_test.rb +20 -0
- data/test/stripe/charge_test.rb +0 -16
- data/test/stripe/connection_manager_test.rb +138 -0
- data/test/stripe/customer_test.rb +1 -44
- data/test/stripe/errors_test.rb +29 -8
- data/test/stripe/file_test.rb +0 -10
- data/test/stripe/invoice_test.rb +17 -1
- data/test/stripe/list_object_test.rb +0 -16
- data/test/stripe/login_link_test.rb +1 -1
- data/test/stripe/multipart_encoder_test.rb +130 -0
- data/test/stripe/payment_intent_test.rb +1 -1
- data/test/stripe/setup_intent_test.rb +1 -1
- data/test/stripe/source_test.rb +0 -18
- data/test/stripe/stripe_client_test.rb +214 -29
- data/test/stripe/stripe_object_test.rb +7 -35
- data/test/stripe/stripe_response_test.rb +70 -24
- data/test/stripe/subscription_item_test.rb +12 -0
- data/test/stripe/subscription_schedule_test.rb +0 -34
- data/test/stripe/subscription_test.rb +2 -2
- data/test/stripe/webhook_test.rb +2 -2
- data/test/stripe_mock.rb +4 -3
- data/test/stripe_test.rb +0 -13
- data/test/test_helper.rb +10 -5
- metadata +13 -42
- data/lib/stripe/resources/issuer_fraud_record.rb +0 -9
- data/lib/stripe/resources/subscription_schedule_revision.rb +0 -34
- data/test/stripe/file_upload_test.rb +0 -79
- data/test/stripe/issuer_fraud_record_test.rb +0 -20
- data/test/stripe/subscription_schedule_revision_test.rb +0 -37
- data/test/stripe/usage_record_test.rb +0 -28
data/test/test_helper.rb
CHANGED
|
@@ -17,7 +17,7 @@ require ::File.expand_path("test_data", __dir__)
|
|
|
17
17
|
require ::File.expand_path("stripe_mock", __dir__)
|
|
18
18
|
|
|
19
19
|
# If changing this number, please also change it in `.travis.yml`.
|
|
20
|
-
MOCK_MINIMUM_VERSION = "0.
|
|
20
|
+
MOCK_MINIMUM_VERSION = "0.63.0"
|
|
21
21
|
MOCK_PORT = Stripe::StripeMock.start
|
|
22
22
|
|
|
23
23
|
# Disable all real network connections except those that are outgoing to
|
|
@@ -28,16 +28,21 @@ WebMock.disable_net_connect!(allow: "localhost:#{MOCK_PORT}")
|
|
|
28
28
|
# we can print one error and fail fast so that it's more clear to the user how
|
|
29
29
|
# they should fix the problem.
|
|
30
30
|
begin
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
resp = Net::HTTP.get_response(URI("http://localhost:#{MOCK_PORT}/"))
|
|
32
|
+
version = resp["Stripe-Mock-Version"]
|
|
33
|
+
|
|
34
|
+
if version.nil?
|
|
35
|
+
abort("Couldn't find `Stripe-Mock-Version` in response from " \
|
|
36
|
+
"`localhost:#{MOCK_PORT}`. Is the service running there stripe-mock?")
|
|
37
|
+
end
|
|
38
|
+
|
|
34
39
|
if version != "master" &&
|
|
35
40
|
Gem::Version.new(version) < Gem::Version.new(MOCK_MINIMUM_VERSION)
|
|
36
41
|
abort("Your version of stripe-mock (#{version}) is too old. The minimum " \
|
|
37
42
|
"version to run this test suite is #{MOCK_MINIMUM_VERSION}. Please " \
|
|
38
43
|
"see its repository for upgrade instructions.")
|
|
39
44
|
end
|
|
40
|
-
rescue
|
|
45
|
+
rescue Errno::ECONNREFUSED
|
|
41
46
|
abort("Couldn't reach stripe-mock at `localhost:#{MOCK_PORT}`. Is " \
|
|
42
47
|
"it running? Please see README for setup instructions.")
|
|
43
48
|
end
|
metadata
CHANGED
|
@@ -1,43 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stripe
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 5.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stripe
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
12
|
-
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: faraday
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0.13'
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0.13'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: net-http-persistent
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '3.0'
|
|
34
|
-
type: :runtime
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '3.0'
|
|
11
|
+
date: 2019-08-20 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
41
13
|
description: Stripe is the easiest way to accept payments online. See https://stripe.com
|
|
42
14
|
for details.
|
|
43
15
|
email: support@stripe.com
|
|
@@ -73,8 +45,11 @@ files:
|
|
|
73
45
|
- lib/stripe/api_operations/request.rb
|
|
74
46
|
- lib/stripe/api_operations/save.rb
|
|
75
47
|
- lib/stripe/api_resource.rb
|
|
48
|
+
- lib/stripe/connection_manager.rb
|
|
49
|
+
- lib/stripe/error_object.rb
|
|
76
50
|
- lib/stripe/errors.rb
|
|
77
51
|
- lib/stripe/list_object.rb
|
|
52
|
+
- lib/stripe/multipart_encoder.rb
|
|
78
53
|
- lib/stripe/oauth.rb
|
|
79
54
|
- lib/stripe/object_types.rb
|
|
80
55
|
- lib/stripe/resources.rb
|
|
@@ -108,7 +83,6 @@ files:
|
|
|
108
83
|
- lib/stripe/resources/invoice.rb
|
|
109
84
|
- lib/stripe/resources/invoice_item.rb
|
|
110
85
|
- lib/stripe/resources/invoice_line_item.rb
|
|
111
|
-
- lib/stripe/resources/issuer_fraud_record.rb
|
|
112
86
|
- lib/stripe/resources/issuing/authorization.rb
|
|
113
87
|
- lib/stripe/resources/issuing/card.rb
|
|
114
88
|
- lib/stripe/resources/issuing/card_details.rb
|
|
@@ -142,7 +116,6 @@ files:
|
|
|
142
116
|
- lib/stripe/resources/subscription.rb
|
|
143
117
|
- lib/stripe/resources/subscription_item.rb
|
|
144
118
|
- lib/stripe/resources/subscription_schedule.rb
|
|
145
|
-
- lib/stripe/resources/subscription_schedule_revision.rb
|
|
146
119
|
- lib/stripe/resources/tax_id.rb
|
|
147
120
|
- lib/stripe/resources/tax_rate.rb
|
|
148
121
|
- lib/stripe/resources/terminal/connection_token.rb
|
|
@@ -174,10 +147,12 @@ files:
|
|
|
174
147
|
- test/stripe/application_fee_refund_test.rb
|
|
175
148
|
- test/stripe/application_fee_test.rb
|
|
176
149
|
- test/stripe/balance_test.rb
|
|
150
|
+
- test/stripe/balance_transaction_test.rb
|
|
177
151
|
- test/stripe/bank_account_test.rb
|
|
178
152
|
- test/stripe/capability_test.rb
|
|
179
153
|
- test/stripe/charge_test.rb
|
|
180
154
|
- test/stripe/checkout/session_test.rb
|
|
155
|
+
- test/stripe/connection_manager_test.rb
|
|
181
156
|
- test/stripe/country_spec_test.rb
|
|
182
157
|
- test/stripe/coupon_test.rb
|
|
183
158
|
- test/stripe/credit_note_test.rb
|
|
@@ -190,11 +165,9 @@ files:
|
|
|
190
165
|
- test/stripe/exchange_rate_test.rb
|
|
191
166
|
- test/stripe/file_link_test.rb
|
|
192
167
|
- test/stripe/file_test.rb
|
|
193
|
-
- test/stripe/file_upload_test.rb
|
|
194
168
|
- test/stripe/invoice_item_test.rb
|
|
195
169
|
- test/stripe/invoice_line_item_test.rb
|
|
196
170
|
- test/stripe/invoice_test.rb
|
|
197
|
-
- test/stripe/issuer_fraud_record_test.rb
|
|
198
171
|
- test/stripe/issuing/authorization_test.rb
|
|
199
172
|
- test/stripe/issuing/card_test.rb
|
|
200
173
|
- test/stripe/issuing/cardholder_test.rb
|
|
@@ -202,6 +175,7 @@ files:
|
|
|
202
175
|
- test/stripe/issuing/transaction_test.rb
|
|
203
176
|
- test/stripe/list_object_test.rb
|
|
204
177
|
- test/stripe/login_link_test.rb
|
|
178
|
+
- test/stripe/multipart_encoder_test.rb
|
|
205
179
|
- test/stripe/oauth_test.rb
|
|
206
180
|
- test/stripe/order_return_test.rb
|
|
207
181
|
- test/stripe/order_test.rb
|
|
@@ -229,7 +203,6 @@ files:
|
|
|
229
203
|
- test/stripe/stripe_object_test.rb
|
|
230
204
|
- test/stripe/stripe_response_test.rb
|
|
231
205
|
- test/stripe/subscription_item_test.rb
|
|
232
|
-
- test/stripe/subscription_schedule_revision_test.rb
|
|
233
206
|
- test/stripe/subscription_schedule_test.rb
|
|
234
207
|
- test/stripe/subscription_test.rb
|
|
235
208
|
- test/stripe/tax_id_test.rb
|
|
@@ -241,7 +214,6 @@ files:
|
|
|
241
214
|
- test/stripe/topup_test.rb
|
|
242
215
|
- test/stripe/transfer_test.rb
|
|
243
216
|
- test/stripe/usage_record_summary_test.rb
|
|
244
|
-
- test/stripe/usage_record_test.rb
|
|
245
217
|
- test/stripe/util_test.rb
|
|
246
218
|
- test/stripe/webhook_endpoint_test.rb
|
|
247
219
|
- test/stripe/webhook_test.rb
|
|
@@ -267,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
267
239
|
requirements:
|
|
268
240
|
- - ">="
|
|
269
241
|
- !ruby/object:Gem::Version
|
|
270
|
-
version: 2.
|
|
242
|
+
version: 2.3.0
|
|
271
243
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
244
|
requirements:
|
|
273
245
|
- - ">="
|
|
@@ -290,10 +262,12 @@ test_files:
|
|
|
290
262
|
- test/stripe/application_fee_refund_test.rb
|
|
291
263
|
- test/stripe/application_fee_test.rb
|
|
292
264
|
- test/stripe/balance_test.rb
|
|
265
|
+
- test/stripe/balance_transaction_test.rb
|
|
293
266
|
- test/stripe/bank_account_test.rb
|
|
294
267
|
- test/stripe/capability_test.rb
|
|
295
268
|
- test/stripe/charge_test.rb
|
|
296
269
|
- test/stripe/checkout/session_test.rb
|
|
270
|
+
- test/stripe/connection_manager_test.rb
|
|
297
271
|
- test/stripe/country_spec_test.rb
|
|
298
272
|
- test/stripe/coupon_test.rb
|
|
299
273
|
- test/stripe/credit_note_test.rb
|
|
@@ -306,11 +280,9 @@ test_files:
|
|
|
306
280
|
- test/stripe/exchange_rate_test.rb
|
|
307
281
|
- test/stripe/file_link_test.rb
|
|
308
282
|
- test/stripe/file_test.rb
|
|
309
|
-
- test/stripe/file_upload_test.rb
|
|
310
283
|
- test/stripe/invoice_item_test.rb
|
|
311
284
|
- test/stripe/invoice_line_item_test.rb
|
|
312
285
|
- test/stripe/invoice_test.rb
|
|
313
|
-
- test/stripe/issuer_fraud_record_test.rb
|
|
314
286
|
- test/stripe/issuing/authorization_test.rb
|
|
315
287
|
- test/stripe/issuing/card_test.rb
|
|
316
288
|
- test/stripe/issuing/cardholder_test.rb
|
|
@@ -318,6 +290,7 @@ test_files:
|
|
|
318
290
|
- test/stripe/issuing/transaction_test.rb
|
|
319
291
|
- test/stripe/list_object_test.rb
|
|
320
292
|
- test/stripe/login_link_test.rb
|
|
293
|
+
- test/stripe/multipart_encoder_test.rb
|
|
321
294
|
- test/stripe/oauth_test.rb
|
|
322
295
|
- test/stripe/order_return_test.rb
|
|
323
296
|
- test/stripe/order_test.rb
|
|
@@ -345,7 +318,6 @@ test_files:
|
|
|
345
318
|
- test/stripe/stripe_object_test.rb
|
|
346
319
|
- test/stripe/stripe_response_test.rb
|
|
347
320
|
- test/stripe/subscription_item_test.rb
|
|
348
|
-
- test/stripe/subscription_schedule_revision_test.rb
|
|
349
321
|
- test/stripe/subscription_schedule_test.rb
|
|
350
322
|
- test/stripe/subscription_test.rb
|
|
351
323
|
- test/stripe/tax_id_test.rb
|
|
@@ -357,7 +329,6 @@ test_files:
|
|
|
357
329
|
- test/stripe/topup_test.rb
|
|
358
330
|
- test/stripe/transfer_test.rb
|
|
359
331
|
- test/stripe/usage_record_summary_test.rb
|
|
360
|
-
- test/stripe/usage_record_test.rb
|
|
361
332
|
- test/stripe/util_test.rb
|
|
362
333
|
- test/stripe/webhook_endpoint_test.rb
|
|
363
334
|
- test/stripe/webhook_test.rb
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Stripe
|
|
4
|
-
class SubscriptionScheduleRevision < APIResource
|
|
5
|
-
extend Stripe::APIOperations::List
|
|
6
|
-
|
|
7
|
-
OBJECT_NAME = "subscription_schedule_revision".freeze
|
|
8
|
-
|
|
9
|
-
def resource_url
|
|
10
|
-
if !respond_to?(:schedule) || schedule.nil?
|
|
11
|
-
raise NotImplementedError,
|
|
12
|
-
"Subscription schedule revisions cannot be accessed without a " \
|
|
13
|
-
"subscription schedule ID."
|
|
14
|
-
end
|
|
15
|
-
"#{SubscriptionSchedule.resource_url}/#{CGI.escape(schedule)}" \
|
|
16
|
-
"/revisions/#{CGI.escape(id)}"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def self.retrieve(_id, _opts = {})
|
|
20
|
-
raise NotImplementedError,
|
|
21
|
-
"Subscription schedule revisions cannot be retrieved without a " \
|
|
22
|
-
"subscription schedule ID. Retrieve a subscribtion schedule " \
|
|
23
|
-
"revision using `SubscriptionSchedule.retrieve_revision(" \
|
|
24
|
-
"'schedule_id', 'revision_id')`"
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def self.list(_id, _opts = {})
|
|
28
|
-
raise NotImplementedError,
|
|
29
|
-
"Subscription schedule revisions cannot be listed without a " \
|
|
30
|
-
"subscription schedule ID. List subscribtion schedule revisions " \
|
|
31
|
-
"using `SubscriptionSchedule.list_revisions('schedule_id')`"
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require ::File.expand_path("../test_helper", __dir__)
|
|
4
|
-
|
|
5
|
-
module Stripe
|
|
6
|
-
# This is a strict copy of `FileTest`, except that it uses
|
|
7
|
-
# `Stripe::FileUpload` instead of `Stripe::File`.
|
|
8
|
-
class FileUploadTest < Test::Unit::TestCase
|
|
9
|
-
should "be listable" do
|
|
10
|
-
files = Stripe::FileUpload.list
|
|
11
|
-
assert_requested :get, "#{Stripe.api_base}/v1/files"
|
|
12
|
-
assert files.data.is_a?(Array)
|
|
13
|
-
assert files.data[0].is_a?(Stripe::FileUpload)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
should "be retrievable" do
|
|
17
|
-
file = Stripe::FileUpload.retrieve("file_123")
|
|
18
|
-
assert_requested :get, "#{Stripe.api_base}/v1/files/file_123"
|
|
19
|
-
assert file.is_a?(Stripe::FileUpload)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
context ".create" do
|
|
23
|
-
setup do
|
|
24
|
-
# We don't point to the same host for the API and uploads in
|
|
25
|
-
# production, but `stripe-mock` supports both APIs.
|
|
26
|
-
Stripe.uploads_base = Stripe.api_base
|
|
27
|
-
|
|
28
|
-
# Set `api_base` to `nil` to ensure that these requests are _not_ sent
|
|
29
|
-
# to the default API hostname. `api_base` is reset when each test
|
|
30
|
-
# starts so this won't affect the global state.
|
|
31
|
-
Stripe.api_base = nil
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
should "be creatable with a File" do
|
|
35
|
-
file = Stripe::FileUpload.create(
|
|
36
|
-
purpose: "dispute_evidence",
|
|
37
|
-
file: ::File.new(__FILE__),
|
|
38
|
-
file_link_data: { create: true }
|
|
39
|
-
)
|
|
40
|
-
assert_requested :post, "#{Stripe.uploads_base}/v1/files"
|
|
41
|
-
assert file.is_a?(Stripe::FileUpload)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
should "be creatable with a Tempfile" do
|
|
45
|
-
tempfile = Tempfile.new("foo")
|
|
46
|
-
tempfile.write("Hello world")
|
|
47
|
-
tempfile.rewind
|
|
48
|
-
|
|
49
|
-
file = Stripe::FileUpload.create(
|
|
50
|
-
purpose: "dispute_evidence",
|
|
51
|
-
file: tempfile,
|
|
52
|
-
file_link_data: { create: true }
|
|
53
|
-
)
|
|
54
|
-
assert_requested :post, "#{Stripe.uploads_base}/v1/files"
|
|
55
|
-
assert file.is_a?(Stripe::FileUpload)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
should "be creatable with Faraday::UploadIO" do
|
|
59
|
-
file = Stripe::FileUpload.create(
|
|
60
|
-
purpose: "dispute_evidence",
|
|
61
|
-
file: Faraday::UploadIO.new(::File.new(__FILE__), nil),
|
|
62
|
-
file_link_data: { create: true }
|
|
63
|
-
)
|
|
64
|
-
assert_requested :post, "#{Stripe.uploads_base}/v1/files"
|
|
65
|
-
assert file.is_a?(Stripe::FileUpload)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
should "be deserializable when `object=file`" do
|
|
70
|
-
file = Stripe::Util.convert_to_stripe_object({ object: "file" }, {})
|
|
71
|
-
assert file.is_a?(Stripe::FileUpload)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
should "be deserializable when `object=file_upload`" do
|
|
75
|
-
file = Stripe::Util.convert_to_stripe_object({ object: "file_upload" }, {})
|
|
76
|
-
assert file.is_a?(Stripe::FileUpload)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require ::File.expand_path("../test_helper", __dir__)
|
|
4
|
-
|
|
5
|
-
module Stripe
|
|
6
|
-
class IssuerFraudRecordTest < Test::Unit::TestCase
|
|
7
|
-
should "be listable" do
|
|
8
|
-
issfrs = Stripe::IssuerFraudRecord.list
|
|
9
|
-
assert_requested :get, "#{Stripe.api_base}/v1/issuer_fraud_records"
|
|
10
|
-
assert issfrs.data.is_a?(Array)
|
|
11
|
-
assert issfrs.data[0].is_a?(Stripe::IssuerFraudRecord)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
should "be retrievable" do
|
|
15
|
-
issfr = Stripe::IssuerFraudRecord.retrieve("issfr_123")
|
|
16
|
-
assert_requested :get, "#{Stripe.api_base}/v1/issuer_fraud_records/issfr_123"
|
|
17
|
-
assert issfr.is_a?(Stripe::IssuerFraudRecord)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require ::File.expand_path("../test_helper", __dir__)
|
|
4
|
-
|
|
5
|
-
module Stripe
|
|
6
|
-
class SubscriptionScheduleRevisionTest < Test::Unit::TestCase
|
|
7
|
-
context "#resource_url" do
|
|
8
|
-
should "return a resource URL" do
|
|
9
|
-
revision = Stripe::SubscriptionScheduleRevision.construct_from(
|
|
10
|
-
id: "sub_sched_rev_123",
|
|
11
|
-
schedule: "sub_sched_123"
|
|
12
|
-
)
|
|
13
|
-
assert_equal "/v1/subscription_schedules/sub_sched_123/revisions/sub_sched_rev_123",
|
|
14
|
-
revision.resource_url
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
should "raise without a subscription schedule" do
|
|
18
|
-
revision = Stripe::SubscriptionScheduleRevision.construct_from(id: "sub_sched_rev_123")
|
|
19
|
-
assert_raises NotImplementedError do
|
|
20
|
-
revision.resource_url
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
should "raise on #retrieve" do
|
|
26
|
-
assert_raises NotImplementedError do
|
|
27
|
-
Stripe::SubscriptionScheduleRevision.retrieve("sub_sched_rev_123")
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
should "raise on #list" do
|
|
32
|
-
assert_raises NotImplementedError do
|
|
33
|
-
Stripe::SubscriptionScheduleRevision.list("sub_sched_rev_123", {})
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require ::File.expand_path("../test_helper", __dir__)
|
|
4
|
-
|
|
5
|
-
module Stripe
|
|
6
|
-
class UsageRecordTest < Test::Unit::TestCase
|
|
7
|
-
should "be creatable" do
|
|
8
|
-
usage_record = Stripe::UsageRecord.create(
|
|
9
|
-
quantity: 5000,
|
|
10
|
-
subscription_item: "si_abc",
|
|
11
|
-
timestamp: Time.now.to_i,
|
|
12
|
-
action: "increment"
|
|
13
|
-
)
|
|
14
|
-
assert_requested :post, "#{Stripe.api_base}/v1/subscription_items/si_abc/usage_records"
|
|
15
|
-
assert usage_record.is_a?(Stripe::UsageRecord)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
should "raise when subscription_item is missing" do
|
|
19
|
-
assert_raise ArgumentError do
|
|
20
|
-
Stripe::UsageRecord.create(
|
|
21
|
-
quantity: 5000,
|
|
22
|
-
timestamp: Time.now.to_i,
|
|
23
|
-
action: "increment"
|
|
24
|
-
)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|