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
data/test/stripe/errors_test.rb
CHANGED
@@ -7,10 +7,10 @@ module Stripe
|
|
7
7
|
e = StripeError.new("message")
|
8
8
|
assert_equal "message", e.to_s
|
9
9
|
|
10
|
-
e = StripeError.new("message", 200)
|
10
|
+
e = StripeError.new("message", http_status: 200)
|
11
11
|
assert_equal "(Status 200) message", e.to_s
|
12
12
|
|
13
|
-
e = StripeError.new("message", nil, nil, nil, { :request_id => "request-id" })
|
13
|
+
e = StripeError.new("message", http_status: nil, http_body: nil, json_body: nil, http_headers: { :request_id => "request-id" })
|
14
14
|
assert_equal "(Request request-id) message", e.to_s
|
15
15
|
end
|
16
16
|
end
|
@@ -2,38 +2,46 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class FileUploadTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
# Note that these tests are written different from others because we
|
6
|
+
# don't have anything on the uploads service in our OpenAPI spec. This is
|
7
|
+
# something that should be looked into at some point. We may need to ship
|
8
|
+
# a separate spec for it though, so it's high effort with low reward for
|
9
|
+
# the time being.
|
10
|
+
FIXTURE = {
|
11
|
+
id: "fil_15ABpV2eZvKYlo2C7vu7XS5l",
|
12
|
+
object: "file_upload",
|
13
|
+
}.freeze
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
15
|
+
should "be listable" do
|
16
|
+
stub_request(:get, "#{Stripe.uploads_base}/v1/files").
|
17
|
+
to_return(body: JSON.generate({
|
18
|
+
data: [FIXTURE],
|
19
|
+
object: 'list',
|
20
|
+
resource_url: '/v1/files'
|
21
|
+
}))
|
14
22
|
|
15
|
-
|
16
|
-
|
23
|
+
files = Stripe::FileUpload.list
|
24
|
+
assert files.data.kind_of?(Array)
|
25
|
+
assert files.data[0].kind_of?(Stripe::FileUpload)
|
17
26
|
end
|
18
27
|
|
19
|
-
should "
|
20
|
-
|
21
|
-
|
22
|
-
returns(make_response(make_file))
|
28
|
+
should "be retrievable" do
|
29
|
+
stub_request(:get, "#{Stripe.uploads_base}/v1/files/#{FIXTURE[:id]}").
|
30
|
+
to_return(body: JSON.generate(FIXTURE))
|
23
31
|
|
24
|
-
|
25
|
-
|
26
|
-
assert_equal 1403047735, c.created
|
32
|
+
file = Stripe::FileUpload.retrieve(FIXTURE[:id])
|
33
|
+
assert file.kind_of?(Stripe::FileUpload)
|
27
34
|
end
|
28
35
|
|
29
|
-
should "
|
30
|
-
|
31
|
-
|
32
|
-
returns(make_response(make_file_array))
|
36
|
+
should "be creatable" do
|
37
|
+
stub_request(:post, "#{Stripe.uploads_base}/v1/files").
|
38
|
+
to_return(body: JSON.generate(FIXTURE))
|
33
39
|
|
34
|
-
|
35
|
-
|
36
|
-
|
40
|
+
file = Stripe::FileUpload.create(
|
41
|
+
purpose: "dispute_evidence",
|
42
|
+
file: File.new(__FILE__),
|
43
|
+
)
|
44
|
+
assert file.kind_of?(Stripe::FileUpload)
|
37
45
|
end
|
38
46
|
end
|
39
47
|
end
|
@@ -2,18 +2,54 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class InvoiceItemTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:invoice_item)
|
6
|
+
|
7
|
+
should "be listable" do
|
8
|
+
invoiceitems = Stripe::InvoiceItem.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/invoiceitems"
|
10
|
+
assert invoiceitems.data.kind_of?(Array)
|
11
|
+
assert invoiceitems.first.kind_of?(Stripe::InvoiceItem)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable" do
|
15
|
+
item = Stripe::InvoiceItem.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get,
|
17
|
+
"#{Stripe.api_base}/v1/invoiceitems/#{FIXTURE[:id]}"
|
18
|
+
assert item.kind_of?(Stripe::InvoiceItem)
|
19
|
+
end
|
20
|
+
|
21
|
+
should "be creatable" do
|
22
|
+
item = Stripe::InvoiceItem.create(
|
23
|
+
amount: 100,
|
24
|
+
currency: "USD",
|
25
|
+
customer: API_FIXTURES[:customer][:id]
|
26
|
+
)
|
27
|
+
assert_requested :post,
|
28
|
+
"#{Stripe.api_base}/v1/invoiceitems"
|
29
|
+
assert item.kind_of?(Stripe::InvoiceItem)
|
30
|
+
end
|
31
|
+
|
32
|
+
should "be saveable" do
|
33
|
+
item = Stripe::InvoiceItem.retrieve(FIXTURE[:id])
|
34
|
+
item.metadata['key'] = 'value'
|
35
|
+
item.save
|
36
|
+
assert_requested :post,
|
37
|
+
"#{Stripe.api_base}/v1/invoiceitems/#{FIXTURE[:id]}"
|
38
|
+
end
|
39
|
+
|
40
|
+
should "be updateable" do
|
41
|
+
item = Stripe::InvoiceItem.update(FIXTURE[:id], metadata: { key: 'value' })
|
42
|
+
assert_requested :post,
|
43
|
+
"#{Stripe.api_base}/v1/invoiceitems/#{FIXTURE[:id]}"
|
44
|
+
assert item.kind_of?(Stripe::InvoiceItem)
|
9
45
|
end
|
10
46
|
|
11
|
-
should "
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
47
|
+
should "be deletable" do
|
48
|
+
item = Stripe::InvoiceItem.retrieve(FIXTURE[:id])
|
49
|
+
item = item.delete
|
50
|
+
assert_requested :delete,
|
51
|
+
"#{Stripe.api_base}/v1/invoiceitems/#{FIXTURE[:id]}"
|
52
|
+
assert item.kind_of?(Stripe::InvoiceItem)
|
17
53
|
end
|
18
54
|
end
|
19
55
|
end
|
data/test/stripe/invoice_test.rb
CHANGED
@@ -2,65 +2,65 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class InvoiceTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
@mock.expects(:get).once.returns(make_response(make_invoice))
|
7
|
-
i = Stripe::Invoice.retrieve('in_test_invoice')
|
8
|
-
assert_equal 'in_test_invoice', i.id
|
9
|
-
end
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:invoice)
|
10
6
|
|
11
|
-
should "
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
should "be listable" do
|
8
|
+
invoices = Stripe::Invoice.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/invoices"
|
10
|
+
assert invoices.data.kind_of?(Array)
|
11
|
+
assert invoices.first.kind_of?(Stripe::Invoice)
|
15
12
|
end
|
16
13
|
|
17
|
-
should "
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
@mock.expects(:post).once.with('https://api.stripe.com/v1/invoices/in_test_invoice/pay', nil, '').returns(make_response(make_paid_invoice))
|
22
|
-
i.pay
|
23
|
-
assert_equal nil, i.next_payment_attempt
|
14
|
+
should "be retrievable" do
|
15
|
+
invoice = Stripe::Invoice.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/invoices/#{FIXTURE[:id]}"
|
17
|
+
assert invoice.kind_of?(Stripe::Invoice)
|
24
18
|
end
|
25
19
|
|
26
|
-
should "
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
20
|
+
should "be creatable" do
|
21
|
+
invoice = Stripe::Invoice.create(
|
22
|
+
:customer => API_FIXTURES[:customer][:id]
|
23
|
+
)
|
24
|
+
assert_requested :post, "#{Stripe.api_base}/v1/invoices"
|
25
|
+
assert invoice.kind_of?(Stripe::Invoice)
|
32
26
|
end
|
33
27
|
|
34
|
-
should "
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
Stripe.
|
39
|
-
opts[:url] == "#{Stripe.api_base}/v1/invoices/in_test_invoice/pay" &&
|
40
|
-
opts[:method] == :post &&
|
41
|
-
opts[:headers]['Authorization'] == 'Bearer foobar'
|
42
|
-
end.returns(make_response(make_paid_invoice))
|
43
|
-
|
44
|
-
i.pay
|
45
|
-
assert_equal nil, i.next_payment_attempt
|
28
|
+
should "be saveable" do
|
29
|
+
invoice = Stripe::Invoice.retrieve(FIXTURE[:id])
|
30
|
+
invoice.metadata['key'] = 'value'
|
31
|
+
invoice.save
|
32
|
+
assert_requested :post, "#{Stripe.api_base}/v1/invoices/#{FIXTURE[:id]}"
|
46
33
|
end
|
47
34
|
|
48
|
-
should "be
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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')))
|
35
|
+
should "be updateable" do
|
36
|
+
invoice = Stripe::Invoice.update(FIXTURE[:id], metadata: { key: 'value' })
|
37
|
+
assert_requested :post, "#{Stripe.api_base}/v1/invoices/#{FIXTURE[:id]}"
|
38
|
+
assert invoice.kind_of?(Stripe::Invoice)
|
39
|
+
end
|
55
40
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
41
|
+
context "#pay" do
|
42
|
+
should "pay invoice" do
|
43
|
+
invoice = Stripe::Invoice.retrieve(FIXTURE[:id])
|
44
|
+
invoice = invoice.pay
|
45
|
+
assert_requested :post,
|
46
|
+
"#{Stripe.api_base}/v1/invoices/#{FIXTURE[:id]}/pay"
|
47
|
+
assert invoice.kind_of?(Stripe::Invoice)
|
48
|
+
end
|
49
|
+
end
|
61
50
|
|
62
|
-
|
63
|
-
|
51
|
+
context "#upcoming" do
|
52
|
+
should "retrieve upcoming invoices" do
|
53
|
+
invoice = Stripe::Invoice.upcoming(
|
54
|
+
customer: API_FIXTURES[:customer][:id],
|
55
|
+
subscription: API_FIXTURES[:subscription][:id]
|
56
|
+
)
|
57
|
+
assert_requested :get, "#{Stripe.api_base}/v1/invoices/upcoming",
|
58
|
+
query: {
|
59
|
+
customer: API_FIXTURES[:customer][:id],
|
60
|
+
subscription: API_FIXTURES[:subscription][:id]
|
61
|
+
}
|
62
|
+
assert invoice.kind_of?(Stripe::Invoice)
|
63
|
+
end
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -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
|
@@ -36,8 +38,9 @@ module Stripe
|
|
36
38
|
:has_more => true,
|
37
39
|
:url => "/things",
|
38
40
|
})
|
39
|
-
|
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 }))
|
41
44
|
|
42
45
|
assert_equal expected, list.auto_paging_each.to_a
|
43
46
|
end
|
@@ -55,8 +58,9 @@ module Stripe
|
|
55
58
|
:has_more => true,
|
56
59
|
:url => "/things",
|
57
60
|
})
|
58
|
-
|
59
|
-
|
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 }))
|
60
64
|
|
61
65
|
actual = []
|
62
66
|
list.auto_paging_each do |obj|
|
@@ -83,8 +87,9 @@ module Stripe
|
|
83
87
|
:has_more => true,
|
84
88
|
:url => "/things",
|
85
89
|
})
|
86
|
-
|
87
|
-
|
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 }))
|
88
93
|
next_list = list.next_page
|
89
94
|
refute next_list.empty?
|
90
95
|
end
|
@@ -96,15 +101,9 @@ module Stripe
|
|
96
101
|
:url => "/things",
|
97
102
|
})
|
98
103
|
list.filters = { :expand => ['data.source'], :limit => 3 }
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
u.host == URI.parse(Stripe.api_base).host && u.path == "/things" && params == {
|
103
|
-
"expand[]" => ["data.source"],
|
104
|
-
"limit" => ["3"],
|
105
|
-
"starting_after" => ["1"],
|
106
|
-
}
|
107
|
-
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 }))
|
108
107
|
next_list = list.next_page
|
109
108
|
assert_equal({ :expand => ['data.source'], :limit => 3 }, next_list.filters)
|
110
109
|
end
|
@@ -128,8 +127,9 @@ module Stripe
|
|
128
127
|
:data => [{ :id => 2 }],
|
129
128
|
:url => "/things",
|
130
129
|
})
|
131
|
-
|
132
|
-
|
130
|
+
stub_request(:get, "#{Stripe.api_base}/things").
|
131
|
+
with(query: { ending_before: "2" }).
|
132
|
+
to_return(body: JSON.generate({ :data => [{ :id => 1 }] }))
|
133
133
|
next_list = list.previous_page
|
134
134
|
refute next_list.empty?
|
135
135
|
end
|
@@ -140,17 +140,9 @@ module Stripe
|
|
140
140
|
:url => "/things",
|
141
141
|
})
|
142
142
|
list.filters = { :expand => ['data.source'], :limit => 3 }
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
u = URI.parse(url)
|
147
|
-
params = CGI.parse(query)
|
148
|
-
u.host == URI.parse(Stripe.api_base).host && u.path == "/things" && params == {
|
149
|
-
"ending_before" => ["2"],
|
150
|
-
"expand[]" => ["data.source"],
|
151
|
-
"limit" => ["3"],
|
152
|
-
}
|
153
|
-
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 }] }))
|
154
146
|
next_list = list.previous_page
|
155
147
|
assert_equal({ :expand => ['data.source'], :limit => 3 }, next_list.filters)
|
156
148
|
end
|
@@ -162,7 +154,6 @@ module Stripe
|
|
162
154
|
# note that the name #all is deprecated, as is using it fetch the next page
|
163
155
|
# in a list
|
164
156
|
should "be able to retrieve full lists given a listobject" do
|
165
|
-
@mock.expects(:get).twice.returns(make_response(make_charge_array))
|
166
157
|
c = Stripe::Charge.all
|
167
158
|
assert c.kind_of?(Stripe::ListObject)
|
168
159
|
assert_equal('/v1/charges', c.resource_url)
|
@@ -2,24 +2,20 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class OrderReturnTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
@mock.expects(:get).once.returns(make_response(make_order_return_array))
|
7
|
-
returns = Stripe::OrderReturn.list
|
8
|
-
assert returns.data.kind_of?(Array)
|
9
|
-
returns.each do |ret|
|
10
|
-
assert ret.kind_of?(Stripe::OrderReturn)
|
11
|
-
end
|
12
|
-
end
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:order_return)
|
13
6
|
|
14
|
-
should "
|
15
|
-
|
16
|
-
|
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)
|
17
12
|
end
|
18
13
|
|
19
|
-
should "
|
20
|
-
|
21
|
-
|
22
|
-
|
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)
|
23
19
|
end
|
24
20
|
end
|
25
21
|
end
|
data/test/stripe/order_test.rb
CHANGED
@@ -2,71 +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
|
-
p.delete
|
19
|
-
end
|
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)
|
20
18
|
end
|
21
19
|
|
22
|
-
should "
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
p.save
|
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)
|
29
26
|
end
|
30
27
|
|
31
|
-
should "
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
assert_equal('fulfilled', ii.status)
|
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]}"
|
37
33
|
end
|
38
34
|
|
39
|
-
should "
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
p.refresh
|
44
|
-
p.metadata['key'] = 'value'
|
45
|
-
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)
|
46
39
|
end
|
47
40
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
with('https://api.stripe.com/v1/orders/or_test_order/pay', nil, 'token=test_token').
|
55
|
-
returns(make_response(make_paid_order))
|
56
|
-
order.pay(:token => 'test_token')
|
57
|
-
assert_equal "paid", order.status
|
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
|
58
47
|
end
|
59
48
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
order_return = order.return_order(:items => [{:parent => 'sku_foo'}])
|
69
|
-
assert_equal order.id, order_return.order
|
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
|
70
57
|
end
|
71
58
|
end
|
72
59
|
end
|