stripe 4.20.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 +2 -6
- data/CHANGELOG.md +52 -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 +1 -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 +5 -66
- 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 +32 -0
- 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 +1 -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 +10 -3
- 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 +2 -2
- data/test/stripe/setup_intent_test.rb +84 -0
- 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 +23 -43
- 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
@@ -7,19 +7,19 @@ module Stripe
|
|
7
7
|
extend Stripe::APIOperations::List
|
8
8
|
include Stripe::APIOperations::Save
|
9
9
|
|
10
|
-
OBJECT_NAME = "subscription"
|
10
|
+
OBJECT_NAME = "subscription"
|
11
11
|
|
12
12
|
custom_method :delete_discount, http_verb: :delete, http_path: "discount"
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
def delete_discount(params = {}, opts = {})
|
15
|
+
request_stripe_object(
|
16
|
+
method: :delete,
|
17
|
+
path: resource_url + "/discount",
|
18
|
+
params: params,
|
19
|
+
opts: opts
|
20
|
+
)
|
19
21
|
end
|
20
22
|
|
21
|
-
|
22
|
-
resource_url + "/discount"
|
23
|
-
end
|
23
|
+
save_nested_resource :source
|
24
24
|
end
|
25
25
|
end
|
@@ -6,8 +6,11 @@ module Stripe
|
|
6
6
|
include Stripe::APIOperations::Delete
|
7
7
|
extend Stripe::APIOperations::List
|
8
8
|
include Stripe::APIOperations::Save
|
9
|
+
extend Stripe::APIOperations::NestedResource
|
9
10
|
|
10
|
-
OBJECT_NAME = "subscription_item"
|
11
|
+
OBJECT_NAME = "subscription_item"
|
12
|
+
|
13
|
+
nested_resource_class_methods :usage_record, operations: %i[create]
|
11
14
|
|
12
15
|
def usage_record_summaries(params = {}, opts = {})
|
13
16
|
resp, opts = request(:get, resource_url + "/usage_record_summaries", params, opts)
|
@@ -5,28 +5,28 @@ module Stripe
|
|
5
5
|
extend Stripe::APIOperations::Create
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
include Stripe::APIOperations::Save
|
8
|
-
extend Stripe::APIOperations::NestedResource
|
9
8
|
|
10
|
-
OBJECT_NAME = "subscription_schedule"
|
9
|
+
OBJECT_NAME = "subscription_schedule"
|
11
10
|
|
12
11
|
custom_method :cancel, http_verb: :post
|
13
12
|
custom_method :release, http_verb: :post
|
14
13
|
|
15
|
-
nested_resource_class_methods :revision, operations: %i[retrieve list]
|
16
|
-
|
17
14
|
def cancel(params = {}, opts = {})
|
18
|
-
|
19
|
-
|
15
|
+
request_stripe_object(
|
16
|
+
method: :post,
|
17
|
+
path: resource_url + "/cancel",
|
18
|
+
params: params,
|
19
|
+
opts: opts
|
20
|
+
)
|
20
21
|
end
|
21
22
|
|
22
23
|
def release(params = {}, opts = {})
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
Util.convert_to_stripe_object(resp.data, opts)
|
24
|
+
request_stripe_object(
|
25
|
+
method: :post,
|
26
|
+
path: resource_url + "/release",
|
27
|
+
params: params,
|
28
|
+
opts: opts
|
29
|
+
)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -6,13 +6,17 @@ module Stripe
|
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
include Stripe::APIOperations::Save
|
8
8
|
|
9
|
-
OBJECT_NAME = "topup"
|
9
|
+
OBJECT_NAME = "topup"
|
10
10
|
|
11
11
|
custom_method :cancel, http_verb: :post
|
12
12
|
|
13
13
|
def cancel(params = {}, opts = {})
|
14
|
-
|
15
|
-
|
14
|
+
request_stripe_object(
|
15
|
+
method: :post,
|
16
|
+
path: resource_url + "/cancel",
|
17
|
+
params: params,
|
18
|
+
opts: opts
|
19
|
+
)
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
@@ -7,7 +7,7 @@ module Stripe
|
|
7
7
|
include Stripe::APIOperations::Save
|
8
8
|
extend Stripe::APIOperations::NestedResource
|
9
9
|
|
10
|
-
OBJECT_NAME = "transfer"
|
10
|
+
OBJECT_NAME = "transfer"
|
11
11
|
|
12
12
|
custom_method :cancel, http_verb: :post
|
13
13
|
|
@@ -15,13 +15,12 @@ module Stripe
|
|
15
15
|
operations: %i[create retrieve update list]
|
16
16
|
|
17
17
|
def cancel(params = {}, opts = {})
|
18
|
-
|
19
|
-
|
18
|
+
request_stripe_object(
|
19
|
+
method: :post,
|
20
|
+
path: resource_url + "/cancel",
|
21
|
+
params: params,
|
22
|
+
opts: opts
|
23
|
+
)
|
20
24
|
end
|
21
|
-
|
22
|
-
def cancel_url
|
23
|
-
resource_url + "/cancel"
|
24
|
-
end
|
25
|
-
deprecate :cancel_url, :none, 2019, 11
|
26
25
|
end
|
27
26
|
end
|
@@ -2,22 +2,6 @@
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class UsageRecord < APIResource
|
5
|
-
OBJECT_NAME = "usage_record"
|
6
|
-
|
7
|
-
def self.create(params = {}, opts = {})
|
8
|
-
unless params.key?(:subscription_item)
|
9
|
-
raise ArgumentError, "Params must have a subscription_item key"
|
10
|
-
end
|
11
|
-
req_params = params.clone.delete_if do |key, _value|
|
12
|
-
key == :subscription_item
|
13
|
-
end
|
14
|
-
resp, opts = request(
|
15
|
-
:post,
|
16
|
-
"/v1/subscription_items/#{params[:subscription_item]}/usage_records",
|
17
|
-
req_params,
|
18
|
-
opts
|
19
|
-
)
|
20
|
-
Util.convert_to_stripe_object(resp.data, opts)
|
21
|
-
end
|
5
|
+
OBJECT_NAME = "usage_record"
|
22
6
|
end
|
23
7
|
end
|
data/lib/stripe/resources.rb
CHANGED
@@ -30,7 +30,6 @@ require "stripe/resources/file_link"
|
|
30
30
|
require "stripe/resources/invoice"
|
31
31
|
require "stripe/resources/invoice_item"
|
32
32
|
require "stripe/resources/invoice_line_item"
|
33
|
-
require "stripe/resources/issuer_fraud_record"
|
34
33
|
require "stripe/resources/issuing/authorization"
|
35
34
|
require "stripe/resources/issuing/card"
|
36
35
|
require "stripe/resources/issuing/card_details"
|
@@ -56,6 +55,7 @@ require "stripe/resources/reporting/report_run"
|
|
56
55
|
require "stripe/resources/reporting/report_type"
|
57
56
|
require "stripe/resources/reversal"
|
58
57
|
require "stripe/resources/review"
|
58
|
+
require "stripe/resources/setup_intent"
|
59
59
|
require "stripe/resources/sigma/scheduled_query_run"
|
60
60
|
require "stripe/resources/sku"
|
61
61
|
require "stripe/resources/source"
|
@@ -63,7 +63,6 @@ require "stripe/resources/source_transaction"
|
|
63
63
|
require "stripe/resources/subscription"
|
64
64
|
require "stripe/resources/subscription_item"
|
65
65
|
require "stripe/resources/subscription_schedule"
|
66
|
-
require "stripe/resources/subscription_schedule_revision"
|
67
66
|
require "stripe/resources/tax_id"
|
68
67
|
require "stripe/resources/tax_rate"
|
69
68
|
require "stripe/resources/terminal/connection_token"
|