stripe 1.51.1 → 1.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/VERSION +1 -1
- data/lib/stripe/account.rb +7 -33
- data/lib/stripe/api_resource.rb +26 -0
- data/lib/stripe/customer.rb +1 -16
- data/lib/stripe/subscription.rb +2 -0
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/account_test.rb +0 -42
- data/test/stripe/api_resource_test.rb +20 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51a173fc4e60e562a7a4b0e56ac97b8fdb6d9cec
|
4
|
+
data.tar.gz: 0ca3a5dd2f33d2dca97ab0fb868f89defe9ac119
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c7e39888631f88be74385814a7bedc046744636ac352ad727c726d54c90efaa8ba95b5480f56212d144396524bb563f744a26ee196a029d3e03dc7af9bd71b7
|
7
|
+
data.tar.gz: 7c572f28527faebf622fca923814ff926b320ff764539f18905dd75faf4b9a2dd04fcaa33ada0a8b639a57438652a760379a7ceb8da1847f4c2c8483e38bca22
|
data/History.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.52.0
|
data/lib/stripe/account.rb
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
module Stripe
|
2
2
|
class Account < APIResource
|
3
|
+
extend Gem::Deprecate
|
3
4
|
extend Stripe::APIOperations::Create
|
4
5
|
extend Stripe::APIOperations::List
|
5
6
|
include Stripe::APIOperations::Delete
|
6
7
|
include Stripe::APIOperations::Save
|
7
8
|
|
9
|
+
save_nested_resource :external_account
|
10
|
+
|
11
|
+
# This method is deprecated. Please use `#external_account=` instead.
|
12
|
+
save_nested_resource :bank_account
|
13
|
+
deprecate :bank_account=, "#external_account=", 2017, 8
|
14
|
+
|
8
15
|
def resource_url
|
9
16
|
if self['id']
|
10
17
|
super
|
@@ -28,23 +35,6 @@ module Stripe
|
|
28
35
|
super(id, opts)
|
29
36
|
end
|
30
37
|
|
31
|
-
# Set or replace an account's external account.
|
32
|
-
def external_account=(value)
|
33
|
-
super
|
34
|
-
|
35
|
-
# The parent setter will perform certain useful operations like
|
36
|
-
# converting to an APIResource if appropriate.
|
37
|
-
value = self.external_account
|
38
|
-
|
39
|
-
# Note that external_account may be a card, but could also be a tokenized
|
40
|
-
# card's ID (which is a string), and so we check its type here.
|
41
|
-
if value.is_a?(APIResource)
|
42
|
-
value.save_with_parent = true
|
43
|
-
end
|
44
|
-
|
45
|
-
value
|
46
|
-
end
|
47
|
-
|
48
38
|
def reject(params={}, opts={})
|
49
39
|
opts = Util.normalize_opts(opts)
|
50
40
|
response, opts = request(:post, resource_url + '/reject', params, opts)
|
@@ -110,22 +100,6 @@ module Stripe
|
|
110
100
|
|
111
101
|
ARGUMENT_NOT_PROVIDED = Object.new
|
112
102
|
|
113
|
-
# Set or replace an account's bank account.
|
114
|
-
#
|
115
|
-
# This method is deprecated. Please use #external_account instead.
|
116
|
-
def bank_account=(value)
|
117
|
-
super
|
118
|
-
value = self.bank_account
|
119
|
-
|
120
|
-
if value.is_a?(APIResource)
|
121
|
-
value.save_with_parent = true
|
122
|
-
end
|
123
|
-
|
124
|
-
value
|
125
|
-
end
|
126
|
-
extend Gem::Deprecate
|
127
|
-
deprecate :bank_account=, "#external_account=", 2017, 8
|
128
|
-
|
129
103
|
private
|
130
104
|
|
131
105
|
def serialize_additional_owners(legal_entity, additional_owners)
|
data/lib/stripe/api_resource.rb
CHANGED
@@ -20,6 +20,32 @@ module Stripe
|
|
20
20
|
"/v1/#{CGI.escape(class_name.downcase)}s"
|
21
21
|
end
|
22
22
|
|
23
|
+
# A metaprogramming call that specifies that a field of a resource can be
|
24
|
+
# its own type of API resource (say a nested card under an account for
|
25
|
+
# example), and if that resource is set, it should be transmitted to the
|
26
|
+
# API on a create or update. Doing so is not the default behavior because
|
27
|
+
# API resources should normally be persisted on their own RESTful
|
28
|
+
# endpoints.
|
29
|
+
def self.save_nested_resource(name)
|
30
|
+
define_method(:"#{name}=") do |value|
|
31
|
+
super(value)
|
32
|
+
|
33
|
+
# The parent setter will perform certain useful operations like
|
34
|
+
# converting to an APIResource if appropriate. Refresh our argument
|
35
|
+
# value to whatever it mutated to.
|
36
|
+
value = send(name)
|
37
|
+
|
38
|
+
# Note that the value may be subresource, but could also be a scalar
|
39
|
+
# (like a tokenized card's ID for example), so we check the type before
|
40
|
+
# setting #save_with_parent here.
|
41
|
+
if value.is_a?(APIResource)
|
42
|
+
value.save_with_parent = true
|
43
|
+
end
|
44
|
+
|
45
|
+
value
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
23
49
|
def resource_url
|
24
50
|
unless id = self['id']
|
25
51
|
raise InvalidRequestError.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}", 'id')
|
data/lib/stripe/customer.rb
CHANGED
@@ -5,22 +5,7 @@ module Stripe
|
|
5
5
|
include Stripe::APIOperations::Save
|
6
6
|
extend Stripe::APIOperations::List
|
7
7
|
|
8
|
-
|
9
|
-
def source=(value)
|
10
|
-
super
|
11
|
-
|
12
|
-
# The parent setter will perform certain useful operations like
|
13
|
-
# converting to an APIResource if appropriate.
|
14
|
-
value = self.source
|
15
|
-
|
16
|
-
# Note that source may be a card, but could also be a tokenized card's ID
|
17
|
-
# (which is a string), and so we check its type here.
|
18
|
-
if value.is_a?(APIResource)
|
19
|
-
value.save_with_parent = true
|
20
|
-
end
|
21
|
-
|
22
|
-
value
|
23
|
-
end
|
8
|
+
save_nested_resource :source
|
24
9
|
|
25
10
|
def add_invoice_item(params, opts={})
|
26
11
|
opts = @opts.merge(Util.normalize_opts(opts))
|
data/lib/stripe/subscription.rb
CHANGED
data/lib/stripe/version.rb
CHANGED
data/test/stripe/account_test.rb
CHANGED
@@ -290,49 +290,7 @@ module Stripe
|
|
290
290
|
assert_equal(expected, obj.serialize_params)
|
291
291
|
end
|
292
292
|
|
293
|
-
context "#external_account=" do
|
294
|
-
should "can have a token source set" do
|
295
|
-
a = Stripe::Account.new("test_account")
|
296
|
-
a.external_account = "tok_123"
|
297
|
-
assert_equal "tok_123", a.external_account
|
298
|
-
end
|
299
|
-
|
300
|
-
should "set a flag if given an object source" do
|
301
|
-
a = Stripe::Account.new("test_account")
|
302
|
-
a.external_account = {
|
303
|
-
:object => 'card'
|
304
|
-
}
|
305
|
-
assert_equal true, a.external_account.save_with_parent
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
293
|
context "#bank_account=" do
|
310
|
-
should "can have a token source set" do
|
311
|
-
old_stderr = $stderr
|
312
|
-
$stderr = StringIO.new
|
313
|
-
begin
|
314
|
-
a = Stripe::Account.new("test_account")
|
315
|
-
a.bank_account = "tok_123"
|
316
|
-
assert_equal "tok_123", a.bank_account
|
317
|
-
ensure
|
318
|
-
$stderr = old_stderr
|
319
|
-
end
|
320
|
-
end
|
321
|
-
|
322
|
-
should "set a flag if given an object source" do
|
323
|
-
old_stderr = $stderr
|
324
|
-
$stderr = StringIO.new
|
325
|
-
begin
|
326
|
-
a = Stripe::Account.new("test_account")
|
327
|
-
a.bank_account = {
|
328
|
-
:object => 'bank_account'
|
329
|
-
}
|
330
|
-
assert_equal true, a.bank_account.save_with_parent
|
331
|
-
ensure
|
332
|
-
$stderr = old_stderr
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
294
|
should "warn that #bank_account= is deprecated" do
|
337
295
|
old_stderr = $stderr
|
338
296
|
$stderr = StringIO.new
|
@@ -3,6 +3,26 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
3
3
|
|
4
4
|
module Stripe
|
5
5
|
class ApiResourceTest < Test::Unit::TestCase
|
6
|
+
class NestedTestAPIResource < Stripe::APIResource
|
7
|
+
save_nested_resource :external_account
|
8
|
+
end
|
9
|
+
|
10
|
+
context ".save_nested_resource" do
|
11
|
+
should "can have a scalar set" do
|
12
|
+
r = NestedTestAPIResource.new("test_resource")
|
13
|
+
r.external_account = "tok_123"
|
14
|
+
assert_equal "tok_123", r.external_account
|
15
|
+
end
|
16
|
+
|
17
|
+
should "set a flag if given an object source" do
|
18
|
+
r = NestedTestAPIResource.new("test_resource")
|
19
|
+
r.external_account = {
|
20
|
+
:object => 'card'
|
21
|
+
}
|
22
|
+
assert_equal true, r.external_account.save_with_parent
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
6
26
|
should "creating a new APIResource should not fetch over the network" do
|
7
27
|
@mock.expects(:get).never
|
8
28
|
Stripe::Customer.new("someid")
|