stripe 1.36.1 → 1.36.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/VERSION +1 -1
- data/lib/stripe/account.rb +25 -18
- 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 +1 -1
- data/lib/stripe/api_operations/update.rb +9 -13
- data/lib/stripe/api_resource.rb +4 -4
- data/lib/stripe/application_fee.rb +1 -1
- data/lib/stripe/application_fee_refund.rb +2 -2
- data/lib/stripe/balance_transaction.rb +1 -1
- data/lib/stripe/bank_account.rb +4 -4
- data/lib/stripe/bitcoin_receiver.rb +4 -4
- data/lib/stripe/bitcoin_transaction.rb +1 -1
- data/lib/stripe/card.rb +4 -4
- data/lib/stripe/charge.rb +6 -6
- data/lib/stripe/country_spec.rb +1 -1
- data/lib/stripe/customer.rb +3 -3
- data/lib/stripe/dispute.rb +1 -1
- data/lib/stripe/file_upload.rb +1 -1
- data/lib/stripe/invoice.rb +2 -2
- data/lib/stripe/list_object.rb +6 -1
- data/lib/stripe/order.rb +1 -1
- data/lib/stripe/product.rb +0 -9
- data/lib/stripe/reversal.rb +2 -2
- data/lib/stripe/singleton_api_resource.rb +3 -3
- data/lib/stripe/stripe_object.rb +128 -63
- data/lib/stripe/subscription.rb +3 -3
- data/lib/stripe/transfer.rb +1 -1
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/account_test.rb +8 -8
- data/test/stripe/api_resource_test.rb +1 -1
- data/test/stripe/country_spec_test.rb +7 -7
- data/test/stripe/customer_card_test.rb +2 -2
- data/test/stripe/list_object_test.rb +35 -12
- data/test/stripe/recipient_card_test.rb +2 -2
- data/test/stripe/stripe_object_test.rb +83 -11
- data/test/test_data.rb +23 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13034f2ff5896fc11dd19069e36bb5d28c29e065
|
4
|
+
data.tar.gz: 8a825283ac5be6e8d30415a111b149b67418892e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe4c1d03c1f87740d45bf360227c7bb54305fefda51edf9d491520cfa697c04efc08a061367a77b0114a68eac63328fa48c7a94e08e4d09d699fe567abdbf71c
|
7
|
+
data.tar.gz: 7209dab3a89095a82b94f454232fd9772d2b3523830b87fe52ecc774b2a5cf9cda23ebf0eddaaeaac0df1a0968ae70a3f31a2153d101d1b86e3436690fef9592
|
data/History.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.36.
|
1
|
+
1.36.2
|
data/lib/stripe/account.rb
CHANGED
@@ -5,7 +5,7 @@ module Stripe
|
|
5
5
|
extend Stripe::APIOperations::List
|
6
6
|
include Stripe::APIOperations::Update
|
7
7
|
|
8
|
-
def
|
8
|
+
def resource_url
|
9
9
|
if self['id']
|
10
10
|
super
|
11
11
|
else
|
@@ -25,7 +25,6 @@ module Stripe
|
|
25
25
|
opts = id
|
26
26
|
id = nil
|
27
27
|
end
|
28
|
-
|
29
28
|
super(id, opts)
|
30
29
|
end
|
31
30
|
|
@@ -52,15 +51,16 @@ module Stripe
|
|
52
51
|
#
|
53
52
|
# We're trying to get this overturned on the server side, but for now,
|
54
53
|
# patch in a special allowance.
|
55
|
-
def
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
54
|
+
def serialize_params(options = {})
|
55
|
+
serialize_params_account(self, super)
|
56
|
+
end
|
57
|
+
|
58
|
+
def serialize_params_account(obj, update_hash)
|
59
|
+
if entity = @values[:legal_entity]
|
60
|
+
if owners = entity[:additional_owners]
|
61
|
+
entity_update = update_hash[:legal_entity] ||= {}
|
62
|
+
entity_update[:additional_owners] =
|
63
|
+
serialize_additional_owners(entity, owners)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
update_hash
|
@@ -89,9 +89,9 @@ module Stripe
|
|
89
89
|
|
90
90
|
private
|
91
91
|
|
92
|
-
def
|
93
|
-
original_value =
|
94
|
-
if original_value && original_value.length >
|
92
|
+
def serialize_additional_owners(legal_entity, additional_owners)
|
93
|
+
original_value = legal_entity.instance_variable_get(:@original_values)[:additional_owners]
|
94
|
+
if original_value && original_value.length > additional_owners.length
|
95
95
|
# url params provide no mechanism for deleting an item in an array,
|
96
96
|
# just overwriting the whole array or adding new items. So let's not
|
97
97
|
# allow deleting without a full overwrite until we have a solution.
|
@@ -101,10 +101,17 @@ module Stripe
|
|
101
101
|
end
|
102
102
|
|
103
103
|
update_hash = {}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
additional_owners.each_with_index do |v, i|
|
105
|
+
# We will almost always see a StripeObject except in the case of a Hash
|
106
|
+
# that's been appended to an array of `additional_owners`. We may be
|
107
|
+
# able to normalize that ugliness by using an array proxy object with
|
108
|
+
# StripeObjects that can detect appends and replace a hash with a
|
109
|
+
# StripeObject.
|
110
|
+
update = v.is_a?(StripeObject) ? v.serialize_params : v
|
111
|
+
|
112
|
+
if update != {} && (!original_value ||
|
113
|
+
update != legal_entity.serialize_params_value(original_value[i], nil, false, true))
|
114
|
+
update_hash[i.to_s] = update
|
108
115
|
end
|
109
116
|
end
|
110
117
|
update_hash
|
@@ -5,7 +5,7 @@ module Stripe
|
|
5
5
|
opts = Util.normalize_opts(opts)
|
6
6
|
opts = @opts.merge(opts) if @opts
|
7
7
|
|
8
|
-
response, opts = request(:get,
|
8
|
+
response, opts = request(:get, resource_url, filters, opts)
|
9
9
|
obj = ListObject.construct_from(response, opts)
|
10
10
|
|
11
11
|
# set filters so that we can fetch the same limit, expansions, and
|
@@ -14,9 +14,6 @@ module Stripe
|
|
14
14
|
# in the list, it overrides the update URL used for the create or
|
15
15
|
# update.
|
16
16
|
def save(params={})
|
17
|
-
# Let the caller override the URL but avoid serializing it.
|
18
|
-
req_url = params.delete(:req_url) || save_url
|
19
|
-
|
20
17
|
# We started unintentionally (sort of) allowing attributes sent to
|
21
18
|
# +save+ to override values used during the update. So as not to break
|
22
19
|
# the API, this makes that official here.
|
@@ -25,16 +22,15 @@ module Stripe
|
|
25
22
|
# Now remove any parameters that look like object attributes.
|
26
23
|
params = params.reject { |k, _| respond_to?(k) }
|
27
24
|
|
28
|
-
values = self.
|
25
|
+
values = self.serialize_params(self).merge(params)
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
# note that id gets removed here our call to #url above has already
|
28
|
+
# generated a uri for this object with an identifier baked in
|
29
|
+
values.delete(:id)
|
30
|
+
|
31
|
+
response, opts = request(:post, save_url, values)
|
32
|
+
initialize_from(response, opts)
|
34
33
|
|
35
|
-
response, opts = request(:post, req_url, values)
|
36
|
-
initialize_from(response, opts)
|
37
|
-
end
|
38
34
|
self
|
39
35
|
end
|
40
36
|
|
@@ -48,9 +44,9 @@ module Stripe
|
|
48
44
|
# resource. Otherwise, generate a URL based on the object's identifier
|
49
45
|
# for a normal update.
|
50
46
|
if self[:id] == nil && self.class.respond_to?(:create)
|
51
|
-
self.class.
|
47
|
+
self.class.resource_url
|
52
48
|
else
|
53
|
-
|
49
|
+
resource_url
|
54
50
|
end
|
55
51
|
end
|
56
52
|
end
|
data/lib/stripe/api_resource.rb
CHANGED
@@ -6,22 +6,22 @@ module Stripe
|
|
6
6
|
self.name.split('::')[-1]
|
7
7
|
end
|
8
8
|
|
9
|
-
def self.
|
9
|
+
def self.resource_url
|
10
10
|
if self == APIResource
|
11
11
|
raise NotImplementedError.new('APIResource is an abstract class. You should perform actions on its subclasses (Charge, Customer, etc.)')
|
12
12
|
end
|
13
13
|
"/v1/#{CGI.escape(class_name.downcase)}s"
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def resource_url
|
17
17
|
unless id = self['id']
|
18
18
|
raise InvalidRequestError.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}", 'id')
|
19
19
|
end
|
20
|
-
"#{self.class.
|
20
|
+
"#{self.class.resource_url}/#{CGI.escape(id)}"
|
21
21
|
end
|
22
22
|
|
23
23
|
def refresh
|
24
|
-
response, opts = request(:get,
|
24
|
+
response, opts = request(:get, resource_url, @retrieve_params)
|
25
25
|
initialize_from(response, opts)
|
26
26
|
end
|
27
27
|
|
@@ -3,8 +3,8 @@ module Stripe
|
|
3
3
|
include Stripe::APIOperations::Update
|
4
4
|
extend Stripe::APIOperations::List
|
5
5
|
|
6
|
-
def
|
7
|
-
"#{ApplicationFee.
|
6
|
+
def resource_url
|
7
|
+
"#{ApplicationFee.resource_url}/#{CGI.escape(fee)}/refunds/#{CGI.escape(id)}"
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.retrieve(id, api_key=nil)
|
data/lib/stripe/bank_account.rb
CHANGED
@@ -5,15 +5,15 @@ module Stripe
|
|
5
5
|
extend Stripe::APIOperations::List
|
6
6
|
|
7
7
|
def verify(params={}, opts={})
|
8
|
-
response, opts = request(:post,
|
8
|
+
response, opts = request(:post, resource_url + '/verify', params, opts)
|
9
9
|
initialize_from(response, opts)
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def resource_url
|
13
13
|
if respond_to?(:customer)
|
14
|
-
"#{Customer.
|
14
|
+
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
|
15
15
|
elsif respond_to?(:account)
|
16
|
-
"#{Account.
|
16
|
+
"#{Account.resource_url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -5,15 +5,15 @@ module Stripe
|
|
5
5
|
include Stripe::APIOperations::Delete
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
|
8
|
-
def self.
|
8
|
+
def self.resource_url
|
9
9
|
"/v1/bitcoin/receivers"
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def resource_url
|
13
13
|
if respond_to?(:customer) && !self.customer.nil?
|
14
|
-
"#{Customer.
|
14
|
+
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
|
15
15
|
else
|
16
|
-
"#{self.class.
|
16
|
+
"#{self.class.resource_url}/#{CGI.escape(id)}"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/stripe/card.rb
CHANGED
@@ -4,13 +4,13 @@ module Stripe
|
|
4
4
|
include Stripe::APIOperations::Delete
|
5
5
|
extend Stripe::APIOperations::List
|
6
6
|
|
7
|
-
def
|
7
|
+
def resource_url
|
8
8
|
if respond_to?(:recipient)
|
9
|
-
"#{Recipient.
|
9
|
+
"#{Recipient.resource_url}/#{CGI.escape(recipient)}/cards/#{CGI.escape(id)}"
|
10
10
|
elsif respond_to?(:customer)
|
11
|
-
"#{Customer.
|
11
|
+
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
|
12
12
|
elsif respond_to?(:account)
|
13
|
-
"#{Account.
|
13
|
+
"#{Account.resource_url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
data/lib/stripe/charge.rb
CHANGED
@@ -45,7 +45,7 @@ module Stripe
|
|
45
45
|
params = {
|
46
46
|
:fraud_details => { :user_report => 'fraudulent' }
|
47
47
|
}
|
48
|
-
response, opts = request(:post,
|
48
|
+
response, opts = request(:post, resource_url, params)
|
49
49
|
initialize_from(response, opts)
|
50
50
|
end
|
51
51
|
|
@@ -53,28 +53,28 @@ module Stripe
|
|
53
53
|
params = {
|
54
54
|
:fraud_details => { :user_report => 'safe' }
|
55
55
|
}
|
56
|
-
response, opts = request(:post,
|
56
|
+
response, opts = request(:post, resource_url, params)
|
57
57
|
initialize_from(response, opts)
|
58
58
|
end
|
59
59
|
|
60
60
|
private
|
61
61
|
|
62
62
|
def capture_url
|
63
|
-
|
63
|
+
resource_url + '/capture'
|
64
64
|
end
|
65
65
|
|
66
66
|
def dispute_url
|
67
|
-
|
67
|
+
resource_url + '/dispute'
|
68
68
|
end
|
69
69
|
|
70
70
|
def close_dispute_url
|
71
|
-
|
71
|
+
resource_url + '/dispute/close'
|
72
72
|
end
|
73
73
|
|
74
74
|
# Note that this is actually the *old* refund URL and its use is no longer
|
75
75
|
# preferred.
|
76
76
|
def refund_url
|
77
|
-
|
77
|
+
resource_url + '/refund'
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
data/lib/stripe/country_spec.rb
CHANGED
data/lib/stripe/customer.rb
CHANGED
@@ -61,15 +61,15 @@ module Stripe
|
|
61
61
|
private
|
62
62
|
|
63
63
|
def discount_url
|
64
|
-
|
64
|
+
resource_url + '/discount'
|
65
65
|
end
|
66
66
|
|
67
67
|
def subscription_url
|
68
|
-
|
68
|
+
resource_url + '/subscription'
|
69
69
|
end
|
70
70
|
|
71
71
|
def subscriptions_url
|
72
|
-
|
72
|
+
resource_url + '/subscriptions'
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
data/lib/stripe/dispute.rb
CHANGED
data/lib/stripe/file_upload.rb
CHANGED
data/lib/stripe/invoice.rb
CHANGED
data/lib/stripe/list_object.rb
CHANGED
@@ -64,7 +64,7 @@ module Stripe
|
|
64
64
|
|
65
65
|
def retrieve(id, opts={})
|
66
66
|
id, retrieve_params = Util.normalize_id(id)
|
67
|
-
response, opts = request(:get,"#{
|
67
|
+
response, opts = request(:get,"#{resource_url}/#{CGI.escape(id)}", retrieve_params, opts)
|
68
68
|
Util.convert_to_stripe_object(response, opts)
|
69
69
|
end
|
70
70
|
|
@@ -96,5 +96,10 @@ module Stripe
|
|
96
96
|
|
97
97
|
list(params, opts)
|
98
98
|
end
|
99
|
+
|
100
|
+
def resource_url
|
101
|
+
self.url ||
|
102
|
+
raise(ArgumentError, "List object does not contain a 'url' field.")
|
103
|
+
end
|
99
104
|
end
|
100
105
|
end
|
data/lib/stripe/order.rb
CHANGED
data/lib/stripe/product.rb
CHANGED
@@ -4,14 +4,5 @@ module Stripe
|
|
4
4
|
extend Stripe::APIOperations::Create
|
5
5
|
include Stripe::APIOperations::Update
|
6
6
|
include Stripe::APIOperations::Delete
|
7
|
-
|
8
|
-
# Keep APIResource#url as `api_url` to avoid letting the external URL
|
9
|
-
# replace the Stripe URL.
|
10
|
-
alias_method :api_url, :url
|
11
|
-
|
12
|
-
# Override Stripe::APIOperations::Update#save to explicitly pass URL.
|
13
|
-
def save
|
14
|
-
super(:req_url => api_url)
|
15
|
-
end
|
16
7
|
end
|
17
8
|
end
|