stripe 3.3.2 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +20 -0
- data/.rubocop_todo.yml +62 -0
- data/.travis.yml +1 -1
- data/Gemfile +19 -12
- data/History.txt +10 -0
- data/README.md +5 -1
- data/Rakefile +8 -5
- data/VERSION +1 -1
- data/bin/stripe-console +2 -2
- data/lib/stripe.rb +72 -74
- data/lib/stripe/account.rb +15 -17
- data/lib/stripe/alipay_account.rb +10 -7
- data/lib/stripe/api_operations/create.rb +1 -1
- data/lib/stripe/api_operations/delete.rb +1 -1
- data/lib/stripe/api_operations/list.rb +2 -2
- data/lib/stripe/api_operations/request.rb +5 -12
- data/lib/stripe/api_operations/save.rb +6 -6
- data/lib/stripe/api_resource.rb +7 -9
- data/lib/stripe/apple_pay_domain.rb +2 -2
- data/lib/stripe/application_fee.rb +5 -5
- data/lib/stripe/application_fee_refund.rb +5 -5
- data/lib/stripe/balance.rb +1 -1
- data/lib/stripe/balance_transaction.rb +2 -2
- data/lib/stripe/bank_account.rb +7 -7
- data/lib/stripe/bitcoin_receiver.rb +4 -2
- data/lib/stripe/bitcoin_transaction.rb +3 -1
- data/lib/stripe/card.rb +5 -5
- data/lib/stripe/charge.rb +18 -18
- data/lib/stripe/country_spec.rb +2 -2
- data/lib/stripe/coupon.rb +1 -1
- data/lib/stripe/customer.rb +23 -23
- data/lib/stripe/dispute.rb +3 -3
- data/lib/stripe/ephemeral_key.rb +4 -4
- data/lib/stripe/errors.rb +4 -4
- data/lib/stripe/event.rb +1 -1
- data/lib/stripe/file_upload.rb +5 -5
- data/lib/stripe/invoice.rb +7 -7
- data/lib/stripe/invoice_item.rb +1 -1
- data/lib/stripe/invoice_line_item.rb +1 -1
- data/lib/stripe/list_object.rb +14 -18
- data/lib/stripe/login_link.rb +3 -3
- data/lib/stripe/oauth.rb +15 -13
- data/lib/stripe/order.rb +5 -5
- data/lib/stripe/order_return.rb +1 -1
- data/lib/stripe/payout.rb +3 -3
- data/lib/stripe/plan.rb +1 -1
- data/lib/stripe/product.rb +1 -1
- data/lib/stripe/recipient.rb +3 -2
- data/lib/stripe/recipient_transfer.rb +1 -2
- data/lib/stripe/refund.rb +1 -1
- data/lib/stripe/reversal.rb +5 -5
- data/lib/stripe/singleton_api_resource.rb +3 -3
- data/lib/stripe/sku.rb +1 -1
- data/lib/stripe/source.rb +13 -10
- data/lib/stripe/stripe_client.rb +149 -169
- data/lib/stripe/stripe_object.rb +77 -76
- data/lib/stripe/subscription.rb +5 -5
- data/lib/stripe/subscription_item.rb +2 -2
- data/lib/stripe/three_d_secure.rb +1 -1
- data/lib/stripe/token.rb +1 -1
- data/lib/stripe/transfer.rb +3 -3
- data/lib/stripe/util.rb +77 -62
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +14 -10
- data/stripe.gemspec +14 -14
- data/test/stripe/account_test.rb +69 -81
- data/test/stripe/alipay_account_test.rb +19 -1
- data/test/stripe/api_operations_test.rb +7 -7
- data/test/stripe/api_resource_test.rb +224 -260
- data/test/stripe/apple_pay_domain_test.rb +8 -8
- data/test/stripe/application_fee_refund_test.rb +8 -8
- data/test/stripe/application_fee_test.rb +3 -3
- data/test/stripe/balance_test.rb +2 -2
- data/test/stripe/bank_account_test.rb +9 -11
- data/test/stripe/charge_test.rb +11 -11
- data/test/stripe/country_spec_test.rb +4 -4
- data/test/stripe/coupon_test.rb +10 -10
- data/test/stripe/customer_card_test.rb +11 -15
- data/test/stripe/customer_test.rb +26 -27
- data/test/stripe/dispute_test.rb +8 -8
- data/test/stripe/ephemeral_key_test.rb +14 -14
- data/test/stripe/errors_test.rb +2 -2
- data/test/stripe/file_upload_test.rb +26 -28
- data/test/stripe/invoice_item_test.rb +14 -14
- data/test/stripe/invoice_line_item_test.rb +1 -1
- data/test/stripe/invoice_test.rb +37 -37
- data/test/stripe/list_object_test.rb +60 -76
- data/test/stripe/login_link_test.rb +14 -14
- data/test/stripe/oauth_test.rb +42 -50
- data/test/stripe/order_return_test.rb +5 -5
- data/test/stripe/order_test.rb +12 -12
- data/test/stripe/payout_test.rb +9 -9
- data/test/stripe/plan_test.rb +9 -9
- data/test/stripe/product_test.rb +8 -8
- data/test/stripe/recipient_test.rb +9 -10
- data/test/stripe/refund_test.rb +9 -9
- data/test/stripe/reversal_test.rb +10 -10
- data/test/stripe/sku_test.rb +8 -8
- data/test/stripe/source_test.rb +14 -16
- data/test/stripe/stripe_client_test.rb +235 -266
- data/test/stripe/stripe_object_test.rb +163 -147
- data/test/stripe/stripe_response_test.rb +4 -3
- data/test/stripe/subscription_item_test.rb +11 -11
- data/test/stripe/subscription_test.rb +14 -14
- data/test/stripe/three_d_secure_test.rb +2 -2
- data/test/stripe/transfer_test.rb +8 -8
- data/test/stripe/util_test.rb +59 -57
- data/test/stripe/webhook_test.rb +18 -16
- data/test/stripe_test.rb +4 -4
- data/test/test_data.rb +26 -26
- data/test/test_helper.rb +29 -25
- metadata +6 -10
- data/test/stripe/bitcoin_receiver_test.rb +0 -67
- data/test/stripe/bitcoin_transaction_test.rb +0 -19
- data/test/stripe/recipient_card_test.rb +0 -44
@@ -3,20 +3,23 @@ module Stripe
|
|
3
3
|
include Stripe::APIOperations::Save
|
4
4
|
include Stripe::APIOperations::Delete
|
5
5
|
|
6
|
-
OBJECT_NAME =
|
6
|
+
OBJECT_NAME = "alipay_account".freeze
|
7
7
|
|
8
8
|
def resource_url
|
9
|
-
if respond_to?(:customer)
|
10
|
-
|
9
|
+
if !respond_to?(:customer) || customer.nil?
|
10
|
+
raise NotImplementedError,
|
11
|
+
"Alipay accounts cannot be accessed without a customer ID."
|
11
12
|
end
|
13
|
+
|
14
|
+
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
|
12
15
|
end
|
13
16
|
|
14
|
-
def self.update(
|
15
|
-
raise NotImplementedError
|
17
|
+
def self.update(_id, _params = nil, _opts = nil)
|
18
|
+
raise NotImplementedError, "Alipay accounts cannot be updated without a customer ID. Update an Alipay account by `a = customer.sources.retrieve('alipay_account_id'); a.save`"
|
16
19
|
end
|
17
20
|
|
18
|
-
def self.retrieve(
|
19
|
-
raise NotImplementedError
|
21
|
+
def self.retrieve(_id, _opts = nil)
|
22
|
+
raise NotImplementedError, "Alipay accounts cannot be retrieved without a customer ID. Retrieve an Alipay account using customer.sources.retrieve('alipay_account_id')"
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Stripe
|
2
2
|
module APIOperations
|
3
3
|
module List
|
4
|
-
def list(filters={}, opts={})
|
4
|
+
def list(filters = {}, opts = {})
|
5
5
|
opts = Util.normalize_opts(opts)
|
6
6
|
|
7
7
|
resp, opts = request(:get, resource_url, filters, opts)
|
@@ -22,7 +22,7 @@ module Stripe
|
|
22
22
|
# #all, and this alias allows us to maintain backward compatibility (the
|
23
23
|
# choice was somewhat misleading in the way that it only returned a single
|
24
24
|
# page rather than all objects).
|
25
|
-
alias
|
25
|
+
alias all list
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -2,9 +2,7 @@ module Stripe
|
|
2
2
|
module APIOperations
|
3
3
|
module Request
|
4
4
|
module ClassMethods
|
5
|
-
|
6
|
-
|
7
|
-
def request(method, url, params={}, opts={})
|
5
|
+
def request(method, url, params = {}, opts = {})
|
8
6
|
warn_on_opts_in_params(params)
|
9
7
|
|
10
8
|
opts = Util.normalize_opts(opts)
|
@@ -25,9 +23,7 @@ module Stripe
|
|
25
23
|
# Hash#select returns an array before 1.9
|
26
24
|
opts_to_persist = {}
|
27
25
|
opts.each do |k, v|
|
28
|
-
if OPTS_KEYS_TO_PERSIST.include?(k)
|
29
|
-
opts_to_persist[k] = v
|
30
|
-
end
|
26
|
+
opts_to_persist[k] = v if Util::OPTS_KEYS_TO_PERSIST.include?(k)
|
31
27
|
end
|
32
28
|
|
33
29
|
[resp, opts_to_persist]
|
@@ -35,12 +31,9 @@ module Stripe
|
|
35
31
|
|
36
32
|
private
|
37
33
|
|
38
|
-
KNOWN_OPTS = Set[:api_key, :idempotency_key, :stripe_account, :stripe_version]
|
39
|
-
private_constant :KNOWN_OPTS
|
40
|
-
|
41
34
|
def warn_on_opts_in_params(params)
|
42
|
-
|
43
|
-
if params.
|
35
|
+
Util::OPTS_USER_SPECIFIED.each do |opt|
|
36
|
+
if params.key?(opt)
|
44
37
|
$stderr.puts("WARNING: #{opt} should be in opts instead of params.")
|
45
38
|
end
|
46
39
|
end
|
@@ -53,7 +46,7 @@ module Stripe
|
|
53
46
|
|
54
47
|
protected
|
55
48
|
|
56
|
-
def request(method, url, params={}, opts={})
|
49
|
+
def request(method, url, params = {}, opts = {})
|
57
50
|
opts = @opts.merge(Util.normalize_opts(opts))
|
58
51
|
self.class.request(method, url, params, opts)
|
59
52
|
end
|
@@ -14,9 +14,9 @@ module Stripe
|
|
14
14
|
# object values) to be added to the request. E.g. to allow for an
|
15
15
|
# idempotency_key to be passed in the request headers, or for the
|
16
16
|
# api_key to be overwritten. See {APIOperations::Request.request}.
|
17
|
-
def update(id, params={}, opts={})
|
18
|
-
params.
|
19
|
-
if
|
17
|
+
def update(id, params = {}, opts = {})
|
18
|
+
params.each_key do |k|
|
19
|
+
if protected_fields.include?(k)
|
20
20
|
raise ArgumentError, "Cannot update protected field: #{k}"
|
21
21
|
end
|
22
22
|
end
|
@@ -42,7 +42,7 @@ module Stripe
|
|
42
42
|
# object values) to be added to the request. E.g. to allow for an
|
43
43
|
# idempotency_key to be passed in the request headers, or for the
|
44
44
|
# api_key to be overwritten. See {APIOperations::Request.request}.
|
45
|
-
def save(params={}, opts={})
|
45
|
+
def save(params = {}, opts = {})
|
46
46
|
# We started unintentionally (sort of) allowing attributes sent to
|
47
47
|
# +save+ to override values used during the update. So as not to break
|
48
48
|
# the API, this makes that official here.
|
@@ -51,7 +51,7 @@ module Stripe
|
|
51
51
|
# Now remove any parameters that look like object attributes.
|
52
52
|
params = params.reject { |k, _| respond_to?(k) }
|
53
53
|
|
54
|
-
values =
|
54
|
+
values = serialize_params(self).merge(params)
|
55
55
|
|
56
56
|
# note that id gets removed here our call to #url above has already
|
57
57
|
# generated a uri for this object with an identifier baked in
|
@@ -74,7 +74,7 @@ module Stripe
|
|
74
74
|
# Stripe::APIOperations::Create), then use the URL to create a new
|
75
75
|
# resource. Otherwise, generate a URL based on the object's identifier
|
76
76
|
# for a normal update.
|
77
|
-
if self[:id]
|
77
|
+
if self[:id].nil? && self.class.respond_to?(:create)
|
78
78
|
self.class.resource_url
|
79
79
|
else
|
80
80
|
resource_url
|
data/lib/stripe/api_resource.rb
CHANGED
@@ -10,12 +10,12 @@ module Stripe
|
|
10
10
|
attr_accessor :save_with_parent
|
11
11
|
|
12
12
|
def self.class_name
|
13
|
-
|
13
|
+
name.split("::")[-1]
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.resource_url
|
17
17
|
if self == APIResource
|
18
|
-
raise NotImplementedError
|
18
|
+
raise NotImplementedError, "APIResource is an abstract class. You should perform actions on its subclasses (Charge, Customer, etc.)"
|
19
19
|
end
|
20
20
|
"/v1/#{CGI.escape(class_name.downcase)}s"
|
21
21
|
end
|
@@ -38,17 +38,15 @@ module Stripe
|
|
38
38
|
# Note that the value may be subresource, but could also be a scalar
|
39
39
|
# (like a tokenized card's ID for example), so we check the type before
|
40
40
|
# setting #save_with_parent here.
|
41
|
-
if value.is_a?(APIResource)
|
42
|
-
value.save_with_parent = true
|
43
|
-
end
|
41
|
+
value.save_with_parent = true if value.is_a?(APIResource)
|
44
42
|
|
45
43
|
value
|
46
44
|
end
|
47
45
|
end
|
48
46
|
|
49
47
|
def resource_url
|
50
|
-
unless id = self[
|
51
|
-
raise InvalidRequestError.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}",
|
48
|
+
unless (id = self["id"])
|
49
|
+
raise InvalidRequestError.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}", "id")
|
52
50
|
end
|
53
51
|
"#{self.class.resource_url}/#{CGI.escape(id)}"
|
54
52
|
end
|
@@ -58,9 +56,9 @@ module Stripe
|
|
58
56
|
initialize_from(resp.data, opts)
|
59
57
|
end
|
60
58
|
|
61
|
-
def self.retrieve(id, opts={})
|
59
|
+
def self.retrieve(id, opts = {})
|
62
60
|
opts = Util.normalize_opts(opts)
|
63
|
-
instance =
|
61
|
+
instance = new(id, opts)
|
64
62
|
instance.refresh
|
65
63
|
instance
|
66
64
|
end
|
@@ -5,10 +5,10 @@ module Stripe
|
|
5
5
|
include Stripe::APIOperations::Delete
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
|
8
|
-
OBJECT_NAME =
|
8
|
+
OBJECT_NAME = "apple_pay_domain".freeze
|
9
9
|
|
10
10
|
def self.resource_url
|
11
|
-
|
11
|
+
"/v1/apple_pay/domains"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -2,21 +2,21 @@ module Stripe
|
|
2
2
|
class ApplicationFee < APIResource
|
3
3
|
extend Stripe::APIOperations::List
|
4
4
|
|
5
|
-
OBJECT_NAME =
|
5
|
+
OBJECT_NAME = "application_fee".freeze
|
6
6
|
|
7
7
|
def self.resource_url
|
8
|
-
|
8
|
+
"/v1/application_fees"
|
9
9
|
end
|
10
10
|
|
11
11
|
# If you don't need access to an updated fee object after the refund, it's
|
12
12
|
# more performant to just call `fee.refunds.create` directly.
|
13
|
-
def refund(params={}, opts={})
|
14
|
-
|
13
|
+
def refund(params = {}, opts = {})
|
14
|
+
refunds.create(params, opts)
|
15
15
|
|
16
16
|
# now that a refund has been created, we expect the state of this object
|
17
17
|
# to change as well (i.e. `refunded` will now be `true`) so refresh it
|
18
18
|
# from the server
|
19
|
-
|
19
|
+
refresh
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -3,18 +3,18 @@ module Stripe
|
|
3
3
|
include Stripe::APIOperations::Save
|
4
4
|
extend Stripe::APIOperations::List
|
5
5
|
|
6
|
-
OBJECT_NAME =
|
6
|
+
OBJECT_NAME = "fee_refund".freeze
|
7
7
|
|
8
8
|
def resource_url
|
9
9
|
"#{ApplicationFee.resource_url}/#{CGI.escape(fee)}/refunds/#{CGI.escape(id)}"
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.update(
|
13
|
-
raise NotImplementedError
|
12
|
+
def self.update(_id, _params = nil, _opts = nil)
|
13
|
+
raise NotImplementedError, "Refunds cannot be updated without an application fee ID. Update a refund by using `a = appfee.refunds.retrieve('refund_id'); a.save`"
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.retrieve(
|
17
|
-
raise NotImplementedError
|
16
|
+
def self.retrieve(_id, _api_key = nil)
|
17
|
+
raise NotImplementedError, "Refunds cannot be retrieved without an application fee ID. Retrieve a refund using appfee.refunds.retrieve('refund_id')"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/lib/stripe/balance.rb
CHANGED
@@ -2,10 +2,10 @@ module Stripe
|
|
2
2
|
class BalanceTransaction < APIResource
|
3
3
|
extend Stripe::APIOperations::List
|
4
4
|
|
5
|
-
OBJECT_NAME =
|
5
|
+
OBJECT_NAME = "balance_transaction".freeze
|
6
6
|
|
7
7
|
def self.resource_url
|
8
|
-
|
8
|
+
"/v1/balance/history"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
data/lib/stripe/bank_account.rb
CHANGED
@@ -4,10 +4,10 @@ module Stripe
|
|
4
4
|
include Stripe::APIOperations::Delete
|
5
5
|
extend Stripe::APIOperations::List
|
6
6
|
|
7
|
-
OBJECT_NAME =
|
7
|
+
OBJECT_NAME = "bank_account".freeze
|
8
8
|
|
9
|
-
def verify(params={}, opts={})
|
10
|
-
resp, opts = request(:post, resource_url +
|
9
|
+
def verify(params = {}, opts = {})
|
10
|
+
resp, opts = request(:post, resource_url + "/verify", params, opts)
|
11
11
|
initialize_from(resp.data, opts)
|
12
12
|
end
|
13
13
|
|
@@ -19,12 +19,12 @@ module Stripe
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def self.update(
|
23
|
-
raise NotImplementedError
|
22
|
+
def self.update(_id, _params = nil, _opts = nil)
|
23
|
+
raise NotImplementedError, "Bank accounts cannot be updated without an account ID. Update a bank account by using `a = account.external_accounts.retrieve('card_id'); a.save`"
|
24
24
|
end
|
25
25
|
|
26
|
-
def self.retrieve(
|
27
|
-
raise NotImplementedError
|
26
|
+
def self.retrieve(_id, _opts = nil)
|
27
|
+
raise NotImplementedError, "Bank accounts cannot be retrieved without an account ID. Retrieve a bank account using account.external_accounts.retrieve('card_id')"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -1,18 +1,20 @@
|
|
1
1
|
module Stripe
|
2
2
|
class BitcoinReceiver < APIResource
|
3
|
+
# Directly creating or retrieving BitcoinReceivers is deprecated. Please use
|
4
|
+
# the Sources API instead: https://stripe.com/docs/sources/bitcoin
|
3
5
|
extend Stripe::APIOperations::Create
|
4
6
|
include Stripe::APIOperations::Save
|
5
7
|
include Stripe::APIOperations::Delete
|
6
8
|
extend Stripe::APIOperations::List
|
7
9
|
|
8
|
-
OBJECT_NAME =
|
10
|
+
OBJECT_NAME = "bitcoin_receiver".freeze
|
9
11
|
|
10
12
|
def self.resource_url
|
11
13
|
"/v1/bitcoin/receivers"
|
12
14
|
end
|
13
15
|
|
14
16
|
def resource_url
|
15
|
-
if respond_to?(:customer) && !
|
17
|
+
if respond_to?(:customer) && !customer.nil? && customer != ""
|
16
18
|
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
|
17
19
|
else
|
18
20
|
"#{self.class.resource_url}/#{CGI.escape(id)}"
|
@@ -1,8 +1,10 @@
|
|
1
1
|
module Stripe
|
2
2
|
class BitcoinTransaction < APIResource
|
3
|
+
# Directly retrieving BitcoinTransactions is deprecated. Please use the
|
4
|
+
# Sources API instead: https://stripe.com/docs/sources/bitcoin
|
3
5
|
extend Stripe::APIOperations::List
|
4
6
|
|
5
|
-
OBJECT_NAME =
|
7
|
+
OBJECT_NAME = "bitcoin_transaction".freeze
|
6
8
|
|
7
9
|
def self.resource_url
|
8
10
|
"/v1/bitcoin/transactions"
|
data/lib/stripe/card.rb
CHANGED
@@ -4,7 +4,7 @@ module Stripe
|
|
4
4
|
include Stripe::APIOperations::Delete
|
5
5
|
extend Stripe::APIOperations::List
|
6
6
|
|
7
|
-
OBJECT_NAME =
|
7
|
+
OBJECT_NAME = "card".freeze
|
8
8
|
|
9
9
|
def resource_url
|
10
10
|
if respond_to?(:recipient) && !recipient.nil? && !recipient.empty?
|
@@ -16,12 +16,12 @@ module Stripe
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.update(
|
20
|
-
raise NotImplementedError
|
19
|
+
def self.update(_id, _params = nil, _opts = nil)
|
20
|
+
raise NotImplementedError, "Cards cannot be updated without a customer ID. Update a card using `c = customer.sources.retrieve('card_id'); c.save`"
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.retrieve(
|
24
|
-
raise NotImplementedError
|
23
|
+
def self.retrieve(_id, _opts = nil)
|
24
|
+
raise NotImplementedError, "Cards cannot be retrieved without a customer ID. Retrieve a card using customer.sources.retrieve('card_id')"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/lib/stripe/charge.rb
CHANGED
@@ -4,9 +4,9 @@ module Stripe
|
|
4
4
|
extend Stripe::APIOperations::Create
|
5
5
|
include Stripe::APIOperations::Save
|
6
6
|
|
7
|
-
OBJECT_NAME =
|
7
|
+
OBJECT_NAME = "charge".freeze
|
8
8
|
|
9
|
-
def refund(params={}, opts={})
|
9
|
+
def refund(params = {}, opts = {})
|
10
10
|
# Old versions of charge objects included a `refunds` field that was just
|
11
11
|
# a vanilla array instead of a Stripe list object.
|
12
12
|
#
|
@@ -14,38 +14,38 @@ module Stripe
|
|
14
14
|
# `self.refunds.create`), but detect the old API version by looking for
|
15
15
|
# an `Array` and fall back to the old refund URL if necessary so as to
|
16
16
|
# maintain internal compatibility.
|
17
|
-
|
18
|
-
|
17
|
+
if refunds.is_a?(Array)
|
18
|
+
resp, opts = request(:post, refund_url, params, opts)
|
19
|
+
initialize_from(resp.data, opts)
|
20
|
+
else
|
21
|
+
refunds.create(params, opts)
|
19
22
|
|
20
23
|
# now that a refund has been created, we expect the state of this object
|
21
24
|
# to change as well (i.e. `refunded` will now be `true`) so refresh it
|
22
25
|
# from the server
|
23
|
-
|
24
|
-
else
|
25
|
-
resp, opts = request(:post, refund_url, params, opts)
|
26
|
-
initialize_from(resp.data, opts)
|
26
|
+
refresh
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def capture(params={}, opts={})
|
30
|
+
def capture(params = {}, opts = {})
|
31
31
|
resp, opts = request(:post, capture_url, params, opts)
|
32
32
|
initialize_from(resp.data, opts)
|
33
33
|
end
|
34
34
|
|
35
|
-
def update_dispute(params={}, opts={})
|
35
|
+
def update_dispute(params = {}, opts = {})
|
36
36
|
resp, opts = request(:post, dispute_url, params, opts)
|
37
|
-
initialize_from({ :
|
37
|
+
initialize_from({ dispute: resp.data }, opts, true)
|
38
38
|
dispute
|
39
39
|
end
|
40
40
|
|
41
|
-
def close_dispute(params={}, opts={})
|
41
|
+
def close_dispute(params = {}, opts = {})
|
42
42
|
resp, opts = request(:post, close_dispute_url, params, opts)
|
43
43
|
initialize_from(resp.data, opts)
|
44
44
|
end
|
45
45
|
|
46
46
|
def mark_as_fraudulent
|
47
47
|
params = {
|
48
|
-
:
|
48
|
+
fraud_details: { user_report: "fraudulent" },
|
49
49
|
}
|
50
50
|
resp, opts = request(:post, resource_url, params)
|
51
51
|
initialize_from(resp.data, opts)
|
@@ -53,7 +53,7 @@ module Stripe
|
|
53
53
|
|
54
54
|
def mark_as_safe
|
55
55
|
params = {
|
56
|
-
:
|
56
|
+
fraud_details: { user_report: "safe" },
|
57
57
|
}
|
58
58
|
resp, opts = request(:post, resource_url, params)
|
59
59
|
initialize_from(resp.data, opts)
|
@@ -62,21 +62,21 @@ module Stripe
|
|
62
62
|
private
|
63
63
|
|
64
64
|
def capture_url
|
65
|
-
resource_url +
|
65
|
+
resource_url + "/capture"
|
66
66
|
end
|
67
67
|
|
68
68
|
def dispute_url
|
69
|
-
resource_url +
|
69
|
+
resource_url + "/dispute"
|
70
70
|
end
|
71
71
|
|
72
72
|
def close_dispute_url
|
73
|
-
resource_url +
|
73
|
+
resource_url + "/dispute/close"
|
74
74
|
end
|
75
75
|
|
76
76
|
# Note that this is actually the *old* refund URL and its use is no longer
|
77
77
|
# preferred.
|
78
78
|
def refund_url
|
79
|
-
resource_url +
|
79
|
+
resource_url + "/refund"
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|