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
@@ -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
|
@@ -16,33 +16,58 @@ module Stripe
|
|
16
16
|
custom_method :void_invoice, http_verb: :post, http_path: "void"
|
17
17
|
|
18
18
|
def finalize_invoice(params = {}, opts = {})
|
19
|
-
|
20
|
-
|
19
|
+
request_stripe_object(
|
20
|
+
method: :post,
|
21
|
+
path: resource_url + "/finalize",
|
22
|
+
params: params,
|
23
|
+
opts: opts
|
24
|
+
)
|
21
25
|
end
|
22
26
|
|
23
27
|
def mark_uncollectible(params = {}, opts = {})
|
24
|
-
|
25
|
-
|
28
|
+
request_stripe_object(
|
29
|
+
method: :post,
|
30
|
+
path: resource_url + "/mark_uncollectible",
|
31
|
+
params: params,
|
32
|
+
opts: opts
|
33
|
+
)
|
26
34
|
end
|
27
35
|
|
28
36
|
def pay(params = {}, opts = {})
|
29
|
-
|
30
|
-
|
37
|
+
request_stripe_object(
|
38
|
+
method: :post,
|
39
|
+
path: resource_url + "/pay",
|
40
|
+
params: params,
|
41
|
+
opts: opts
|
42
|
+
)
|
31
43
|
end
|
32
44
|
|
33
45
|
def send_invoice(params = {}, opts = {})
|
34
|
-
|
35
|
-
|
46
|
+
request_stripe_object(
|
47
|
+
method: :post,
|
48
|
+
path: resource_url + "/send",
|
49
|
+
params: params,
|
50
|
+
opts: opts
|
51
|
+
)
|
36
52
|
end
|
37
53
|
|
38
54
|
def void_invoice(params = {}, opts = {})
|
39
|
-
|
40
|
-
|
55
|
+
request_stripe_object(
|
56
|
+
method: :post,
|
57
|
+
path: resource_url + "/void",
|
58
|
+
params: params,
|
59
|
+
opts: opts
|
60
|
+
)
|
41
61
|
end
|
42
62
|
|
43
63
|
def self.upcoming(params, opts = {})
|
44
64
|
resp, opts = request(:get, resource_url + "/upcoming", params, opts)
|
45
65
|
Util.convert_to_stripe_object(resp.data, opts)
|
46
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
|
47
72
|
end
|
48
73
|
end
|
@@ -6,19 +6,27 @@ 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
|
13
13
|
|
14
14
|
def approve(params = {}, opts = {})
|
15
|
-
|
16
|
-
|
15
|
+
request_stripe_object(
|
16
|
+
method: :post,
|
17
|
+
path: resource_url + "/approve",
|
18
|
+
params: params,
|
19
|
+
opts: opts
|
20
|
+
)
|
17
21
|
end
|
18
22
|
|
19
23
|
def decline(params = {}, opts = {})
|
20
|
-
|
21
|
-
|
24
|
+
request_stripe_object(
|
25
|
+
method: :post,
|
26
|
+
path: resource_url + "/decline",
|
27
|
+
params: params,
|
28
|
+
opts: opts
|
29
|
+
)
|
22
30
|
end
|
23
31
|
end
|
24
32
|
end
|
@@ -7,13 +7,17 @@ module Stripe
|
|
7
7
|
extend Stripe::APIOperations::List
|
8
8
|
include Stripe::APIOperations::Save
|
9
9
|
|
10
|
-
OBJECT_NAME = "issuing.card"
|
10
|
+
OBJECT_NAME = "issuing.card"
|
11
11
|
|
12
12
|
custom_method :details, http_verb: :get
|
13
13
|
|
14
14
|
def details(params = {}, opts = {})
|
15
|
-
|
16
|
-
|
15
|
+
request_stripe_object(
|
16
|
+
method: :get,
|
17
|
+
path: resource_url + "/details",
|
18
|
+
params: params,
|
19
|
+
opts: opts
|
20
|
+
)
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -6,27 +6,27 @@ 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"
|
13
13
|
|
14
14
|
def pay(params = {}, opts = {})
|
15
|
-
|
16
|
-
|
15
|
+
request_stripe_object(
|
16
|
+
method: :post,
|
17
|
+
path: resource_url + "/pay",
|
18
|
+
params: params,
|
19
|
+
opts: opts
|
20
|
+
)
|
17
21
|
end
|
18
22
|
|
19
23
|
def return_order(params = {}, opts = {})
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
private def returns_url
|
29
|
-
resource_url + "/returns"
|
24
|
+
request_stripe_object(
|
25
|
+
method: :post,
|
26
|
+
path: resource_url + "/returns",
|
27
|
+
params: params,
|
28
|
+
opts: opts
|
29
|
+
)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -6,25 +6,37 @@ module Stripe
|
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
include Stripe::APIOperations::Save
|
8
8
|
|
9
|
-
OBJECT_NAME = "payment_intent"
|
9
|
+
OBJECT_NAME = "payment_intent"
|
10
10
|
|
11
11
|
custom_method :cancel, http_verb: :post
|
12
12
|
custom_method :capture, http_verb: :post
|
13
13
|
custom_method :confirm, http_verb: :post
|
14
14
|
|
15
15
|
def cancel(params = {}, opts = {})
|
16
|
-
|
17
|
-
|
16
|
+
request_stripe_object(
|
17
|
+
method: :post,
|
18
|
+
path: resource_url + "/cancel",
|
19
|
+
params: params,
|
20
|
+
opts: opts
|
21
|
+
)
|
18
22
|
end
|
19
23
|
|
20
24
|
def capture(params = {}, opts = {})
|
21
|
-
|
22
|
-
|
25
|
+
request_stripe_object(
|
26
|
+
method: :post,
|
27
|
+
path: resource_url + "/capture",
|
28
|
+
params: params,
|
29
|
+
opts: opts
|
30
|
+
)
|
23
31
|
end
|
24
32
|
|
25
33
|
def confirm(params = {}, opts = {})
|
26
|
-
|
27
|
-
|
34
|
+
request_stripe_object(
|
35
|
+
method: :post,
|
36
|
+
path: resource_url + "/confirm",
|
37
|
+
params: params,
|
38
|
+
opts: opts
|
39
|
+
)
|
28
40
|
end
|
29
41
|
end
|
30
42
|
end
|
@@ -6,19 +6,27 @@ module Stripe
|
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
include Stripe::APIOperations::Save
|
8
8
|
|
9
|
-
OBJECT_NAME = "payment_method"
|
9
|
+
OBJECT_NAME = "payment_method"
|
10
10
|
|
11
11
|
custom_method :attach, http_verb: :post
|
12
12
|
custom_method :detach, http_verb: :post
|
13
13
|
|
14
14
|
def attach(params = {}, opts = {})
|
15
|
-
|
16
|
-
|
15
|
+
request_stripe_object(
|
16
|
+
method: :post,
|
17
|
+
path: resource_url + "/attach",
|
18
|
+
params: params,
|
19
|
+
opts: opts
|
20
|
+
)
|
17
21
|
end
|
18
22
|
|
19
23
|
def detach(params = {}, opts = {})
|
20
|
-
|
21
|
-
|
24
|
+
request_stripe_object(
|
25
|
+
method: :post,
|
26
|
+
path: resource_url + "/detach",
|
27
|
+
params: params,
|
28
|
+
opts: opts
|
29
|
+
)
|
22
30
|
end
|
23
31
|
end
|
24
32
|
end
|
@@ -6,19 +6,17 @@ module Stripe
|
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
include Stripe::APIOperations::Save
|
8
8
|
|
9
|
-
OBJECT_NAME = "payout"
|
9
|
+
OBJECT_NAME = "payout"
|
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
|
-
|
18
|
-
def cancel_url
|
19
|
-
resource_url + "/cancel"
|
20
|
-
end
|
21
|
-
extend Gem::Deprecate
|
22
|
-
deprecate :cancel_url, :none, 2019, 11
|
23
21
|
end
|
24
22
|
end
|
@@ -4,13 +4,17 @@ module Stripe
|
|
4
4
|
class Review < APIResource
|
5
5
|
extend Stripe::APIOperations::List
|
6
6
|
|
7
|
-
OBJECT_NAME = "review"
|
7
|
+
OBJECT_NAME = "review"
|
8
8
|
|
9
9
|
custom_method :approve, http_verb: :post
|
10
10
|
|
11
11
|
def approve(params = {}, opts = {})
|
12
|
-
|
13
|
-
|
12
|
+
request_stripe_object(
|
13
|
+
method: :post,
|
14
|
+
path: resource_url + "/approve",
|
15
|
+
params: params,
|
16
|
+
opts: opts
|
17
|
+
)
|
14
18
|
end
|
15
19
|
end
|
16
20
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class SetupIntent < APIResource
|
5
|
+
extend Stripe::APIOperations::Create
|
6
|
+
extend Stripe::APIOperations::List
|
7
|
+
include Stripe::APIOperations::Save
|
8
|
+
|
9
|
+
OBJECT_NAME = "setup_intent"
|
10
|
+
|
11
|
+
custom_method :cancel, http_verb: :post
|
12
|
+
custom_method :confirm, http_verb: :post
|
13
|
+
|
14
|
+
def cancel(params = {}, opts = {})
|
15
|
+
request_stripe_object(
|
16
|
+
method: :post,
|
17
|
+
path: resource_url + "/cancel",
|
18
|
+
params: params,
|
19
|
+
opts: opts
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def confirm(params = {}, opts = {})
|
24
|
+
request_stripe_object(
|
25
|
+
method: :post,
|
26
|
+
path: resource_url + "/confirm",
|
27
|
+
params: params,
|
28
|
+
opts: opts
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/stripe/resources/sku.rb
CHANGED
@@ -5,13 +5,17 @@ module Stripe
|
|
5
5
|
extend Stripe::APIOperations::Create
|
6
6
|
include Stripe::APIOperations::Save
|
7
7
|
|
8
|
-
OBJECT_NAME = "source"
|
8
|
+
OBJECT_NAME = "source"
|
9
9
|
|
10
10
|
custom_method :verify, http_verb: :post
|
11
11
|
|
12
12
|
def verify(params = {}, opts = {})
|
13
|
-
|
14
|
-
|
13
|
+
request_stripe_object(
|
14
|
+
method: :post,
|
15
|
+
path: resource_url + "/verify",
|
16
|
+
params: params,
|
17
|
+
opts: opts
|
18
|
+
)
|
15
19
|
end
|
16
20
|
|
17
21
|
def detach(params = {}, opts = {})
|
@@ -27,12 +31,6 @@ module Stripe
|
|
27
31
|
initialize_from(resp.data, opts)
|
28
32
|
end
|
29
33
|
|
30
|
-
def delete(params = {}, opts = {})
|
31
|
-
detach(params, opts)
|
32
|
-
end
|
33
|
-
extend Gem::Deprecate
|
34
|
-
deprecate :delete, "#detach", 2017, 10
|
35
|
-
|
36
34
|
def source_transactions(params = {}, opts = {})
|
37
35
|
resp, opts = request(:get, resource_url + "/source_transactions", params,
|
38
36
|
opts)
|