stripe 1.55.0 → 1.55.1
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/README.md +2 -2
- data/VERSION +1 -1
- data/lib/stripe.rb +8 -0
- data/lib/stripe/errors/permission_error.rb +4 -0
- data/lib/stripe/stripe_object.rb +1 -1
- data/lib/stripe/subscription.rb +10 -0
- data/lib/stripe/subscription_item.rb +12 -0
- data/lib/stripe/util.rb +47 -32
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/api_resource_test.rb +12 -0
- data/test/stripe/invoice_test.rb +18 -0
- data/test/stripe/stripe_object_test.rb +7 -0
- data/test/stripe/subscription_item_test.rb +76 -0
- data/test/stripe/subscription_test.rb +70 -0
- data/test/stripe/util_test.rb +4 -0
- data/test/test_data.rb +26 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a4bdfe3a97b5c7b3d7a1c5c5ace530dd4ef4b0c
|
4
|
+
data.tar.gz: aa5aacbe6bc4dc1dd5982e8c4ef4346a5cf890e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf05983e41c5ae0b5a4390c7f3557da1df08ead492fca1d13f08a6e9fc171715c723767587da01023285ffb55052502944c795c9e07a05167e595bffb9009986
|
7
|
+
data.tar.gz: b5e01f1265f2ebc91b221011ca5f435167704ce7781de700b879593fdf29ed3ad5f0df55f75376de0e9efb49e88dc95a29d6a85829fa6290329ce673b2e7db74
|
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -121,8 +121,8 @@ certificates.
|
|
121
121
|
### max_network_retries
|
122
122
|
|
123
123
|
When `max_network_retries` is set to a positive integer, stripe will retry
|
124
|
-
requests that fail on a network error. Idempotency keys will be added to
|
125
|
-
and
|
124
|
+
requests that fail on a network error. Idempotency keys will be added to `POST`
|
125
|
+
and `DELETE` requests to ensure the safety of retrying. There will be a short delay
|
126
126
|
between each retry, with an exponential backoff algorithm used to determine the
|
127
127
|
length of the delay. Default value is 0.
|
128
128
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.55.
|
1
|
+
1.55.1
|
data/lib/stripe.rb
CHANGED
@@ -43,6 +43,7 @@ require 'stripe/recipient'
|
|
43
43
|
require 'stripe/bank_account'
|
44
44
|
require 'stripe/card'
|
45
45
|
require 'stripe/subscription'
|
46
|
+
require 'stripe/subscription_item'
|
46
47
|
require 'stripe/application_fee'
|
47
48
|
require 'stripe/refund'
|
48
49
|
require 'stripe/reversal'
|
@@ -66,6 +67,7 @@ require 'stripe/errors/api_connection_error'
|
|
66
67
|
require 'stripe/errors/card_error'
|
67
68
|
require 'stripe/errors/invalid_request_error'
|
68
69
|
require 'stripe/errors/authentication_error'
|
70
|
+
require 'stripe/errors/permission_error'
|
69
71
|
require 'stripe/errors/rate_limit_error'
|
70
72
|
|
71
73
|
module Stripe
|
@@ -377,6 +379,8 @@ module Stripe
|
|
377
379
|
raise authentication_error(error, resp, error_obj)
|
378
380
|
when 402
|
379
381
|
raise card_error(error, resp, error_obj)
|
382
|
+
when 403
|
383
|
+
raise permission_error(error, resp, error_obj)
|
380
384
|
when 429
|
381
385
|
raise rate_limit_error(error, resp, error_obj)
|
382
386
|
else
|
@@ -405,6 +409,10 @@ module Stripe
|
|
405
409
|
resp.code, resp.body, error_obj, resp.headers)
|
406
410
|
end
|
407
411
|
|
412
|
+
def self.permission_error(error, resp, error_obj)
|
413
|
+
PermissionError.new(error[:message], resp.code, resp.body, error_obj, resp.headers)
|
414
|
+
end
|
415
|
+
|
408
416
|
def self.api_error(error, resp, error_obj)
|
409
417
|
APIError.new(error[:message], resp.code, resp.body, error_obj, resp.headers)
|
410
418
|
end
|
data/lib/stripe/stripe_object.rb
CHANGED
@@ -84,8 +84,8 @@ module Stripe
|
|
84
84
|
# Default to true. TODO: Convert to optional arguments after we're off
|
85
85
|
# 1.9 which will make this quite a bit more clear.
|
86
86
|
dirty = method_options.fetch(:dirty, true)
|
87
|
-
|
88
87
|
values.each do |k, v|
|
88
|
+
add_accessors([k], values) unless metaclass.method_defined?(k.to_sym)
|
89
89
|
@values[k] = Util.convert_to_stripe_object(v, opts)
|
90
90
|
dirty_value!(@values[k]) if dirty
|
91
91
|
@unsaved_values.add(k)
|
data/lib/stripe/subscription.rb
CHANGED
@@ -12,6 +12,16 @@ module Stripe
|
|
12
12
|
initialize_from({ :discount => nil }, opts, true)
|
13
13
|
end
|
14
14
|
|
15
|
+
def self.update(id, params={}, opts={})
|
16
|
+
params[:items] = Util.array_to_hash(params[:items]) if params[:items]
|
17
|
+
super(id, params, opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.create(params={}, opts={})
|
21
|
+
params[:items] = Util.array_to_hash(params[:items]) if params[:items]
|
22
|
+
super(params, opts)
|
23
|
+
end
|
24
|
+
|
15
25
|
private
|
16
26
|
|
17
27
|
def discount_url
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Stripe
|
2
|
+
class SubscriptionItem < APIResource
|
3
|
+
extend Stripe::APIOperations::Create
|
4
|
+
include Stripe::APIOperations::Delete
|
5
|
+
extend Stripe::APIOperations::List
|
6
|
+
include Stripe::APIOperations::Save
|
7
|
+
|
8
|
+
def self.resource_url
|
9
|
+
'/v1/subscription_items'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/stripe/util.rb
CHANGED
@@ -23,38 +23,39 @@ module Stripe
|
|
23
23
|
'list' => ListObject,
|
24
24
|
|
25
25
|
# business objects
|
26
|
-
'account'
|
27
|
-
'alipay_account'
|
28
|
-
'
|
29
|
-
'
|
30
|
-
'
|
31
|
-
'
|
32
|
-
'
|
33
|
-
'
|
34
|
-
'
|
35
|
-
'
|
36
|
-
'
|
37
|
-
'
|
38
|
-
'
|
39
|
-
'
|
40
|
-
'
|
41
|
-
'
|
42
|
-
'
|
43
|
-
'
|
44
|
-
'
|
45
|
-
'
|
46
|
-
'
|
47
|
-
'
|
48
|
-
'
|
49
|
-
'
|
50
|
-
'
|
51
|
-
'
|
52
|
-
'
|
53
|
-
'
|
54
|
-
'
|
55
|
-
'
|
56
|
-
'
|
57
|
-
'
|
26
|
+
'account' => Account,
|
27
|
+
'alipay_account' => AlipayAccount,
|
28
|
+
'apple_pay_domain' => ApplePayDomain,
|
29
|
+
'application_fee' => ApplicationFee,
|
30
|
+
'balance' => Balance,
|
31
|
+
'balance_transaction' => BalanceTransaction,
|
32
|
+
'bank_account' => BankAccount,
|
33
|
+
'bitcoin_receiver' => BitcoinReceiver,
|
34
|
+
'bitcoin_transaction' => BitcoinTransaction,
|
35
|
+
'card' => Card,
|
36
|
+
'charge' => Charge,
|
37
|
+
'country_spec' => CountrySpec,
|
38
|
+
'coupon' => Coupon,
|
39
|
+
'customer' => Customer,
|
40
|
+
'dispute' => Dispute,
|
41
|
+
'event' => Event,
|
42
|
+
'fee_refund' => ApplicationFeeRefund,
|
43
|
+
'file_upload' => FileUpload,
|
44
|
+
'invoice' => Invoice,
|
45
|
+
'invoiceitem' => InvoiceItem,
|
46
|
+
'order' => Order,
|
47
|
+
'order_return' => OrderReturn,
|
48
|
+
'plan' => Plan,
|
49
|
+
'product' => Product,
|
50
|
+
'recipient' => Recipient,
|
51
|
+
'refund' => Refund,
|
52
|
+
'sku' => SKU,
|
53
|
+
'subscription' => Subscription,
|
54
|
+
'subscription_item' => SubscriptionItem,
|
55
|
+
'token' => Token,
|
56
|
+
'transfer' => Transfer,
|
57
|
+
'transfer_reversal' => Reversal,
|
58
|
+
'three_d_secure' => ThreeDSecure,
|
58
59
|
}
|
59
60
|
end
|
60
61
|
|
@@ -120,6 +121,20 @@ module Stripe
|
|
120
121
|
map { |k,v| "#{url_encode(k)}=#{url_encode(v)}" }.join('&')
|
121
122
|
end
|
122
123
|
|
124
|
+
# Transforms an array into a hash with integer keys. Used for a small
|
125
|
+
# number of API endpoints. If the argument is not an Array, return it
|
126
|
+
# unchanged. Example: [{foo: 'bar'}] => {"0" => {foo: "bar"}}
|
127
|
+
def self.array_to_hash(array)
|
128
|
+
case array
|
129
|
+
when Array
|
130
|
+
hash = {}
|
131
|
+
array.each_with_index { |v,i| hash[i.to_s] = v }
|
132
|
+
hash
|
133
|
+
else
|
134
|
+
array
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
123
138
|
# Encodes a string in a way that makes it suitable for use in a set of
|
124
139
|
# query parameters in a URI or in a set of form parameters in a request
|
125
140
|
# body.
|
data/lib/stripe/version.rb
CHANGED
@@ -300,6 +300,18 @@ module Stripe
|
|
300
300
|
end
|
301
301
|
end
|
302
302
|
|
303
|
+
should "a 403 should give a PermissionError with http status, body, and JSON body" do
|
304
|
+
response = make_response(make_missing_id_error, 403)
|
305
|
+
@mock.expects(:get).once.raises(RestClient::ExceptionWithResponse.new(response, 403))
|
306
|
+
begin
|
307
|
+
Stripe::Customer.retrieve("foo")
|
308
|
+
rescue Stripe::PermissionError => e
|
309
|
+
assert_equal(403, e.http_status)
|
310
|
+
assert_equal(true, !!e.http_body)
|
311
|
+
assert_equal(true, e.json_body.kind_of?(Hash))
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
303
315
|
should "a 404 should give an InvalidRequestError with http status, body, and JSON body" do
|
304
316
|
response = make_response(make_missing_id_error, 404)
|
305
317
|
@mock.expects(:get).once.raises(RestClient::ExceptionWithResponse.new(response, 404))
|
data/test/stripe/invoice_test.rb
CHANGED
@@ -44,5 +44,23 @@ module Stripe
|
|
44
44
|
i.pay
|
45
45
|
assert_equal nil, i.next_payment_attempt
|
46
46
|
end
|
47
|
+
|
48
|
+
should "be able to retrieve upcoming invoices" do
|
49
|
+
base = "#{Stripe.api_base}/v1/invoices/upcoming?"
|
50
|
+
cus_sub = "customer=c_test_customer&subscription=s_test_subscription&"
|
51
|
+
item0 = "subscription_items[][plan]=gold&subscription_items[][quantity]=1&"
|
52
|
+
item1 = "subscription_items[][plan]=silver&subscription_items[][quantity]=2"
|
53
|
+
@mock.expects(:get).once.with(base + cus_sub + item0 + item1, nil, nil).
|
54
|
+
returns(make_response(make_invoice(:customer => 'c_test_customer', :subscription => 's_test_subscription')))
|
55
|
+
|
56
|
+
i = Stripe::Invoice.upcoming(
|
57
|
+
:customer => 'c_test_customer',
|
58
|
+
:subscription => 's_test_subscription',
|
59
|
+
:subscription_items => [{:plan => 'gold', :quantity =>1}, {:plan => 'silver', :quantity =>2}]
|
60
|
+
)
|
61
|
+
|
62
|
+
assert_equal 'c_test_customer', i.customer
|
63
|
+
assert_equal 's_test_subscription', i.subscription
|
64
|
+
end
|
47
65
|
end
|
48
66
|
end
|
@@ -90,6 +90,13 @@ module Stripe
|
|
90
90
|
assert_equal Stripe::StripeObject, obj.metadata.class
|
91
91
|
end
|
92
92
|
|
93
|
+
should "create accessors when #update_attributes is called" do
|
94
|
+
obj = Stripe::StripeObject.construct_from({})
|
95
|
+
assert_equal false, obj.send(:metaclass).method_defined?(:foo)
|
96
|
+
obj.update_attributes(:foo => 'bar')
|
97
|
+
assert_equal true, obj.send(:metaclass).method_defined?(:foo)
|
98
|
+
end
|
99
|
+
|
93
100
|
should "warn that #refresh_from is deprecated" do
|
94
101
|
old_stderr = $stderr
|
95
102
|
$stderr = StringIO.new
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class SubscriptionItemTest < Test::Unit::TestCase
|
5
|
+
should "subscription items should be retrievable" do
|
6
|
+
@mock.expects(:get).once.with("#{Stripe.api_base}/v1/subscription_items/si_test_subscription_item", nil, nil).
|
7
|
+
returns(make_response(make_subscription_item))
|
8
|
+
|
9
|
+
sub_item = Stripe::SubscriptionItem.retrieve('si_test_subscription_item')
|
10
|
+
|
11
|
+
assert sub_item.kind_of?(Stripe::SubscriptionItem)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "subscription items should be listable" do
|
15
|
+
@mock.expects(:get).once.with("#{Stripe.api_base}/v1/subscription_items?subscription=s_test_subscription&limit=3", nil, nil).
|
16
|
+
returns(make_response(make_subscription_item_array))
|
17
|
+
sub_items = Stripe::SubscriptionItem.list(:subscription => 's_test_subscription', :limit => 3).data
|
18
|
+
|
19
|
+
assert sub_items.kind_of? Array
|
20
|
+
assert sub_items[0].kind_of? Stripe::SubscriptionItem
|
21
|
+
end
|
22
|
+
|
23
|
+
should "subscription items should be deletable" do
|
24
|
+
@mock.expects(:get).once.returns(make_response(make_subscription_item))
|
25
|
+
sub_item = Stripe::SubscriptionItem.retrieve('si_test_subscription_item')
|
26
|
+
|
27
|
+
@mock.expects(:delete).once.with("#{Stripe.api_base}/v1/subscription_items/#{sub_item.id}", nil, nil).
|
28
|
+
returns(make_response(make_subscription_item))
|
29
|
+
sub_item.delete
|
30
|
+
end
|
31
|
+
|
32
|
+
should "subscription items should be updateable" do
|
33
|
+
sid = 'si_test_subscription_item'
|
34
|
+
@mock.expects(:post).once.with do |url, api_key, params|
|
35
|
+
url == "#{Stripe.api_base}/v1/subscription_items/#{sid}" &&
|
36
|
+
api_key.nil? &&
|
37
|
+
CGI.parse(params) == {'plan' => ['silver'], 'quantity' => ['3']}
|
38
|
+
end.returns(make_response(make_subscription_item(:plan => 'silver', :quantity => 3)))
|
39
|
+
|
40
|
+
sub_item = Stripe::SubscriptionItem.update(sid, {:plan => 'silver', :quantity => 3})
|
41
|
+
|
42
|
+
assert_equal 'silver', sub_item.plan.id
|
43
|
+
assert_equal 3, sub_item.quantity
|
44
|
+
end
|
45
|
+
|
46
|
+
should "subscription items should be saveable" do
|
47
|
+
@mock.expects(:get).once.returns(make_response(make_subscription_item))
|
48
|
+
sub_item = Stripe::SubscriptionItem.retrieve('si_test_subscription_item')
|
49
|
+
|
50
|
+
@mock.expects(:post).once.with do |url, api_key, params|
|
51
|
+
url == "#{Stripe.api_base}/v1/subscription_items/#{sub_item.id}" &&
|
52
|
+
api_key.nil? &&
|
53
|
+
CGI.parse(params) == {'plan' => ['silver'], 'quantity' => ['3']}
|
54
|
+
end.returns(make_response(make_subscription_item(:plan => 'silver', :quantity => 3)))
|
55
|
+
|
56
|
+
sub_item.plan = 'silver'
|
57
|
+
sub_item.quantity = 3
|
58
|
+
sub_item.save
|
59
|
+
|
60
|
+
assert_equal 'silver', sub_item.plan.id
|
61
|
+
assert_equal 3, sub_item.quantity
|
62
|
+
end
|
63
|
+
|
64
|
+
should "create should return a new subscription item" do
|
65
|
+
@mock.expects(:post).once.with do |url, api_key, params|
|
66
|
+
url == "#{Stripe.api_base}/v1/subscription_items" && api_key.nil? &&
|
67
|
+
CGI.parse(params) == {'plan' => ['silver'], 'quantity' => ['3']}
|
68
|
+
end.returns(make_response(make_subscription_item(:plan => 'silver', :quantity => 3)))
|
69
|
+
|
70
|
+
sub_item = Stripe::SubscriptionItem.create(:plan => 'silver', :quantity => 3)
|
71
|
+
|
72
|
+
assert_equal 'silver', sub_item.plan.id
|
73
|
+
assert_equal 3, sub_item.quantity
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -87,6 +87,52 @@ module Stripe
|
|
87
87
|
assert_equal 'active', sub.status
|
88
88
|
end
|
89
89
|
|
90
|
+
should "subscription items should be updateable" do
|
91
|
+
sid = 's_test_subscription'
|
92
|
+
items = {:data => [{:plan => {:id =>'gold'}, :quantity => 1}, {:plan => {:id =>'silver'}, :quantity => 2}]}
|
93
|
+
|
94
|
+
@mock.expects(:post).once.with do |url, api_key, params|
|
95
|
+
url == "#{Stripe.api_base}/v1/subscriptions/#{sid}" &&
|
96
|
+
api_key.nil? &&
|
97
|
+
CGI.parse(params) == {
|
98
|
+
'items[0][plan]' => ['gold'],
|
99
|
+
'items[0][quantity]' => ['1'],
|
100
|
+
'items[1][plan]' => ['silver'],
|
101
|
+
'items[1][quantity]' => ['2'],
|
102
|
+
}
|
103
|
+
end.returns(make_response(make_subscription(:items => items)))
|
104
|
+
|
105
|
+
sub = Stripe::Subscription.update(sid, :items => [{:plan => 'gold', :quantity =>1}, {:plan => 'silver', :quantity =>2}])
|
106
|
+
|
107
|
+
assert_equal 'gold', sub.items.data[0].plan.id
|
108
|
+
assert_equal 1, sub.items.data[0].quantity
|
109
|
+
assert_equal 'silver', sub.items.data[1].plan.id
|
110
|
+
assert_equal 2, sub.items.data[1].quantity
|
111
|
+
end
|
112
|
+
|
113
|
+
should "subscription items should be updateable with hash" do
|
114
|
+
sid = 's_test_subscription'
|
115
|
+
items = {:data => [{:plan => {:id =>'gold'}, :quantity => 1}, {:plan => {:id =>'silver'}, :quantity => 2}]}
|
116
|
+
|
117
|
+
@mock.expects(:post).once.with do |url, api_key, params|
|
118
|
+
url == "#{Stripe.api_base}/v1/subscriptions/#{sid}" &&
|
119
|
+
api_key.nil? &&
|
120
|
+
CGI.parse(params) == {
|
121
|
+
'items[0][plan]' => ['gold'],
|
122
|
+
'items[0][quantity]' => ['1'],
|
123
|
+
'items[1][plan]' => ['silver'],
|
124
|
+
'items[1][quantity]' => ['2'],
|
125
|
+
}
|
126
|
+
end.returns(make_response(make_subscription(:items => items)))
|
127
|
+
|
128
|
+
sub = Stripe::Subscription.update(sid, :items => {'0' => {:plan => 'gold', :quantity =>1}, '1' => {:plan => 'silver', :quantity =>2}})
|
129
|
+
|
130
|
+
assert_equal 'gold', sub.items.data[0].plan.id
|
131
|
+
assert_equal 1, sub.items.data[0].quantity
|
132
|
+
assert_equal 'silver', sub.items.data[1].plan.id
|
133
|
+
assert_equal 2, sub.items.data[1].quantity
|
134
|
+
end
|
135
|
+
|
90
136
|
should "subscriptions should be saveable" do
|
91
137
|
@mock.expects(:get).once.returns(make_response(make_subscription))
|
92
138
|
sub = Stripe::Subscription.retrieve('s_test_subscription')
|
@@ -113,6 +159,30 @@ module Stripe
|
|
113
159
|
assert_equal 'gold', sub.plan.identifier
|
114
160
|
end
|
115
161
|
|
162
|
+
should "create with items should return a new subscription" do
|
163
|
+
items = {:data => [{:plan => {:id =>'gold'}, :quantity => 1}, {:plan => {:id =>'silver'}, :quantity => 2}]}
|
164
|
+
|
165
|
+
@mock.expects(:post).once.with do |url, api_key, params|
|
166
|
+
url == "#{Stripe.api_base}/v1/subscriptions" &&
|
167
|
+
api_key.nil? &&
|
168
|
+
CGI.parse(params) == {
|
169
|
+
'customer' => ['c_test_customer'],
|
170
|
+
'items[0][plan]' => ['gold'],
|
171
|
+
'items[0][quantity]' => ['1'],
|
172
|
+
'items[1][plan]' => ['silver'],
|
173
|
+
'items[1][quantity]' => ['2'],
|
174
|
+
}
|
175
|
+
end.returns(make_response(make_subscription(:items => items, :id => 'test_new_subscription')))
|
176
|
+
|
177
|
+
sub = Stripe::Subscription.create(:customer => 'c_test_customer', :items => [{:plan => 'gold', :quantity =>1}, {:plan => 'silver', :quantity =>2}])
|
178
|
+
|
179
|
+
assert_equal 'test_new_subscription', sub.id
|
180
|
+
assert_equal 'gold', sub.items.data[0].plan.id
|
181
|
+
assert_equal 1, sub.items.data[0].quantity
|
182
|
+
assert_equal 'silver', sub.items.data[1].plan.id
|
183
|
+
assert_equal 2, sub.items.data[1].quantity
|
184
|
+
end
|
185
|
+
|
116
186
|
should "be able to delete a subscriptions's discount" do
|
117
187
|
@mock.expects(:post).once.returns(make_response(make_subscription))
|
118
188
|
sub = Stripe::Subscription.create(:plan => 'gold', :customer => 'c_test_customer', coupon: 'forever')
|
data/test/stripe/util_test.rb
CHANGED
@@ -141,5 +141,9 @@ module Stripe
|
|
141
141
|
obj = Util.convert_to_stripe_object([1, 2, 3], {})
|
142
142
|
assert_equal [1, 2, 3], obj
|
143
143
|
end
|
144
|
+
|
145
|
+
should "#array_to_hash should convert an array into a hash with integer keys" do
|
146
|
+
assert_equal({"0" => 1, "1" => 2, "2" => 3}, Util.array_to_hash([1, 2, 3]))
|
147
|
+
end
|
144
148
|
end
|
145
149
|
end
|
data/test/test_data.rb
CHANGED
@@ -277,6 +277,24 @@ module Stripe
|
|
277
277
|
}.merge(params)
|
278
278
|
end
|
279
279
|
|
280
|
+
def make_subscription_item(params = {})
|
281
|
+
plan = params.delete(:plan) || 'gold'
|
282
|
+
{
|
283
|
+
:id => "si_test_subscription_item",
|
284
|
+
:object => "subscription_item",
|
285
|
+
:created => 1473875521,
|
286
|
+
:plan => {
|
287
|
+
:id => plan,
|
288
|
+
:object => "plan",
|
289
|
+
:amount => 1000,
|
290
|
+
:created => 1468349629,
|
291
|
+
:currency => "usd",
|
292
|
+
:interval => "month",
|
293
|
+
},
|
294
|
+
:quantity => 1
|
295
|
+
}.merge(params)
|
296
|
+
end
|
297
|
+
|
280
298
|
def make_refund(params = {})
|
281
299
|
{
|
282
300
|
:object => 'refund',
|
@@ -297,6 +315,14 @@ module Stripe
|
|
297
315
|
}
|
298
316
|
end
|
299
317
|
|
318
|
+
def make_subscription_item_array
|
319
|
+
{
|
320
|
+
:data => [make_subscription_item, make_subscription_item, make_subscription_item],
|
321
|
+
:object => 'list',
|
322
|
+
:resource_url => '/v1/subscription_items'
|
323
|
+
}
|
324
|
+
end
|
325
|
+
|
300
326
|
def make_customer_subscription_array(customer_id)
|
301
327
|
{
|
302
328
|
:data => [make_subscription, make_subscription, make_subscription],
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.55.
|
4
|
+
version: 1.55.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- lib/stripe/errors/authentication_error.rb
|
78
78
|
- lib/stripe/errors/card_error.rb
|
79
79
|
- lib/stripe/errors/invalid_request_error.rb
|
80
|
+
- lib/stripe/errors/permission_error.rb
|
80
81
|
- lib/stripe/errors/rate_limit_error.rb
|
81
82
|
- lib/stripe/errors/stripe_error.rb
|
82
83
|
- lib/stripe/event.rb
|
@@ -96,6 +97,7 @@ files:
|
|
96
97
|
- lib/stripe/source.rb
|
97
98
|
- lib/stripe/stripe_object.rb
|
98
99
|
- lib/stripe/subscription.rb
|
100
|
+
- lib/stripe/subscription_item.rb
|
99
101
|
- lib/stripe/three_d_secure.rb
|
100
102
|
- lib/stripe/token.rb
|
101
103
|
- lib/stripe/transfer.rb
|
@@ -136,6 +138,7 @@ files:
|
|
136
138
|
- test/stripe/sku_test.rb
|
137
139
|
- test/stripe/source_test.rb
|
138
140
|
- test/stripe/stripe_object_test.rb
|
141
|
+
- test/stripe/subscription_item_test.rb
|
139
142
|
- test/stripe/subscription_test.rb
|
140
143
|
- test/stripe/three_d_secure_test.rb
|
141
144
|
- test/stripe/transfer_test.rb
|
@@ -202,6 +205,7 @@ test_files:
|
|
202
205
|
- test/stripe/sku_test.rb
|
203
206
|
- test/stripe/source_test.rb
|
204
207
|
- test/stripe/stripe_object_test.rb
|
208
|
+
- test/stripe/subscription_item_test.rb
|
205
209
|
- test/stripe/subscription_test.rb
|
206
210
|
- test/stripe/three_d_secure_test.rb
|
207
211
|
- test/stripe/transfer_test.rb
|