stripe 1.30.3 → 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/.github/ISSUE_TEMPLATE.md +5 -0
- data/.travis.yml +3 -14
- data/Gemfile +28 -4
- data/History.txt +180 -0
- data/README.md +147 -0
- data/Rakefile +10 -0
- data/VERSION +1 -1
- data/bin/stripe-console +12 -5
- data/lib/data/ca-certificates.crt +3868 -5114
- data/lib/stripe/account.rb +43 -23
- data/lib/stripe/alipay_account.rb +20 -0
- 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 -3
- data/lib/stripe/api_operations/request.rb +9 -3
- data/lib/stripe/api_operations/save.rb +85 -0
- data/lib/stripe/api_resource.rb +38 -5
- data/lib/stripe/apple_pay_domain.rb +12 -0
- data/lib/stripe/application_fee.rb +8 -8
- data/lib/stripe/application_fee_refund.rb +7 -3
- data/lib/stripe/balance_transaction.rb +1 -1
- data/lib/stripe/bank_account.rb +13 -4
- data/lib/stripe/bitcoin_receiver.rb +6 -6
- data/lib/stripe/bitcoin_transaction.rb +1 -1
- data/lib/stripe/card.rb +9 -5
- data/lib/stripe/charge.rb +38 -20
- data/lib/stripe/country_spec.rb +9 -0
- data/lib/stripe/coupon.rb +1 -1
- data/lib/stripe/customer.rb +12 -10
- data/lib/stripe/dispute.rb +4 -5
- data/lib/stripe/errors.rb +92 -0
- data/lib/stripe/file_upload.rb +1 -1
- data/lib/stripe/invoice.rb +7 -7
- data/lib/stripe/invoice_item.rb +1 -1
- data/lib/stripe/list_object.rb +8 -7
- data/lib/stripe/order.rb +12 -4
- data/lib/stripe/order_return.rb +9 -0
- data/lib/stripe/plan.rb +1 -1
- data/lib/stripe/product.rb +2 -10
- data/lib/stripe/recipient.rb +1 -1
- data/lib/stripe/refund.rb +1 -1
- data/lib/stripe/reversal.rb +7 -3
- data/lib/stripe/singleton_api_resource.rb +3 -3
- data/lib/stripe/sku.rb +2 -2
- data/lib/stripe/source.rb +11 -0
- data/lib/stripe/stripe_client.rb +396 -0
- data/lib/stripe/stripe_object.rb +167 -91
- data/lib/stripe/stripe_response.rb +48 -0
- data/lib/stripe/subscription.rb +15 -9
- data/lib/stripe/subscription_item.rb +12 -0
- data/lib/stripe/three_d_secure.rb +9 -0
- data/lib/stripe/transfer.rb +4 -5
- data/lib/stripe/util.rb +105 -33
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe.rb +69 -266
- data/spec/fixtures.json +1409 -0
- data/spec/fixtures.yaml +1153 -0
- data/spec/spec.json +19949 -0
- data/spec/spec.yaml +15504 -0
- data/stripe.gemspec +5 -18
- data/test/api_fixtures.rb +29 -0
- data/test/api_stub_helpers.rb +125 -0
- data/test/stripe/account_test.rb +163 -211
- data/test/stripe/alipay_account_test.rb +19 -0
- data/test/stripe/api_operations_test.rb +31 -0
- data/test/stripe/api_resource_test.rb +174 -340
- data/test/stripe/apple_pay_domain_test.rb +33 -0
- data/test/stripe/application_fee_refund_test.rb +22 -31
- data/test/stripe/application_fee_test.rb +6 -14
- data/test/stripe/balance_test.rb +3 -3
- data/test/stripe/bank_account_test.rb +41 -0
- 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 -98
- data/test/stripe/country_spec_test.rb +20 -0
- data/test/stripe/coupon_test.rb +35 -11
- data/test/stripe/customer_card_test.rb +25 -46
- data/test/stripe/customer_test.rb +89 -61
- data/test/stripe/dispute_test.rb +28 -31
- data/test/stripe/errors_test.rb +18 -0
- data/test/stripe/file_upload_test.rb +32 -24
- data/test/stripe/invoice_item_test.rb +55 -0
- data/test/stripe/invoice_test.rb +50 -24
- data/test/stripe/list_object_test.rb +57 -45
- data/test/stripe/order_return_test.rb +21 -0
- data/test/stripe/order_test.rb +41 -34
- data/test/stripe/plan_test.rb +52 -0
- data/test/stripe/product_test.rb +31 -25
- data/test/stripe/recipient_card_test.rb +23 -40
- data/test/stripe/recipient_test.rb +50 -0
- data/test/stripe/refund_test.rb +20 -36
- data/test/stripe/reversal_test.rb +27 -31
- data/test/stripe/sku_test.rb +39 -13
- data/test/stripe/source_test.rb +43 -0
- data/test/stripe/stripe_client_test.rb +428 -0
- data/test/stripe/stripe_object_test.rb +186 -13
- data/test/stripe/stripe_response_test.rb +46 -0
- data/test/stripe/subscription_item_test.rb +54 -0
- data/test/stripe/subscription_test.rb +40 -52
- data/test/stripe/three_d_secure_test.rb +23 -0
- data/test/stripe/transfer_test.rb +38 -13
- data/test/stripe/util_test.rb +48 -16
- data/test/stripe_test.rb +25 -0
- data/test/test_data.rb +5 -621
- data/test/test_helper.rb +24 -24
- metadata +60 -139
- data/README.rdoc +0 -68
- data/gemfiles/default-with-activesupport.gemfile +0 -10
- data/gemfiles/json.gemfile +0 -12
- data/gemfiles/yajl.gemfile +0 -12
- data/lib/stripe/api_operations/update.rb +0 -58
- data/lib/stripe/errors/api_connection_error.rb +0 -4
- data/lib/stripe/errors/api_error.rb +0 -4
- data/lib/stripe/errors/authentication_error.rb +0 -4
- data/lib/stripe/errors/card_error.rb +0 -12
- data/lib/stripe/errors/invalid_request_error.rb +0 -11
- data/lib/stripe/errors/rate_limit_error.rb +0 -4
- data/lib/stripe/errors/stripe_error.rb +0 -26
- data/test/stripe/charge_refund_test.rb +0 -55
- data/test/stripe/metadata_test.rb +0 -129
@@ -8,8 +8,10 @@ module Stripe
|
|
8
8
|
end
|
9
9
|
|
10
10
|
should "provide #count via enumerable" do
|
11
|
-
list = Stripe::ListObject.construct_from(
|
12
|
-
|
11
|
+
list = Stripe::ListObject.construct_from({
|
12
|
+
data: [API_FIXTURES.fetch(:charge)]
|
13
|
+
})
|
14
|
+
assert_equal 1, list.count
|
13
15
|
end
|
14
16
|
|
15
17
|
should "provide #each" do
|
@@ -31,9 +33,14 @@ module Stripe
|
|
31
33
|
]
|
32
34
|
expected = Util.convert_to_stripe_object(arr, {})
|
33
35
|
|
34
|
-
list = TestListObject.construct_from({
|
35
|
-
|
36
|
-
|
36
|
+
list = TestListObject.construct_from({
|
37
|
+
:data => [{ :id => 1 }],
|
38
|
+
:has_more => true,
|
39
|
+
:url => "/things",
|
40
|
+
})
|
41
|
+
stub_request(:get, "#{Stripe.api_base}/things").
|
42
|
+
with(query: { starting_after: "1" }).
|
43
|
+
to_return(body: JSON.generate({ :data => [{ :id => 2 }, { :id => 3}], :has_more => false }))
|
37
44
|
|
38
45
|
assert_equal expected, list.auto_paging_each.to_a
|
39
46
|
end
|
@@ -46,9 +53,14 @@ module Stripe
|
|
46
53
|
]
|
47
54
|
expected = Util.convert_to_stripe_object(arr, {})
|
48
55
|
|
49
|
-
list = TestListObject.construct_from({
|
50
|
-
|
51
|
-
|
56
|
+
list = TestListObject.construct_from({
|
57
|
+
:data => [{ :id => 1 }],
|
58
|
+
:has_more => true,
|
59
|
+
:url => "/things",
|
60
|
+
})
|
61
|
+
stub_request(:get, "#{Stripe.api_base}/things").
|
62
|
+
with(query: { starting_after: "1" }).
|
63
|
+
to_return(body: JSON.generate({ :data => [{ :id => 2 }, { :id => 3}], :has_more => false }))
|
52
64
|
|
53
65
|
actual = []
|
54
66
|
list.auto_paging_each do |obj|
|
@@ -70,33 +82,38 @@ module Stripe
|
|
70
82
|
#
|
71
83
|
|
72
84
|
should "fetch a next page through #next_page" do
|
73
|
-
list = TestListObject.construct_from({
|
74
|
-
|
75
|
-
|
85
|
+
list = TestListObject.construct_from({
|
86
|
+
:data => [{ :id => 1 }],
|
87
|
+
:has_more => true,
|
88
|
+
:url => "/things",
|
89
|
+
})
|
90
|
+
stub_request(:get, "#{Stripe.api_base}/things").
|
91
|
+
with(query: { starting_after: "1" }).
|
92
|
+
to_return(body: JSON.generate({ :data => [{ :id => 2 }], :has_more => false }))
|
76
93
|
next_list = list.next_page
|
77
94
|
refute next_list.empty?
|
78
95
|
end
|
79
96
|
|
80
97
|
should "fetch a next page through #next_page and respect limit" do
|
81
|
-
list = TestListObject.construct_from({
|
98
|
+
list = TestListObject.construct_from({
|
99
|
+
:data => [{ :id => 1 }],
|
100
|
+
:has_more => true,
|
101
|
+
:url => "/things",
|
102
|
+
})
|
82
103
|
list.filters = { :expand => ['data.source'], :limit => 3 }
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
u = URI.parse(url)
|
87
|
-
params = CGI.parse(query)
|
88
|
-
u.host == URI.parse(Stripe.api_base).host && u.path == "/things" && params == {
|
89
|
-
"expand[]" => ["data.source"],
|
90
|
-
"limit" => ["3"],
|
91
|
-
"starting_after" => ["1"],
|
92
|
-
}
|
93
|
-
end.returns(make_response({ :data => [{ :id => 2 }], :has_more => false }))
|
104
|
+
stub_request(:get, "#{Stripe.api_base}/things").
|
105
|
+
with(query: { "expand[]" => "data.source", "limit" => "3", "starting_after" => "1" }).
|
106
|
+
to_return(body: JSON.generate({ :data => [{ :id => 2 }], :has_more => false }))
|
94
107
|
next_list = list.next_page
|
95
108
|
assert_equal({ :expand => ['data.source'], :limit => 3 }, next_list.filters)
|
96
109
|
end
|
97
110
|
|
98
111
|
should "fetch an empty page through #next_page" do
|
99
|
-
list = TestListObject.construct_from({
|
112
|
+
list = TestListObject.construct_from({
|
113
|
+
:data => [{ :id => 1 }],
|
114
|
+
:has_more => false,
|
115
|
+
:url => "/things",
|
116
|
+
})
|
100
117
|
next_list = list.next_page
|
101
118
|
assert_equal Stripe::ListObject.empty_list, next_list
|
102
119
|
end
|
@@ -106,27 +123,26 @@ module Stripe
|
|
106
123
|
#
|
107
124
|
|
108
125
|
should "fetch a next page through #previous_page" do
|
109
|
-
list = TestListObject.construct_from({
|
110
|
-
|
111
|
-
|
126
|
+
list = TestListObject.construct_from({
|
127
|
+
:data => [{ :id => 2 }],
|
128
|
+
:url => "/things",
|
129
|
+
})
|
130
|
+
stub_request(:get, "#{Stripe.api_base}/things").
|
131
|
+
with(query: { ending_before: "2" }).
|
132
|
+
to_return(body: JSON.generate({ :data => [{ :id => 1 }] }))
|
112
133
|
next_list = list.previous_page
|
113
134
|
refute next_list.empty?
|
114
135
|
end
|
115
136
|
|
116
137
|
should "fetch a next page through #previous_page and respect limit" do
|
117
|
-
list = TestListObject.construct_from({
|
138
|
+
list = TestListObject.construct_from({
|
139
|
+
:data => [{ :id => 2 }],
|
140
|
+
:url => "/things",
|
141
|
+
})
|
118
142
|
list.filters = { :expand => ['data.source'], :limit => 3 }
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
u = URI.parse(url)
|
123
|
-
params = CGI.parse(query)
|
124
|
-
u.host == URI.parse(Stripe.api_base).host && u.path == "/things" && params == {
|
125
|
-
"ending_before" => ["2"],
|
126
|
-
"expand[]" => ["data.source"],
|
127
|
-
"limit" => ["3"],
|
128
|
-
}
|
129
|
-
end.returns(make_response({ :data => [{ :id => 1 }] }))
|
143
|
+
stub_request(:get, "#{Stripe.api_base}/things").
|
144
|
+
with(query: { "expand[]" => "data.source", "limit" => "3", "ending_before" => "2" }).
|
145
|
+
to_return(body: JSON.generate({ :data => [{ :id => 1 }] }))
|
130
146
|
next_list = list.previous_page
|
131
147
|
assert_equal({ :expand => ['data.source'], :limit => 3 }, next_list.filters)
|
132
148
|
end
|
@@ -138,13 +154,12 @@ module Stripe
|
|
138
154
|
# note that the name #all is deprecated, as is using it fetch the next page
|
139
155
|
# in a list
|
140
156
|
should "be able to retrieve full lists given a listobject" do
|
141
|
-
@mock.expects(:get).twice.returns(make_response(make_charge_array))
|
142
157
|
c = Stripe::Charge.all
|
143
158
|
assert c.kind_of?(Stripe::ListObject)
|
144
|
-
assert_equal('/v1/charges', c.
|
159
|
+
assert_equal('/v1/charges', c.resource_url)
|
145
160
|
all = c.all
|
146
161
|
assert all.kind_of?(Stripe::ListObject)
|
147
|
-
assert_equal('/v1/charges', all.
|
162
|
+
assert_equal('/v1/charges', all.resource_url)
|
148
163
|
assert all.data.kind_of?(Array)
|
149
164
|
end
|
150
165
|
end
|
@@ -152,7 +167,4 @@ end
|
|
152
167
|
|
153
168
|
# A helper class with a URL that allows us to try out pagination.
|
154
169
|
class TestListObject < Stripe::ListObject
|
155
|
-
def url
|
156
|
-
"/things"
|
157
|
-
end
|
158
170
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class OrderReturnTest < Test::Unit::TestCase
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:order_return)
|
6
|
+
|
7
|
+
should "be listable" do
|
8
|
+
order_returns = Stripe::OrderReturn.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/order_returns"
|
10
|
+
assert order_returns.data.kind_of?(Array)
|
11
|
+
assert order_returns.data[0].kind_of?(Stripe::OrderReturn)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable" do
|
15
|
+
order_return = Stripe::OrderReturn.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get,
|
17
|
+
"#{Stripe.api_base}/v1/order_returns/#{FIXTURE[:id]}"
|
18
|
+
assert order_return.kind_of?(Stripe::OrderReturn)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/test/stripe/order_test.rb
CHANGED
@@ -2,51 +2,58 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class OrderTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:order)
|
6
|
+
|
7
|
+
should "be listable" do
|
7
8
|
orders = Stripe::Order.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/orders"
|
8
10
|
assert orders.data.kind_of?(Array)
|
9
|
-
orders.
|
10
|
-
assert order.kind_of?(Stripe::Order)
|
11
|
-
end
|
11
|
+
assert orders.first.kind_of?(Stripe::Order)
|
12
12
|
end
|
13
13
|
|
14
|
-
should "
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
should "be retrievable" do
|
15
|
+
order = Stripe::Order.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/orders/#{FIXTURE[:id]}"
|
17
|
+
assert order.kind_of?(Stripe::Order)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "be creatable" do
|
21
|
+
order = Stripe::Order.create(
|
22
|
+
currency: "USD"
|
23
|
+
)
|
24
|
+
assert_requested :post, "#{Stripe.api_base}/v1/orders"
|
25
|
+
assert order.kind_of?(Stripe::Order)
|
20
26
|
end
|
21
27
|
|
22
|
-
should "
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
p.status = "fulfilled"
|
28
|
-
p.save
|
28
|
+
should "be saveable" do
|
29
|
+
order = Stripe::Order.retrieve(FIXTURE[:id])
|
30
|
+
order.metadata['key'] = 'value'
|
31
|
+
order.save
|
32
|
+
assert_requested :post, "#{Stripe.api_base}/v1/orders/#{FIXTURE[:id]}"
|
29
33
|
end
|
30
34
|
|
31
|
-
should "
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
p.refresh
|
36
|
-
p.metadata['key'] = 'value'
|
37
|
-
p.save
|
35
|
+
should "be updateable" do
|
36
|
+
order = Stripe::Order.update(FIXTURE[:id], metadata: { key: 'value' })
|
37
|
+
assert_requested :post, "#{Stripe.api_base}/v1/orders/#{FIXTURE[:id]}"
|
38
|
+
assert order.kind_of?(Stripe::Order)
|
38
39
|
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
context "#pay" do
|
42
|
+
should "pay an order" do
|
43
|
+
order = Stripe::Order.retrieve(FIXTURE[:id])
|
44
|
+
order = order.pay(token: API_FIXTURES.fetch(:token)[:id])
|
45
|
+
assert order.kind_of?(Stripe::Order)
|
46
|
+
end
|
47
|
+
end
|
44
48
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
49
|
+
context "#return_order" do
|
50
|
+
should "return an order" do
|
51
|
+
order = Stripe::Order.retrieve(FIXTURE[:id])
|
52
|
+
order = order.return_order(:orders => [
|
53
|
+
{ parent: API_FIXTURES.fetch(:sku)[:id] }
|
54
|
+
])
|
55
|
+
assert order.kind_of?(Stripe::OrderReturn)
|
56
|
+
end
|
50
57
|
end
|
51
58
|
end
|
52
59
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class PlanTest < Test::Unit::TestCase
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:plan)
|
6
|
+
|
7
|
+
should "be listable" do
|
8
|
+
plans = Stripe::Plan.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/plans"
|
10
|
+
assert plans.data.kind_of?(Array)
|
11
|
+
assert plans.data[0].kind_of?(Stripe::Plan)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable" do
|
15
|
+
plan = Stripe::Plan.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/plans/#{FIXTURE[:id]}"
|
17
|
+
assert plan.kind_of?(Stripe::Plan)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "be creatable" do
|
21
|
+
plan = Stripe::Plan.create(
|
22
|
+
amount: 5000,
|
23
|
+
interval: "month",
|
24
|
+
name: "Sapphire elite",
|
25
|
+
currency: "usd",
|
26
|
+
id: "sapphire-elite"
|
27
|
+
)
|
28
|
+
assert_requested :post, "#{Stripe.api_base}/v1/plans"
|
29
|
+
assert plan.kind_of?(Stripe::Plan)
|
30
|
+
end
|
31
|
+
|
32
|
+
should "be saveable" do
|
33
|
+
plan = Stripe::Plan.retrieve(FIXTURE[:id])
|
34
|
+
plan.metadata['key'] = 'value'
|
35
|
+
plan.save
|
36
|
+
assert_requested :post, "#{Stripe.api_base}/v1/plans/#{FIXTURE[:id]}"
|
37
|
+
end
|
38
|
+
|
39
|
+
should "be updateable" do
|
40
|
+
plan = Stripe::Plan.update(FIXTURE[:id], metadata: {foo: 'bar'})
|
41
|
+
assert_requested :post, "#{Stripe.api_base}/v1/plans/#{FIXTURE[:id]}"
|
42
|
+
assert plan.kind_of?(Stripe::Plan)
|
43
|
+
end
|
44
|
+
|
45
|
+
should "be deletable" do
|
46
|
+
plan = Stripe::Plan.retrieve(FIXTURE[:id])
|
47
|
+
plan = plan.delete
|
48
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/plans/#{FIXTURE[:id]}"
|
49
|
+
assert plan.kind_of?(Stripe::Plan)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/test/stripe/product_test.rb
CHANGED
@@ -2,40 +2,46 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ProductTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:product)
|
6
|
+
|
7
|
+
should "be listable" do
|
7
8
|
products = Stripe::Product.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/products"
|
8
10
|
assert products.data.kind_of?(Array)
|
9
|
-
products.
|
10
|
-
|
11
|
-
|
11
|
+
assert products.data[0].kind_of?(Stripe::Product)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable" do
|
15
|
+
product = Stripe::Product.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/products/#{FIXTURE[:id]}"
|
17
|
+
assert product.kind_of?(Stripe::Product)
|
12
18
|
end
|
13
19
|
|
14
|
-
should "
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
+
should "be creatable" do
|
21
|
+
_ = Stripe::Product.create(
|
22
|
+
name: "My Product"
|
23
|
+
)
|
24
|
+
assert_requested :post, "#{Stripe.api_base}/v1/products"
|
20
25
|
end
|
21
26
|
|
22
|
-
should "
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
p.description = "New product description"
|
28
|
-
p.save
|
27
|
+
should "be saveable" do
|
28
|
+
product = Stripe::Product.retrieve(FIXTURE[:id])
|
29
|
+
product.metadata['key'] = 'value'
|
30
|
+
product.save
|
31
|
+
assert_requested :post, "#{Stripe.api_base}/v1/products/#{FIXTURE[:id]}"
|
29
32
|
end
|
30
33
|
|
31
|
-
should "
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
p.refresh
|
36
|
-
p.metadata['key'] = 'value'
|
37
|
-
p.save
|
34
|
+
should "be updateable" do
|
35
|
+
product = Stripe::Product.update(FIXTURE[:id], metadata: {foo: 'bar'})
|
36
|
+
assert_requested :post, "#{Stripe.api_base}/v1/products/#{FIXTURE[:id]}"
|
37
|
+
assert product.kind_of?(Stripe::Product)
|
38
38
|
end
|
39
39
|
|
40
|
+
should "be deletable" do
|
41
|
+
product = Stripe::Product.retrieve(FIXTURE[:id])
|
42
|
+
product = product.delete
|
43
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/products/#{FIXTURE[:id]}"
|
44
|
+
assert product.kind_of?(Stripe::Product)
|
45
|
+
end
|
40
46
|
end
|
41
47
|
end
|
@@ -2,56 +2,39 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class RecipientCardTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:source)
|
6
6
|
|
7
|
-
|
8
|
-
@
|
9
|
-
|
7
|
+
setup do
|
8
|
+
@recipient =
|
9
|
+
Stripe::Recipient.retrieve(API_FIXTURES.fetch(:transfer_recipient)[:id])
|
10
10
|
end
|
11
11
|
|
12
|
-
should "
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
assert cards.kind_of? Array
|
17
|
-
assert cards[0].kind_of? Stripe::Card
|
12
|
+
should "be listable" do
|
13
|
+
cards = @recipient.cards.list
|
14
|
+
assert cards.data.kind_of?(Array)
|
15
|
+
assert cards.data[0].kind_of?(Stripe::Token)
|
18
16
|
end
|
19
17
|
|
20
|
-
should "
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
)
|
26
|
-
card = c.cards.retrieve('card')
|
27
|
-
assert_equal RECIPIENT_CARD_URL, card.url
|
18
|
+
should "be creatable" do
|
19
|
+
card = @recipient.cards.create(
|
20
|
+
card: API_FIXTURES.fetch(:token)[:id]
|
21
|
+
)
|
22
|
+
assert_requested :post, "#{Stripe.api_base}/v1/recipients/#{@recipient.id}/cards"
|
23
|
+
assert card.kind_of?(Stripe::Token)
|
28
24
|
end
|
29
25
|
|
30
|
-
should "
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
card
|
35
|
-
card.delete
|
36
|
-
assert card.deleted
|
26
|
+
should "be deletable" do
|
27
|
+
card = Stripe::Card.construct_from(FIXTURE.merge(recipient: @recipient.id))
|
28
|
+
card = card.delete
|
29
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/recipients/#{@recipient.id}/cards/#{FIXTURE[:id]}"
|
30
|
+
assert card.kind_of?(Stripe::Card)
|
37
31
|
end
|
38
32
|
|
39
|
-
should "
|
40
|
-
|
41
|
-
|
42
|
-
@mock.expects(:post).once.returns(make_response(make_card(:exp_year => "2100")))
|
43
|
-
card = c.cards.retrieve('card')
|
44
|
-
assert_equal "2000", card.exp_year
|
45
|
-
card.exp_year = "2100"
|
33
|
+
should "be saveable" do
|
34
|
+
card = Stripe::Card.construct_from(FIXTURE.merge(recipient: @recipient.id))
|
35
|
+
card.metadata['key'] = 'value'
|
46
36
|
card.save
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
should "create should return a new recipient card" do
|
51
|
-
c = recipient
|
52
|
-
@mock.expects(:post).once.returns(make_response(make_card(:id => "test_card")))
|
53
|
-
card = c.cards.create(:card => "tok_41YJ05ijAaWaFS")
|
54
|
-
assert_equal "test_card", card.id
|
37
|
+
assert_requested :post, "#{Stripe.api_base}/v1/recipients/#{@recipient.id}/cards/#{FIXTURE[:id]}"
|
55
38
|
end
|
56
39
|
end
|
57
40
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class RecipientTest < Test::Unit::TestCase
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:transfer_recipient)
|
6
|
+
|
7
|
+
should "be listable" do
|
8
|
+
recipients = Stripe::Recipient.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/recipients"
|
10
|
+
assert recipients.data.kind_of?(Array)
|
11
|
+
assert recipients.data[0].kind_of?(Stripe::Recipient)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable" do
|
15
|
+
recipient = Stripe::Recipient.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/recipients/#{FIXTURE[:id]}"
|
17
|
+
assert recipient.kind_of?(Stripe::Recipient)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "be creatable" do
|
21
|
+
recipient = Stripe::Recipient.create(
|
22
|
+
name: "Noah Jackson",
|
23
|
+
type: "individual"
|
24
|
+
)
|
25
|
+
assert_requested :post, "#{Stripe.api_base}/v1/recipients"
|
26
|
+
assert recipient.kind_of?(Stripe::Recipient)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "be saveable" do
|
30
|
+
recipient = Stripe::Recipient.retrieve(FIXTURE[:id])
|
31
|
+
recipient.metadata['key'] = 'value'
|
32
|
+
recipient.save
|
33
|
+
assert_requested :post, "#{Stripe.api_base}/v1/recipients/#{FIXTURE[:id]}"
|
34
|
+
end
|
35
|
+
|
36
|
+
should "be updateable" do
|
37
|
+
recipient = Stripe::Recipient.update(FIXTURE[:id], metadata: {foo: 'bar'})
|
38
|
+
assert_requested :post, "#{Stripe.api_base}/v1/recipients/#{FIXTURE[:id]}"
|
39
|
+
assert recipient.kind_of?(Stripe::Recipient)
|
40
|
+
end
|
41
|
+
|
42
|
+
should "be deletable" do
|
43
|
+
recipient = Stripe::Recipient.retrieve(FIXTURE[:id])
|
44
|
+
recipient = recipient.delete
|
45
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/recipients/#{FIXTURE[:id]}"
|
46
|
+
assert recipient.kind_of?(Stripe::Recipient)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
data/test/stripe/refund_test.rb
CHANGED
@@ -2,54 +2,38 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class RefundTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
@mock.expects(:get).
|
7
|
-
with("#{Stripe.api_base}/v1/refunds", nil, nil).
|
8
|
-
once.returns(make_response(make_refund_array))
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:refund)
|
9
6
|
|
7
|
+
should "be listable" do
|
10
8
|
refunds = Stripe::Refund.list
|
11
|
-
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/refunds"
|
10
|
+
assert refunds.data.kind_of?(Array)
|
12
11
|
assert refunds.first.kind_of?(Stripe::Refund)
|
13
12
|
end
|
14
13
|
|
15
|
-
should "
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
make_response(make_refund(:id => 'refreshed_refund')))
|
20
|
-
|
21
|
-
refund = Stripe::Refund.retrieve('test_refund')
|
22
|
-
refund.refresh
|
23
|
-
|
24
|
-
assert_equal 'refreshed_refund', refund.id
|
14
|
+
should "be retrievable" do
|
15
|
+
refund = Stripe::Refund.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/refunds/#{FIXTURE[:id]}"
|
17
|
+
assert refund.kind_of?(Stripe::Refund)
|
25
18
|
end
|
26
19
|
|
27
|
-
should "
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
@mock.expects(:post).
|
33
|
-
with("#{Stripe.api_base}/v1/refunds/save_refund", nil, 'metadata[key]=value').
|
34
|
-
once.returns(make_response(make_refund(:metadata => {'key' => 'value'})))
|
35
|
-
|
36
|
-
refund = Stripe::Refund.retrieve('get_refund')
|
37
|
-
|
38
|
-
assert_equal nil, refund.metadata['key']
|
20
|
+
should "be creatable" do
|
21
|
+
refund = Stripe::Refund.create(:charge => API_FIXTURES[:charge][:id])
|
22
|
+
assert_requested :post, "#{Stripe.api_base}/v1/refunds"
|
23
|
+
assert refund.kind_of?(Stripe::Refund)
|
24
|
+
end
|
39
25
|
|
26
|
+
should "be saveable" do
|
27
|
+
refund = Stripe::Refund.retrieve(FIXTURE[:id])
|
40
28
|
refund.metadata['key'] = 'value'
|
41
29
|
refund.save
|
42
|
-
|
43
|
-
assert_equal 'value', refund.metadata['key']
|
30
|
+
assert_requested :post, "#{Stripe.api_base}/v1/refunds/#{FIXTURE[:id]}"
|
44
31
|
end
|
45
32
|
|
46
|
-
should "
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
refund = Stripe::Refund.create(:charge => 'test_charge')
|
52
|
-
assert_equal 'test_new_refund', refund.id
|
33
|
+
should "be updateable" do
|
34
|
+
refund = Stripe::Refund.update(FIXTURE[:id], metadata: { key: 'value' })
|
35
|
+
assert_requested :post, "#{Stripe.api_base}/v1/refunds/#{FIXTURE[:id]}"
|
36
|
+
assert refund.kind_of?(Stripe::Refund)
|
53
37
|
end
|
54
38
|
end
|
55
39
|
end
|