stripe 4.24.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/.rubocop.yml +17 -4
- data/.rubocop_todo.yml +10 -9
- data/.travis.yml +1 -5
- data/CHANGELOG.md +22 -0
- data/Gemfile +2 -12
- data/README.md +10 -10
- data/Rakefile +8 -7
- data/VERSION +1 -1
- data/lib/stripe.rb +56 -15
- data/lib/stripe/api_operations/list.rb +0 -6
- 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 -1
- data/lib/stripe/resources.rb +0 -1
- data/lib/stripe/resources/account.rb +1 -5
- 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 -1
- 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 +1 -1
- 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 +1 -7
- 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 +6 -1
- 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 +1 -1
- data/lib/stripe/resources/issuing/card.rb +1 -1
- 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 +1 -9
- data/lib/stripe/resources/order_return.rb +1 -1
- data/lib/stripe/resources/payment_intent.rb +1 -1
- data/lib/stripe/resources/payment_method.rb +1 -1
- data/lib/stripe/resources/payout.rb +1 -7
- 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 +1 -1
- data/lib/stripe/resources/setup_intent.rb +1 -1
- 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 +1 -7
- data/lib/stripe/resources/source_transaction.rb +1 -1
- data/lib/stripe/resources/subscription.rb +9 -9
- data/lib/stripe/resources/subscription_item.rb +1 -1
- data/lib/stripe/resources/subscription_schedule.rb +1 -1
- 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 +1 -1
- data/lib/stripe/resources/transfer.rb +1 -6
- 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/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 +10 -11
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +1 -1
- 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 +2 -10
- 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_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 +11 -39
- data/lib/stripe/resources/issuer_fraud_record.rb +0 -9
- data/test/stripe/file_upload_test.rb +0 -79
- data/test/stripe/issuer_fraud_record_test.rb +0 -20
- data/test/stripe/usage_record_test.rb +0 -28
@@ -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,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
|