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
@@ -0,0 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "securerandom"
|
4
|
+
require "tempfile"
|
5
|
+
|
6
|
+
module Stripe
|
7
|
+
# Encodes parameters into a `multipart/form-data` payload as described by RFC
|
8
|
+
# 2388:
|
9
|
+
#
|
10
|
+
# https://tools.ietf.org/html/rfc2388
|
11
|
+
#
|
12
|
+
# This is most useful for transferring file-like objects.
|
13
|
+
#
|
14
|
+
# Parameters should be added with `#encode`. When ready, use `#body` to get
|
15
|
+
# the encoded result and `#content_type` to get the value that should be
|
16
|
+
# placed in the `Content-Type` header of a subsequent request (which includes
|
17
|
+
# a boundary value).
|
18
|
+
class MultipartEncoder
|
19
|
+
MULTIPART_FORM_DATA = "multipart/form-data"
|
20
|
+
|
21
|
+
# A shortcut for encoding a single set of parameters and finalizing a
|
22
|
+
# result.
|
23
|
+
#
|
24
|
+
# Returns an encoded body and the value that should be set in the content
|
25
|
+
# type header of a subsequent request.
|
26
|
+
def self.encode(params)
|
27
|
+
encoder = MultipartEncoder.new
|
28
|
+
encoder.encode(params)
|
29
|
+
encoder.close
|
30
|
+
[encoder.body, encoder.content_type]
|
31
|
+
end
|
32
|
+
|
33
|
+
# Gets the object's randomly generated boundary string.
|
34
|
+
attr_reader :boundary
|
35
|
+
|
36
|
+
# Initializes a new multipart encoder.
|
37
|
+
def initialize
|
38
|
+
# Kind of weird, but required by Rubocop because the unary plus operator
|
39
|
+
# is considered faster than `Stripe.new`.
|
40
|
+
@body = +""
|
41
|
+
|
42
|
+
# Chose the same number of random bytes that Go uses in its standard
|
43
|
+
# library implementation. Easily enough entropy to ensure that it won't
|
44
|
+
# be present in a file we're sending.
|
45
|
+
@boundary = SecureRandom.hex(30)
|
46
|
+
|
47
|
+
@closed = false
|
48
|
+
@first_field = true
|
49
|
+
end
|
50
|
+
|
51
|
+
# Gets the encoded body. `#close` must be called first.
|
52
|
+
def body
|
53
|
+
raise "object must be closed before getting body" unless @closed
|
54
|
+
|
55
|
+
@body
|
56
|
+
end
|
57
|
+
|
58
|
+
# Finalizes the object by writing the final boundary.
|
59
|
+
def close
|
60
|
+
raise "object already closed" if @closed
|
61
|
+
|
62
|
+
@body << "\r\n"
|
63
|
+
@body << "--#{@boundary}--"
|
64
|
+
|
65
|
+
@closed = true
|
66
|
+
|
67
|
+
nil
|
68
|
+
end
|
69
|
+
|
70
|
+
# Gets the value including boundary that should be put into a multipart
|
71
|
+
# request's `Content-Type`.
|
72
|
+
def content_type
|
73
|
+
"#{MULTIPART_FORM_DATA}; boundary=#{@boundary}"
|
74
|
+
end
|
75
|
+
|
76
|
+
# Encodes a set of parameters to the body.
|
77
|
+
#
|
78
|
+
# Note that parameters are expected to be a hash, but a "flat" hash such
|
79
|
+
# that complex substructures like hashes and arrays have already been
|
80
|
+
# appropriately Stripe-encoded. Pass a complex structure through
|
81
|
+
# `Util.flatten_params` first before handing it off to this method.
|
82
|
+
def encode(params)
|
83
|
+
raise "no more parameters can be written to closed object" if @closed
|
84
|
+
|
85
|
+
params.each do |name, val|
|
86
|
+
if val.is_a?(::File) || val.is_a?(::Tempfile)
|
87
|
+
write_field(name, val.read, filename: ::File.basename(val.path))
|
88
|
+
elsif val.respond_to?(:read)
|
89
|
+
write_field(name, val.read, filename: "blob")
|
90
|
+
else
|
91
|
+
write_field(name, val, filename: nil)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
nil
|
96
|
+
end
|
97
|
+
|
98
|
+
#
|
99
|
+
# private
|
100
|
+
#
|
101
|
+
|
102
|
+
# Escapes double quotes so that the given value can be used in a
|
103
|
+
# double-quoted string and replaces any linebreak characters with spaces.
|
104
|
+
private def escape(str)
|
105
|
+
str.gsub('"', "%22").tr("\n", " ").tr("\r", " ")
|
106
|
+
end
|
107
|
+
|
108
|
+
private def write_field(name, data, filename:)
|
109
|
+
if !@first_field
|
110
|
+
@body << "\r\n"
|
111
|
+
else
|
112
|
+
@first_field = false
|
113
|
+
end
|
114
|
+
|
115
|
+
@body << "--#{@boundary}\r\n"
|
116
|
+
|
117
|
+
if filename
|
118
|
+
@body << %(Content-Disposition: form-data) +
|
119
|
+
%(; name="#{escape(name.to_s)}") +
|
120
|
+
%(; filename="#{escape(filename)}"\r\n)
|
121
|
+
@body << %(Content-Type: application/octet-stream\r\n)
|
122
|
+
else
|
123
|
+
@body << %(Content-Disposition: form-data) +
|
124
|
+
%(; name="#{escape(name.to_s)}"\r\n)
|
125
|
+
end
|
126
|
+
|
127
|
+
@body << "\r\n"
|
128
|
+
@body << data.to_s
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
data/lib/stripe/object_types.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# rubocop:disable Metrics/LineLength
|
4
3
|
# rubocop:disable Metrics/MethodLength
|
5
4
|
|
6
5
|
module Stripe
|
@@ -42,7 +41,6 @@ module Stripe
|
|
42
41
|
Invoice::OBJECT_NAME => Invoice,
|
43
42
|
InvoiceItem::OBJECT_NAME => InvoiceItem,
|
44
43
|
InvoiceLineItem::OBJECT_NAME => InvoiceLineItem,
|
45
|
-
IssuerFraudRecord::OBJECT_NAME => IssuerFraudRecord,
|
46
44
|
Issuing::Authorization::OBJECT_NAME => Issuing::Authorization,
|
47
45
|
Issuing::Card::OBJECT_NAME => Issuing::Card,
|
48
46
|
Issuing::CardDetails::OBJECT_NAME => Issuing::CardDetails,
|
@@ -69,13 +67,13 @@ module Stripe
|
|
69
67
|
Reversal::OBJECT_NAME => Reversal,
|
70
68
|
Review::OBJECT_NAME => Review,
|
71
69
|
SKU::OBJECT_NAME => SKU,
|
70
|
+
SetupIntent::OBJECT_NAME => SetupIntent,
|
72
71
|
Sigma::ScheduledQueryRun::OBJECT_NAME => Sigma::ScheduledQueryRun,
|
73
72
|
Source::OBJECT_NAME => Source,
|
74
73
|
SourceTransaction::OBJECT_NAME => SourceTransaction,
|
75
74
|
Subscription::OBJECT_NAME => Subscription,
|
76
75
|
SubscriptionItem::OBJECT_NAME => SubscriptionItem,
|
77
76
|
SubscriptionSchedule::OBJECT_NAME => SubscriptionSchedule,
|
78
|
-
SubscriptionScheduleRevision::OBJECT_NAME => SubscriptionScheduleRevision,
|
79
77
|
TaxId::OBJECT_NAME => TaxId,
|
80
78
|
TaxRate::OBJECT_NAME => TaxRate,
|
81
79
|
Terminal::ConnectionToken::OBJECT_NAME => Terminal::ConnectionToken,
|
@@ -93,5 +91,4 @@ module Stripe
|
|
93
91
|
end
|
94
92
|
end
|
95
93
|
|
96
|
-
# rubocop:enable Metrics/LineLength
|
97
94
|
# rubocop:enable Metrics/MethodLength
|
@@ -9,7 +9,7 @@ module Stripe
|
|
9
9
|
include Stripe::APIOperations::Save
|
10
10
|
extend Stripe::APIOperations::NestedResource
|
11
11
|
|
12
|
-
OBJECT_NAME = "account"
|
12
|
+
OBJECT_NAME = "account"
|
13
13
|
|
14
14
|
custom_method :reject, http_verb: :post
|
15
15
|
|
@@ -20,8 +20,12 @@ module Stripe
|
|
20
20
|
operations: %i[create retrieve update delete list]
|
21
21
|
|
22
22
|
def reject(params = {}, opts = {})
|
23
|
-
|
24
|
-
|
23
|
+
request_stripe_object(
|
24
|
+
method: :post,
|
25
|
+
path: resource_url + "/reject",
|
26
|
+
params: params,
|
27
|
+
opts: opts
|
28
|
+
)
|
25
29
|
end
|
26
30
|
|
27
31
|
save_nested_resource :external_account
|
@@ -31,10 +35,6 @@ module Stripe
|
|
31
35
|
|
32
36
|
nested_resource_class_methods :login_link, operations: %i[create]
|
33
37
|
|
34
|
-
# This method is deprecated. Please use `#external_account=` instead.
|
35
|
-
save_nested_resource :bank_account
|
36
|
-
deprecate :bank_account=, "#external_account=", 2017, 8
|
37
|
-
|
38
38
|
def resource_url
|
39
39
|
if self["id"]
|
40
40
|
super
|
@@ -5,20 +5,9 @@ module Stripe
|
|
5
5
|
extend Stripe::APIOperations::List
|
6
6
|
extend Stripe::APIOperations::NestedResource
|
7
7
|
|
8
|
-
OBJECT_NAME = "application_fee"
|
8
|
+
OBJECT_NAME = "application_fee"
|
9
9
|
|
10
10
|
nested_resource_class_methods :refund,
|
11
11
|
operations: %i[create retrieve update list]
|
12
|
-
|
13
|
-
# If you don't need access to an updated fee object after the refund, it's
|
14
|
-
# more performant to just call `fee.refunds.create` directly.
|
15
|
-
def refund(params = {}, opts = {})
|
16
|
-
refunds.create(params, opts)
|
17
|
-
|
18
|
-
# now that a refund has been created, we expect the state of this object
|
19
|
-
# to change as well (i.e. `refunded` will now be `true`) so refresh it
|
20
|
-
# from the server
|
21
|
-
refresh
|
22
|
-
end
|
23
12
|
end
|
24
13
|
end
|
@@ -6,7 +6,7 @@ module Stripe
|
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
include Stripe::APIOperations::Save
|
8
8
|
|
9
|
-
OBJECT_NAME = "bank_account"
|
9
|
+
OBJECT_NAME = "bank_account"
|
10
10
|
|
11
11
|
def verify(params = {}, opts = {})
|
12
12
|
resp, opts = request(:post, resource_url + "/verify", params, opts)
|
@@ -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
|
@@ -6,13 +6,17 @@ module Stripe
|
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
include Stripe::APIOperations::Save
|
8
8
|
|
9
|
-
OBJECT_NAME = "credit_note"
|
9
|
+
OBJECT_NAME = "credit_note"
|
10
10
|
|
11
11
|
custom_method :void_credit_note, http_verb: :post, http_path: "void"
|
12
12
|
|
13
13
|
def void_credit_note(params = {}, opts = {})
|
14
|
-
|
15
|
-
|
14
|
+
request_stripe_object(
|
15
|
+
method: :post,
|
16
|
+
path: resource_url + "/void",
|
17
|
+
params: params,
|
18
|
+
opts: opts
|
19
|
+
)
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
@@ -8,8 +8,10 @@ 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
|
+
nested_resource_class_methods :balance_transaction,
|
14
|
+
operations: %i[create retrieve update list]
|
13
15
|
nested_resource_class_methods :tax_id,
|
14
16
|
operations: %i[create retrieve delete list]
|
15
17
|
|
@@ -19,78 +21,15 @@ module Stripe
|
|
19
21
|
nested_resource_class_methods :source,
|
20
22
|
operations: %i[create retrieve update delete list]
|
21
23
|
|
22
|
-
nested_resource_class_methods :balance_transaction,
|
23
|
-
operations: %i[create retrieve update list]
|
24
|
-
|
25
24
|
# The API request for deleting a card or bank account and for detaching a
|
26
25
|
# source object are the same.
|
27
26
|
class << self
|
28
27
|
alias detach_source delete_source
|
29
28
|
end
|
30
29
|
|
31
|
-
def add_invoice_item(params, opts = {})
|
32
|
-
opts = @opts.merge(Util.normalize_opts(opts))
|
33
|
-
InvoiceItem.create(params.merge(customer: id), opts)
|
34
|
-
end
|
35
|
-
|
36
|
-
def invoices(params = {}, opts = {})
|
37
|
-
opts = @opts.merge(Util.normalize_opts(opts))
|
38
|
-
Invoice.all(params.merge(customer: id), opts)
|
39
|
-
end
|
40
|
-
|
41
|
-
def invoice_items(params = {}, opts = {})
|
42
|
-
opts = @opts.merge(Util.normalize_opts(opts))
|
43
|
-
InvoiceItem.all(params.merge(customer: id), opts)
|
44
|
-
end
|
45
|
-
|
46
|
-
def upcoming_invoice(params = {}, opts = {})
|
47
|
-
opts = @opts.merge(Util.normalize_opts(opts))
|
48
|
-
Invoice.upcoming(params.merge(customer: id), opts)
|
49
|
-
end
|
50
|
-
|
51
|
-
def charges(params = {}, opts = {})
|
52
|
-
opts = @opts.merge(Util.normalize_opts(opts))
|
53
|
-
Charge.all(params.merge(customer: id), opts)
|
54
|
-
end
|
55
|
-
|
56
|
-
def create_upcoming_invoice(params = {}, opts = {})
|
57
|
-
opts = @opts.merge(Util.normalize_opts(opts))
|
58
|
-
Invoice.create(params.merge(customer: id), opts)
|
59
|
-
end
|
60
|
-
|
61
|
-
def cancel_subscription(params = {}, opts = {})
|
62
|
-
resp, opts = request(:delete, subscription_url, params, opts)
|
63
|
-
initialize_from({ subscription: resp.data }, opts, true)
|
64
|
-
subscription
|
65
|
-
end
|
66
|
-
|
67
|
-
def update_subscription(params = {}, opts = {})
|
68
|
-
resp, opts = request(:post, subscription_url, params, opts)
|
69
|
-
initialize_from({ subscription: resp.data }, opts, true)
|
70
|
-
subscription
|
71
|
-
end
|
72
|
-
|
73
|
-
def create_subscription(params = {}, opts = {})
|
74
|
-
resp, opts = request(:post, subscriptions_url, params, opts)
|
75
|
-
initialize_from({ subscription: resp.data }, opts, true)
|
76
|
-
subscription
|
77
|
-
end
|
78
|
-
|
79
30
|
def delete_discount
|
80
|
-
|
81
|
-
initialize_from(
|
82
|
-
end
|
83
|
-
|
84
|
-
private def discount_url
|
85
|
-
resource_url + "/discount"
|
86
|
-
end
|
87
|
-
|
88
|
-
private def subscription_url
|
89
|
-
resource_url + "/subscription"
|
90
|
-
end
|
91
|
-
|
92
|
-
private def subscriptions_url
|
93
|
-
resource_url + "/subscriptions"
|
31
|
+
resp, opts = request(:delete, resource_url + "/discount")
|
32
|
+
initialize_from(resp.data, opts, true)
|
94
33
|
end
|
95
34
|
end
|
96
35
|
end
|
@@ -5,19 +5,17 @@ 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
|
|
12
12
|
def close(params = {}, opts = {})
|
13
|
-
|
14
|
-
|
13
|
+
request_stripe_object(
|
14
|
+
method: :post,
|
15
|
+
path: resource_url + "/close",
|
16
|
+
params: params,
|
17
|
+
opts: opts
|
18
|
+
)
|
15
19
|
end
|
16
|
-
|
17
|
-
def close_url
|
18
|
-
resource_url + "/close"
|
19
|
-
end
|
20
|
-
extend Gem::Deprecate
|
21
|
-
deprecate :close_url, :none, 2019, 11
|
22
20
|
end
|
23
21
|
end
|