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
@@ -6,79 +6,17 @@ module Stripe
|
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
include Stripe::APIOperations::Save
|
8
8
|
|
9
|
-
OBJECT_NAME = "charge"
|
9
|
+
OBJECT_NAME = "charge"
|
10
10
|
|
11
11
|
custom_method :capture, http_verb: :post
|
12
12
|
|
13
|
-
def refund(params = {}, opts = {})
|
14
|
-
# Old versions of charge objects included a `refunds` field that was just
|
15
|
-
# a vanilla array instead of a Stripe list object.
|
16
|
-
#
|
17
|
-
# Where possible, we'd still like to use the new refund endpoint (thus
|
18
|
-
# `self.refunds.create`), but detect the old API version by looking for
|
19
|
-
# an `Array` and fall back to the old refund URL if necessary so as to
|
20
|
-
# maintain internal compatibility.
|
21
|
-
if refunds.is_a?(Array)
|
22
|
-
resp, opts = request(:post, refund_url, params, opts)
|
23
|
-
initialize_from(resp.data, opts)
|
24
|
-
else
|
25
|
-
refunds.create(params, opts)
|
26
|
-
|
27
|
-
# now that a refund has been created, we expect the state of this object
|
28
|
-
# to change as well (i.e. `refunded` will now be `true`) so refresh it
|
29
|
-
# from the server
|
30
|
-
refresh
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
13
|
def capture(params = {}, opts = {})
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
initialize_from({ dispute: resp.data }, opts, true)
|
42
|
-
dispute
|
43
|
-
end
|
44
|
-
|
45
|
-
def close_dispute(params = {}, opts = {})
|
46
|
-
resp, opts = request(:post, close_dispute_url, params, opts)
|
47
|
-
initialize_from(resp.data, opts)
|
48
|
-
end
|
49
|
-
|
50
|
-
def mark_as_fraudulent
|
51
|
-
params = {
|
52
|
-
fraud_details: { user_report: "fraudulent" },
|
53
|
-
}
|
54
|
-
resp, opts = request(:post, resource_url, params)
|
55
|
-
initialize_from(resp.data, opts)
|
56
|
-
end
|
57
|
-
|
58
|
-
def mark_as_safe
|
59
|
-
params = {
|
60
|
-
fraud_details: { user_report: "safe" },
|
61
|
-
}
|
62
|
-
resp, opts = request(:post, resource_url, params)
|
63
|
-
initialize_from(resp.data, opts)
|
64
|
-
end
|
65
|
-
|
66
|
-
private def capture_url
|
67
|
-
resource_url + "/capture"
|
68
|
-
end
|
69
|
-
|
70
|
-
private def dispute_url
|
71
|
-
resource_url + "/dispute"
|
72
|
-
end
|
73
|
-
|
74
|
-
private def close_dispute_url
|
75
|
-
resource_url + "/dispute/close"
|
76
|
-
end
|
77
|
-
|
78
|
-
# Note that this is actually the *old* refund URL and its use is no longer
|
79
|
-
# preferred.
|
80
|
-
private def refund_url
|
81
|
-
resource_url + "/refund"
|
14
|
+
request_stripe_object(
|
15
|
+
method: :post,
|
16
|
+
path: resource_url + "/capture",
|
17
|
+
params: params,
|
18
|
+
opts: opts
|
19
|
+
)
|
82
20
|
end
|
83
21
|
end
|
84
22
|
end
|
@@ -8,7 +8,7 @@ module Stripe
|
|
8
8
|
include Stripe::APIOperations::Save
|
9
9
|
extend Stripe::APIOperations::NestedResource
|
10
10
|
|
11
|
-
OBJECT_NAME = "customer"
|
11
|
+
OBJECT_NAME = "customer"
|
12
12
|
|
13
13
|
nested_resource_class_methods :balance_transaction,
|
14
14
|
operations: %i[create retrieve update list]
|
@@ -27,69 +27,9 @@ module Stripe
|
|
27
27
|
alias detach_source delete_source
|
28
28
|
end
|
29
29
|
|
30
|
-
def add_invoice_item(params, opts = {})
|
31
|
-
opts = @opts.merge(Util.normalize_opts(opts))
|
32
|
-
InvoiceItem.create(params.merge(customer: id), opts)
|
33
|
-
end
|
34
|
-
|
35
|
-
def invoices(params = {}, opts = {})
|
36
|
-
opts = @opts.merge(Util.normalize_opts(opts))
|
37
|
-
Invoice.all(params.merge(customer: id), opts)
|
38
|
-
end
|
39
|
-
|
40
|
-
def invoice_items(params = {}, opts = {})
|
41
|
-
opts = @opts.merge(Util.normalize_opts(opts))
|
42
|
-
InvoiceItem.all(params.merge(customer: id), opts)
|
43
|
-
end
|
44
|
-
|
45
|
-
def upcoming_invoice(params = {}, opts = {})
|
46
|
-
opts = @opts.merge(Util.normalize_opts(opts))
|
47
|
-
Invoice.upcoming(params.merge(customer: id), opts)
|
48
|
-
end
|
49
|
-
|
50
|
-
def charges(params = {}, opts = {})
|
51
|
-
opts = @opts.merge(Util.normalize_opts(opts))
|
52
|
-
Charge.all(params.merge(customer: id), opts)
|
53
|
-
end
|
54
|
-
|
55
|
-
def create_upcoming_invoice(params = {}, opts = {})
|
56
|
-
opts = @opts.merge(Util.normalize_opts(opts))
|
57
|
-
Invoice.create(params.merge(customer: id), opts)
|
58
|
-
end
|
59
|
-
|
60
|
-
def cancel_subscription(params = {}, opts = {})
|
61
|
-
resp, opts = request(:delete, subscription_url, params, opts)
|
62
|
-
initialize_from({ subscription: resp.data }, opts, true)
|
63
|
-
subscription
|
64
|
-
end
|
65
|
-
|
66
|
-
def update_subscription(params = {}, opts = {})
|
67
|
-
resp, opts = request(:post, subscription_url, params, opts)
|
68
|
-
initialize_from({ subscription: resp.data }, opts, true)
|
69
|
-
subscription
|
70
|
-
end
|
71
|
-
|
72
|
-
def create_subscription(params = {}, opts = {})
|
73
|
-
resp, opts = request(:post, subscriptions_url, params, opts)
|
74
|
-
initialize_from({ subscription: resp.data }, opts, true)
|
75
|
-
subscription
|
76
|
-
end
|
77
|
-
|
78
30
|
def delete_discount
|
79
|
-
|
80
|
-
initialize_from(
|
81
|
-
end
|
82
|
-
|
83
|
-
private def discount_url
|
84
|
-
resource_url + "/discount"
|
85
|
-
end
|
86
|
-
|
87
|
-
private def subscription_url
|
88
|
-
resource_url + "/subscription"
|
89
|
-
end
|
90
|
-
|
91
|
-
private def subscriptions_url
|
92
|
-
resource_url + "/subscriptions"
|
31
|
+
resp, opts = request(:delete, resource_url + "/discount")
|
32
|
+
initialize_from(resp.data, opts, true)
|
93
33
|
end
|
94
34
|
end
|
95
35
|
end
|
@@ -5,7 +5,7 @@ module Stripe
|
|
5
5
|
extend Stripe::APIOperations::List
|
6
6
|
include Stripe::APIOperations::Save
|
7
7
|
|
8
|
-
OBJECT_NAME = "dispute"
|
8
|
+
OBJECT_NAME = "dispute"
|
9
9
|
|
10
10
|
custom_method :close, http_verb: :post
|
11
11
|
|
@@ -17,11 +17,5 @@ module Stripe
|
|
17
17
|
opts: opts
|
18
18
|
)
|
19
19
|
end
|
20
|
-
|
21
|
-
def close_url
|
22
|
-
resource_url + "/close"
|
23
|
-
end
|
24
|
-
extend Gem::Deprecate
|
25
|
-
deprecate :close_url, :none, 2019, 11
|
26
20
|
end
|
27
21
|
end
|
@@ -5,40 +5,30 @@ module Stripe
|
|
5
5
|
extend Stripe::APIOperations::Create
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
|
8
|
-
OBJECT_NAME = "file"
|
8
|
+
OBJECT_NAME = "file"
|
9
9
|
|
10
10
|
# This resource can have two different object names. In latter API
|
11
11
|
# versions, only `file` is used, but since stripe-ruby may be used with
|
12
12
|
# any API version, we need to support deserializing the older
|
13
13
|
# `file_upload` object into the same class.
|
14
|
-
OBJECT_NAME_ALT = "file_upload"
|
14
|
+
OBJECT_NAME_ALT = "file_upload"
|
15
15
|
|
16
16
|
def self.resource_url
|
17
17
|
"/v1/files"
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.create(params = {}, opts = {})
|
21
|
-
# rest-client would accept a vanilla `File` for upload, but Faraday does
|
22
|
-
# not. Support the old API by wrapping a `File`-like object with an
|
23
|
-
# `UploadIO` object if we're given one.
|
24
21
|
if params[:file] && !params[:file].is_a?(String)
|
25
22
|
unless params[:file].respond_to?(:read)
|
26
23
|
raise ArgumentError, "file must respond to `#read`"
|
27
24
|
end
|
28
|
-
|
29
|
-
params[:file] = Faraday::UploadIO.new(params[:file], nil)
|
30
25
|
end
|
31
26
|
|
32
27
|
opts = {
|
33
28
|
api_base: Stripe.uploads_base,
|
34
|
-
content_type:
|
29
|
+
content_type: MultipartEncoder::MULTIPART_FORM_DATA,
|
35
30
|
}.merge(Util.normalize_opts(opts))
|
36
31
|
super
|
37
32
|
end
|
38
33
|
end
|
39
34
|
end
|
40
|
-
|
41
|
-
module Stripe
|
42
|
-
# For backwards compatibility, the `File` class is aliased to `FileUpload`.
|
43
|
-
FileUpload = File
|
44
|
-
end
|
@@ -7,7 +7,7 @@ module Stripe
|
|
7
7
|
extend Stripe::APIOperations::List
|
8
8
|
include Stripe::APIOperations::Save
|
9
9
|
|
10
|
-
OBJECT_NAME = "invoice"
|
10
|
+
OBJECT_NAME = "invoice"
|
11
11
|
|
12
12
|
custom_method :finalize_invoice, http_verb: :post, http_path: "finalize"
|
13
13
|
custom_method :mark_uncollectible, http_verb: :post
|
@@ -64,5 +64,10 @@ module Stripe
|
|
64
64
|
resp, opts = request(:get, resource_url + "/upcoming", params, opts)
|
65
65
|
Util.convert_to_stripe_object(resp.data, opts)
|
66
66
|
end
|
67
|
+
|
68
|
+
def self.list_upcoming_line_items(params, opts = {})
|
69
|
+
resp, opts = request(:get, resource_url + "/upcoming/lines", params, opts)
|
70
|
+
Util.convert_to_stripe_object(resp.data, opts)
|
71
|
+
end
|
67
72
|
end
|
68
73
|
end
|
@@ -6,7 +6,7 @@ module Stripe
|
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
include Stripe::APIOperations::Save
|
8
8
|
|
9
|
-
OBJECT_NAME = "issuing.authorization"
|
9
|
+
OBJECT_NAME = "issuing.authorization"
|
10
10
|
|
11
11
|
custom_method :approve, http_verb: :post
|
12
12
|
custom_method :decline, http_verb: :post
|
@@ -6,7 +6,7 @@ module Stripe
|
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
include Stripe::APIOperations::Save
|
8
8
|
|
9
|
-
OBJECT_NAME = "order"
|
9
|
+
OBJECT_NAME = "order"
|
10
10
|
|
11
11
|
custom_method :pay, http_verb: :post
|
12
12
|
custom_method :return_order, http_verb: :post, http_path: "returns"
|
@@ -28,13 +28,5 @@ module Stripe
|
|
28
28
|
opts: opts
|
29
29
|
)
|
30
30
|
end
|
31
|
-
|
32
|
-
private def pay_url
|
33
|
-
resource_url + "/pay"
|
34
|
-
end
|
35
|
-
|
36
|
-
private def returns_url
|
37
|
-
resource_url + "/returns"
|
38
|
-
end
|
39
31
|
end
|
40
32
|
end
|