stripe 1.58.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +4 -0
- data/.travis.yml +1 -2
- data/Gemfile +11 -12
- data/History.txt +8 -0
- data/README.md +44 -31
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/stripe.rb +4 -344
- data/lib/stripe/account.rb +4 -4
- data/lib/stripe/api_operations/create.rb +2 -2
- data/lib/stripe/api_operations/delete.rb +2 -2
- data/lib/stripe/api_operations/list.rb +2 -2
- data/lib/stripe/api_operations/request.rb +9 -3
- data/lib/stripe/api_operations/save.rb +4 -6
- data/lib/stripe/api_resource.rb +2 -2
- data/lib/stripe/bank_account.rb +2 -2
- data/lib/stripe/bitcoin_receiver.rb +1 -1
- data/lib/stripe/charge.rb +12 -12
- data/lib/stripe/customer.rb +6 -6
- data/lib/stripe/dispute.rb +2 -3
- data/lib/stripe/errors.rb +20 -10
- data/lib/stripe/invoice.rb +4 -4
- data/lib/stripe/list_object.rb +2 -2
- data/lib/stripe/order.rb +4 -4
- data/lib/stripe/reversal.rb +1 -1
- data/lib/stripe/source.rb +2 -2
- data/lib/stripe/stripe_client.rb +396 -0
- data/lib/stripe/stripe_response.rb +48 -0
- data/lib/stripe/transfer.rb +2 -2
- data/lib/stripe/util.rb +6 -6
- data/lib/stripe/version.rb +1 -1
- data/spec/fixtures.json +0 -0
- data/spec/fixtures.yaml +0 -0
- data/spec/spec.json +0 -0
- data/spec/spec.yaml +0 -0
- data/stripe.gemspec +1 -1
- data/test/api_fixtures.rb +29 -0
- data/test/api_stub_helpers.rb +125 -0
- data/test/stripe/account_test.rb +153 -247
- data/test/stripe/alipay_account_test.rb +10 -2
- data/test/stripe/api_operations_test.rb +3 -3
- data/test/stripe/api_resource_test.rb +139 -499
- data/test/stripe/apple_pay_domain_test.rb +22 -23
- data/test/stripe/application_fee_refund_test.rb +22 -31
- data/test/stripe/application_fee_test.rb +6 -17
- data/test/stripe/balance_test.rb +3 -3
- data/test/stripe/bank_account_test.rb +31 -11
- data/test/stripe/bitcoin_receiver_test.rb +51 -42
- data/test/stripe/bitcoin_transaction_test.rb +11 -19
- data/test/stripe/charge_test.rb +39 -126
- data/test/stripe/country_spec_test.rb +7 -30
- data/test/stripe/coupon_test.rb +33 -17
- data/test/stripe/customer_card_test.rb +25 -46
- data/test/stripe/customer_test.rb +86 -81
- data/test/stripe/dispute_test.rb +27 -38
- data/test/stripe/errors_test.rb +2 -2
- data/test/stripe/file_upload_test.rb +32 -24
- data/test/stripe/invoice_item_test.rb +46 -10
- data/test/stripe/invoice_test.rb +48 -48
- data/test/stripe/list_object_test.rb +22 -31
- data/test/stripe/order_return_test.rb +11 -15
- data/test/stripe/order_test.rb +38 -51
- data/test/stripe/plan_test.rb +39 -18
- data/test/stripe/product_test.rb +29 -33
- data/test/stripe/recipient_card_test.rb +23 -40
- data/test/stripe/recipient_test.rb +39 -10
- data/test/stripe/refund_test.rb +20 -45
- data/test/stripe/reversal_test.rb +27 -31
- data/test/stripe/sku_test.rb +36 -19
- data/test/stripe/source_test.rb +26 -66
- data/test/stripe/stripe_client_test.rb +428 -0
- data/test/stripe/stripe_object_test.rb +6 -2
- data/test/stripe/stripe_response_test.rb +46 -0
- data/test/stripe/subscription_item_test.rb +37 -59
- data/test/stripe/subscription_test.rb +40 -176
- data/test/stripe/three_d_secure_test.rb +13 -12
- data/test/stripe/transfer_test.rb +36 -19
- data/test/stripe_test.rb +3 -36
- data/test/test_data.rb +5 -931
- data/test/test_helper.rb +21 -25
- metadata +22 -17
- data/test/stripe/charge_refund_test.rb +0 -67
- data/test/stripe/metadata_test.rb +0 -129
@@ -116,9 +116,13 @@ module Stripe
|
|
116
116
|
|
117
117
|
# customer comes with a `sources` list that makes a convenient object to
|
118
118
|
# perform tests on
|
119
|
-
|
119
|
+
obj = Stripe::StripeObject.construct_from({
|
120
|
+
sources: [
|
121
|
+
{}
|
122
|
+
]
|
123
|
+
}, opts)
|
120
124
|
|
121
|
-
source =
|
125
|
+
source = obj.sources.first
|
122
126
|
# Pulling `@opts` as an instance variable here is not ideal, but it's
|
123
127
|
# important enough argument that the test here is worth it. we should
|
124
128
|
# consider exposing it publicly on a future pull (and possibly renaming
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class StripeResponseTest < Test::Unit::TestCase
|
5
|
+
context ".from_faraday_hash" do
|
6
|
+
should "converts to StripeResponse" do
|
7
|
+
body = '{"foo": "bar"}'
|
8
|
+
headers = { "Request-Id" => "request-id" }
|
9
|
+
|
10
|
+
http_resp = {
|
11
|
+
body: body,
|
12
|
+
headers: headers,
|
13
|
+
status: 200,
|
14
|
+
}
|
15
|
+
|
16
|
+
resp = StripeResponse.from_faraday_hash(http_resp)
|
17
|
+
|
18
|
+
assert_equal JSON.parse(body, symbolize_names: true), resp.data
|
19
|
+
assert_equal body, resp.http_body
|
20
|
+
assert_equal headers, resp.http_headers
|
21
|
+
assert_equal 200, resp.http_status
|
22
|
+
assert_equal "request-id", resp.request_id
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context ".from_faraday_response" do
|
27
|
+
should "converts to StripeResponse" do
|
28
|
+
body = '{"foo": "bar"}'
|
29
|
+
headers = { "Request-Id" => "request-id" }
|
30
|
+
|
31
|
+
env = Faraday::Env.from(
|
32
|
+
:status => 200, :body => body,
|
33
|
+
:response_headers => headers)
|
34
|
+
http_resp = Faraday::Response.new(env)
|
35
|
+
|
36
|
+
resp = StripeResponse.from_faraday_response(http_resp)
|
37
|
+
|
38
|
+
assert_equal JSON.parse(body, symbolize_names: true), resp.data
|
39
|
+
assert_equal body, resp.http_body
|
40
|
+
assert_equal headers, resp.http_headers
|
41
|
+
assert_equal 200, resp.http_status
|
42
|
+
assert_equal "request-id", resp.request_id
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -2,75 +2,53 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class SubscriptionItemTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:subscription_item)
|
6
|
+
|
7
|
+
should "be listable" do
|
8
|
+
items = Stripe::SubscriptionItem.list(
|
9
|
+
subscription: API_FIXTURES.fetch(:subscription)[:id]
|
10
|
+
)
|
11
|
+
assert_requested :get, "#{Stripe.api_base}/v1/subscription_items",
|
12
|
+
query: { subscription: API_FIXTURES.fetch(:subscription)[:id] }
|
13
|
+
assert items.data.kind_of?(Array)
|
14
|
+
assert items.data[0].kind_of?(Stripe::SubscriptionItem)
|
12
15
|
end
|
13
16
|
|
14
|
-
should "
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
assert sub_items.kind_of? Array
|
20
|
-
assert sub_items[0].kind_of? Stripe::SubscriptionItem
|
17
|
+
should "be retrievable" do
|
18
|
+
item = Stripe::SubscriptionItem.retrieve(FIXTURE[:id])
|
19
|
+
assert_requested :get, "#{Stripe.api_base}/v1/subscription_items/#{FIXTURE[:id]}"
|
20
|
+
assert item.kind_of?(Stripe::SubscriptionItem)
|
21
21
|
end
|
22
22
|
|
23
|
-
should "
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
should "be creatable" do
|
24
|
+
item = Stripe::SubscriptionItem.create(
|
25
|
+
item: 'silver',
|
26
|
+
plan: API_FIXTURES.fetch(:plan)[:id],
|
27
|
+
quantity: 3,
|
28
|
+
subscription: API_FIXTURES.fetch(:subscription)[:id]
|
29
|
+
)
|
30
|
+
assert_requested :post, "#{Stripe.api_base}/v1/subscription_items"
|
31
|
+
assert item.kind_of?(Stripe::SubscriptionItem)
|
30
32
|
end
|
31
33
|
|
32
|
-
should "
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
34
|
+
should "be saveable" do
|
35
|
+
item = Stripe::SubscriptionItem.retrieve(FIXTURE[:id])
|
36
|
+
item.quantity = 4
|
37
|
+
item.save
|
38
|
+
assert_requested :post, "#{Stripe.api_base}/v1/subscription_items/#{FIXTURE[:id]}"
|
44
39
|
end
|
45
40
|
|
46
|
-
should "
|
47
|
-
|
48
|
-
|
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
|
41
|
+
should "be updateable" do
|
42
|
+
item = Stripe::SubscriptionItem.update(FIXTURE[:id], metadata: {foo: 'bar'})
|
43
|
+
assert_requested :post, "#{Stripe.api_base}/v1/subscription_items/#{FIXTURE[:id]}"
|
44
|
+
assert item.kind_of?(Stripe::SubscriptionItem)
|
62
45
|
end
|
63
46
|
|
64
|
-
should "
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
47
|
+
should "be deletable" do
|
48
|
+
item = Stripe::SubscriptionItem.retrieve(FIXTURE[:id])
|
49
|
+
item = item.delete
|
50
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/subscription_items/#{FIXTURE[:id]}"
|
51
|
+
assert item.kind_of?(Stripe::SubscriptionItem)
|
74
52
|
end
|
75
53
|
end
|
76
54
|
end
|
@@ -2,195 +2,59 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class SubscriptionTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
@mock.expects(:get).once.returns(make_response(make_customer))
|
7
|
-
customer = Stripe::Customer.retrieve('c_test_customer')
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:subscription)
|
8
6
|
|
9
|
-
|
10
|
-
|
7
|
+
should "be listable" do
|
8
|
+
subscriptions = Stripe::Subscription.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/subscriptions"
|
10
|
+
assert subscriptions.data.kind_of?(Array)
|
11
|
+
assert subscriptions.data[0].kind_of?(Stripe::Subscription)
|
11
12
|
end
|
12
13
|
|
13
|
-
should "
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
subs = customer.subscriptions.all()
|
19
|
-
|
20
|
-
assert subs.kind_of?(Stripe::ListObject)
|
21
|
-
assert subs.data.kind_of?(Array)
|
22
|
-
assert subs.data[0].kind_of? Stripe::Subscription
|
23
|
-
end
|
24
|
-
|
25
|
-
should "subscriptions should be creatable by customer" do
|
26
|
-
@mock.expects(:get).once.returns(make_response(make_customer))
|
27
|
-
customer = Stripe::Customer.retrieve('c_test_customer')
|
28
|
-
|
29
|
-
@mock.expects(:post).once.with("#{Stripe.api_base}/v1/customers/c_test_customer/subscriptions", nil, 'plan=silver').returns(make_response(make_subscription(:id => 'test_new_subscription')))
|
30
|
-
subscription = customer.subscriptions.create(:plan => 'silver')
|
31
|
-
|
32
|
-
assert_equal 'test_new_subscription', subscription.id
|
33
|
-
end
|
34
|
-
|
35
|
-
should "subscriptions should be retrievable" do
|
36
|
-
@mock.expects(:get).once.with("#{Stripe.api_base}/v1/subscriptions/s_test_subscription", nil, nil).returns(make_response(make_subscription))
|
37
|
-
sub = Stripe::Subscription.retrieve('s_test_subscription')
|
38
|
-
|
39
|
-
assert sub.kind_of?(Stripe::Subscription)
|
40
|
-
end
|
41
|
-
|
42
|
-
should "subscriptions should be listable" do
|
43
|
-
@mock.expects(:get).once.returns(make_response(make_subscription_array))
|
44
|
-
subs = Stripe::Subscription.list.data
|
45
|
-
|
46
|
-
assert subs.kind_of? Array
|
47
|
-
assert subs[0].kind_of? Stripe::Subscription
|
48
|
-
end
|
49
|
-
|
50
|
-
should "subscriptions should be listable with filters" do
|
51
|
-
@mock.expects(:get).once.with("#{Stripe.api_base}/v1/subscriptions?customer=c_test_customer&limit=3&plan=gold", nil, nil).returns(make_response(make_subscription_array))
|
52
|
-
subs = Stripe::Subscription.all(:customer => 'c_test_customer', :limit => 3, :plan => 'gold')
|
53
|
-
|
54
|
-
assert subs.kind_of?(Stripe::ListObject)
|
55
|
-
assert subs.data.kind_of?(Array)
|
56
|
-
assert subs.data[0].kind_of? Stripe::Subscription
|
57
|
-
end
|
58
|
-
|
59
|
-
should "subscriptions should be refreshable" do
|
60
|
-
@mock.expects(:get).twice.returns(make_response(make_subscription(:id => 'refreshed_subscription')))
|
61
|
-
|
62
|
-
sub = Stripe::Subscription.retrieve('s_test_subscription')
|
63
|
-
sub.refresh
|
64
|
-
|
65
|
-
assert_equal 'refreshed_subscription', sub.id
|
66
|
-
end
|
67
|
-
|
68
|
-
should "subscriptions should be deletable" do
|
69
|
-
@mock.expects(:get).once.returns(make_response(make_subscription))
|
70
|
-
sub = Stripe::Subscription.retrieve('s_test_subscription')
|
71
|
-
|
72
|
-
@mock.expects(:delete).once.with("#{Stripe.api_base}/v1/subscriptions/#{sub.id}?at_period_end=true", nil, nil).returns(make_response(make_subscription))
|
73
|
-
sub.delete :at_period_end => true
|
74
|
-
|
75
|
-
@mock.expects(:delete).once.with("#{Stripe.api_base}/v1/subscriptions/#{sub.id}", nil, nil).returns(make_response(make_subscription))
|
76
|
-
sub.delete
|
77
|
-
end
|
78
|
-
|
79
|
-
should "subscriptions should be updateable" do
|
80
|
-
sid = 's_test_subscription'
|
81
|
-
@mock.expects(:post).once.with do |url, api_key, params|
|
82
|
-
url == "#{Stripe.api_base}/v1/subscriptions/#{sid}" && api_key.nil? && CGI.parse(params) == {'status' => ['active']}
|
83
|
-
end.returns(make_response(make_subscription(:status => 'active')))
|
84
|
-
|
85
|
-
sub = Stripe::Subscription.update(sid, :status => 'active')
|
86
|
-
|
87
|
-
assert_equal 'active', sub.status
|
14
|
+
should "be retrievable" do
|
15
|
+
subscription = Stripe::Subscription.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get,
|
17
|
+
"#{Stripe.api_base}/v1/subscriptions/#{FIXTURE[:id]}"
|
18
|
+
assert subscription.kind_of?(Stripe::Subscription)
|
88
19
|
end
|
89
20
|
|
90
|
-
should "
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
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
|
21
|
+
should "be creatable" do
|
22
|
+
subscription = Stripe::Subscription.create(
|
23
|
+
customer: API_FIXTURES.fetch(:customer)[:id]
|
24
|
+
)
|
25
|
+
assert_requested :post, "#{Stripe.api_base}/v1/subscriptions"
|
26
|
+
assert subscription.kind_of?(Stripe::Subscription)
|
134
27
|
end
|
135
28
|
|
136
|
-
should "
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
url == "#{Stripe.api_base}/v1/subscriptions/#{sub.id}" && api_key.nil? && CGI.parse(params) == {'status' => ['active']}
|
143
|
-
end.returns(make_response(make_subscription(:status => 'active')))
|
144
|
-
|
145
|
-
sub.status = 'active'
|
146
|
-
sub.save
|
147
|
-
|
148
|
-
assert_equal 'active', sub.status
|
29
|
+
should "be saveable" do
|
30
|
+
subscription = Stripe::Subscription.retrieve(FIXTURE[:id])
|
31
|
+
subscription.metadata['key'] = 'value'
|
32
|
+
subscription.save
|
33
|
+
assert_requested :post,
|
34
|
+
"#{Stripe.api_base}/v1/subscriptions/#{FIXTURE[:id]}"
|
149
35
|
end
|
150
36
|
|
151
|
-
should "
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
sub = Stripe::Subscription.create(:plan => 'gold', :customer => 'c_test_customer')
|
157
|
-
|
158
|
-
assert_equal 'test_new_subscription', sub.id
|
159
|
-
assert_equal 'gold', sub.plan.identifier
|
37
|
+
should "be updateable" do
|
38
|
+
subscription = Stripe::Subscription.update(FIXTURE[:id], metadata: {foo: 'bar'})
|
39
|
+
assert_requested :post,
|
40
|
+
"#{Stripe.api_base}/v1/subscriptions/#{FIXTURE[:id]}"
|
41
|
+
assert subscription.kind_of?(Stripe::Subscription)
|
160
42
|
end
|
161
43
|
|
162
|
-
should "
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
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
|
44
|
+
should "be deletable" do
|
45
|
+
subscription = Stripe::Subscription.retrieve(FIXTURE[:id])
|
46
|
+
subscription = subscription.delete
|
47
|
+
assert_requested :delete,
|
48
|
+
"#{Stripe.api_base}/v1/subscriptions/#{FIXTURE[:id]}"
|
49
|
+
assert subscription.kind_of?(Stripe::Subscription)
|
184
50
|
end
|
185
51
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
sub.delete_discount
|
193
|
-
assert_equal nil, sub.discount
|
52
|
+
context "#delete_discount" do
|
53
|
+
should "be able to delete a subscriptions's discount" do
|
54
|
+
subscription = Stripe::Subscription.retrieve(FIXTURE[:id])
|
55
|
+
subscription = subscription.delete_discount
|
56
|
+
assert subscription.kind_of?(Stripe::Subscription)
|
57
|
+
end
|
194
58
|
end
|
195
59
|
end
|
196
60
|
end
|
@@ -2,21 +2,22 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ThreeDSecureTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:three_d_secure)
|
6
|
+
|
7
|
+
should "be retrievable" do
|
8
|
+
secure = Stripe::ThreeDSecure.retrieve(FIXTURE[:id])
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/3d_secure/#{FIXTURE[:id]}"
|
10
|
+
assert secure.kind_of?(Stripe::ThreeDSecure)
|
9
11
|
end
|
10
12
|
|
11
|
-
should "
|
12
|
-
|
13
|
-
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:return_url => "https://example.org/3d-secure-result"
|
13
|
+
should "be creatable" do
|
14
|
+
_ = Stripe::ThreeDSecure.create(
|
15
|
+
card: API_FIXTURES.fetch(:token)[:id],
|
16
|
+
amount: 1500,
|
17
|
+
currency: "usd",
|
18
|
+
return_url: "https://example.org/3d-secure-result"
|
18
19
|
)
|
19
|
-
|
20
|
+
assert_requested :post, "#{Stripe.api_base}/v1/3d_secure"
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
@@ -2,32 +2,49 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class TransferTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:transfer)
|
6
|
+
|
7
|
+
should "be listable" do
|
8
|
+
transfers = Stripe::Transfer.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/transfers"
|
10
|
+
assert transfers.data.kind_of?(Array)
|
11
|
+
assert transfers.data[0].kind_of?(Stripe::Transfer)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable" do
|
15
|
+
transfer = Stripe::Transfer.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/transfers/#{FIXTURE[:id]}"
|
17
|
+
assert transfer.kind_of?(Stripe::Transfer)
|
9
18
|
end
|
10
19
|
|
11
|
-
should "
|
12
|
-
|
13
|
-
|
14
|
-
|
20
|
+
should "be creatable" do
|
21
|
+
transfer = Stripe::Transfer.create(
|
22
|
+
amount: 100,
|
23
|
+
currency: "USD"
|
24
|
+
)
|
25
|
+
assert_requested :post, "#{Stripe.api_base}/v1/transfers"
|
26
|
+
assert transfer.kind_of?(Stripe::Transfer)
|
15
27
|
end
|
16
28
|
|
17
|
-
should "
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
assert_equal "bar", transfer.metadata['foo']
|
29
|
+
should "be saveable" do
|
30
|
+
transfer = Stripe::Transfer.retrieve(FIXTURE[:id])
|
31
|
+
transfer.metadata['key'] = 'value'
|
32
|
+
transfer.save
|
33
|
+
assert_requested :post, "#{Stripe.api_base}/v1/transfers/#{FIXTURE[:id]}"
|
23
34
|
end
|
24
35
|
|
25
|
-
should "
|
26
|
-
|
27
|
-
|
36
|
+
should "be updateable" do
|
37
|
+
transfer = Stripe::Transfer.update(FIXTURE[:id], metadata: {foo: 'bar'})
|
38
|
+
assert_requested :post, "#{Stripe.api_base}/v1/transfers/#{FIXTURE[:id]}"
|
39
|
+
assert transfer.kind_of?(Stripe::Transfer)
|
40
|
+
end
|
28
41
|
|
29
|
-
|
30
|
-
transfer
|
42
|
+
context "#cancel" do
|
43
|
+
should "cancel a transfer" do
|
44
|
+
transfer = Stripe::Transfer.retrieve(FIXTURE[:id])
|
45
|
+
transfer = transfer.cancel
|
46
|
+
assert transfer.kind_of?(Stripe::Transfer)
|
47
|
+
end
|
31
48
|
end
|
32
49
|
end
|
33
50
|
end
|