stripe 2.0.3 → 5.55.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +1036 -0
- data/CODE_OF_CONDUCT.md +77 -0
- data/Gemfile +24 -23
- data/History.txt +1 -593
- data/Makefile +7 -0
- data/README.md +252 -53
- data/Rakefile +18 -24
- data/VERSION +1 -1
- data/bin/stripe-console +5 -3
- data/lib/stripe/api_operations/create.rb +4 -2
- data/lib/stripe/api_operations/delete.rb +31 -3
- data/lib/stripe/api_operations/list.rb +4 -13
- data/lib/stripe/api_operations/nested_resource.rb +73 -0
- data/lib/stripe/api_operations/request.rb +92 -10
- data/lib/stripe/api_operations/save.rb +25 -13
- data/lib/stripe/api_operations/search.rb +19 -0
- data/lib/stripe/api_resource.rb +55 -11
- data/lib/stripe/api_resource_test_helpers.rb +47 -0
- data/lib/stripe/connection_manager.rb +200 -0
- data/lib/stripe/error_object.rb +93 -0
- data/lib/stripe/errors.rb +98 -13
- data/lib/stripe/instrumentation.rb +84 -0
- data/lib/stripe/list_object.rb +55 -21
- data/lib/stripe/multipart_encoder.rb +131 -0
- data/lib/stripe/oauth.rb +65 -0
- data/lib/stripe/object_types.rb +119 -0
- data/lib/stripe/{account.rb → resources/account.rb} +75 -38
- data/lib/stripe/resources/account_link.rb +10 -0
- data/lib/stripe/resources/alipay_account.rb +34 -0
- data/lib/stripe/{apple_pay_domain.rb → resources/apple_pay_domain.rb} +6 -1
- data/lib/stripe/resources/application_fee.rb +14 -0
- data/lib/stripe/resources/application_fee_refund.rb +31 -0
- data/lib/stripe/resources/balance.rb +8 -0
- data/lib/stripe/resources/balance_transaction.rb +10 -0
- data/lib/stripe/resources/bank_account.rb +43 -0
- data/lib/stripe/resources/billing_portal/configuration.rb +14 -0
- data/lib/stripe/resources/billing_portal/session.rb +12 -0
- data/lib/stripe/{bitcoin_receiver.rb → resources/bitcoin_receiver.rb} +8 -4
- data/lib/stripe/resources/bitcoin_transaction.rb +16 -0
- data/lib/stripe/resources/capability.rb +34 -0
- data/lib/stripe/resources/card.rb +38 -0
- data/lib/stripe/resources/cash_balance.rb +22 -0
- data/lib/stripe/resources/charge.rb +32 -0
- data/lib/stripe/resources/checkout/session.rb +27 -0
- data/lib/stripe/resources/country_spec.rb +10 -0
- data/lib/stripe/{coupon.rb → resources/coupon.rb} +6 -1
- data/lib/stripe/resources/credit_note.rb +33 -0
- data/lib/stripe/resources/credit_note_line_item.rb +8 -0
- data/lib/stripe/resources/customer.rb +74 -0
- data/lib/stripe/resources/customer_balance_transaction.rb +31 -0
- data/lib/stripe/resources/discount.rb +8 -0
- data/lib/stripe/resources/dispute.rb +22 -0
- data/lib/stripe/resources/ephemeral_key.rb +20 -0
- data/lib/stripe/resources/event.rb +10 -0
- data/lib/stripe/resources/exchange_rate.rb +10 -0
- data/lib/stripe/resources/file.rb +36 -0
- data/lib/stripe/resources/file_link.rb +12 -0
- data/lib/stripe/resources/financial_connections/account.rb +31 -0
- data/lib/stripe/resources/financial_connections/account_owner.rb +10 -0
- data/lib/stripe/resources/financial_connections/account_ownership.rb +10 -0
- data/lib/stripe/resources/financial_connections/session.rb +12 -0
- data/lib/stripe/resources/funding_instructions.rb +16 -0
- data/lib/stripe/resources/identity/verification_report.rb +12 -0
- data/lib/stripe/resources/identity/verification_session.rb +35 -0
- data/lib/stripe/resources/invoice.rb +83 -0
- data/lib/stripe/{invoice_item.rb → resources/invoice_item.rb} +6 -1
- data/lib/stripe/resources/invoice_line_item.rb +8 -0
- data/lib/stripe/resources/issuing/authorization.rb +34 -0
- data/lib/stripe/resources/issuing/card.rb +25 -0
- data/lib/stripe/resources/issuing/card_details.rb +10 -0
- data/lib/stripe/resources/issuing/cardholder.rb +14 -0
- data/lib/stripe/resources/issuing/dispute.rb +25 -0
- data/lib/stripe/resources/issuing/transaction.rb +13 -0
- data/lib/stripe/resources/line_item.rb +8 -0
- data/lib/stripe/resources/login_link.rb +15 -0
- data/lib/stripe/resources/mandate.rb +8 -0
- data/lib/stripe/resources/order.rb +33 -0
- data/lib/stripe/resources/order_return.rb +10 -0
- data/lib/stripe/resources/payment_intent.rb +82 -0
- data/lib/stripe/resources/payment_link.rb +23 -0
- data/lib/stripe/resources/payment_method.rb +33 -0
- data/lib/stripe/resources/payout.rb +33 -0
- data/lib/stripe/resources/person.rb +32 -0
- data/lib/stripe/{plan.rb → resources/plan.rb} +5 -0
- data/lib/stripe/resources/price.rb +21 -0
- data/lib/stripe/resources/product.rb +22 -0
- data/lib/stripe/resources/promotion_code.rb +12 -0
- data/lib/stripe/resources/quote.rb +105 -0
- data/lib/stripe/resources/radar/early_fraud_warning.rb +12 -0
- data/lib/stripe/resources/radar/value_list.rb +15 -0
- data/lib/stripe/resources/radar/value_list_item.rb +14 -0
- data/lib/stripe/resources/recipient.rb +14 -0
- data/lib/stripe/resources/recipient_transfer.rb +7 -0
- data/lib/stripe/resources/refund.rb +42 -0
- data/lib/stripe/resources/reporting/report_run.rb +13 -0
- data/lib/stripe/resources/reporting/report_type.rb +13 -0
- data/lib/stripe/resources/reversal.rb +30 -0
- data/lib/stripe/resources/review.rb +21 -0
- data/lib/stripe/resources/setup_attempt.rb +10 -0
- data/lib/stripe/resources/setup_intent.rb +43 -0
- data/lib/stripe/resources/shipping_rate.rb +12 -0
- data/lib/stripe/resources/sigma/scheduled_query_run.rb +16 -0
- data/lib/stripe/{sku.rb → resources/sku.rb} +7 -2
- data/lib/stripe/resources/source.rb +47 -0
- data/lib/stripe/resources/source_transaction.rb +8 -0
- data/lib/stripe/resources/subscription.rb +35 -0
- data/lib/stripe/resources/subscription_item.rb +26 -0
- data/lib/stripe/resources/subscription_schedule.rb +33 -0
- data/lib/stripe/resources/tax_code.rb +10 -0
- data/lib/stripe/resources/tax_id.rb +27 -0
- data/lib/stripe/{product.rb → resources/tax_rate.rb} +7 -3
- data/lib/stripe/resources/terminal/configuration.rb +15 -0
- data/lib/stripe/resources/terminal/connection_token.rb +12 -0
- data/lib/stripe/resources/terminal/location.rb +15 -0
- data/lib/stripe/resources/terminal/reader.rb +75 -0
- data/lib/stripe/resources/test_helpers/test_clock.rb +25 -0
- data/lib/stripe/{three_d_secure.rb → resources/three_d_secure.rb} +5 -0
- data/lib/stripe/resources/token.rb +10 -0
- data/lib/stripe/resources/topup.rb +23 -0
- data/lib/stripe/resources/transfer.rb +27 -0
- data/lib/stripe/resources/usage_record.rb +8 -0
- data/lib/stripe/resources/usage_record_summary.rb +8 -0
- data/lib/stripe/{recipient.rb → resources/webhook_endpoint.rb} +6 -5
- data/lib/stripe/resources.rb +100 -0
- data/lib/stripe/search_result_object.rb +86 -0
- data/lib/stripe/singleton_api_resource.rb +10 -4
- data/lib/stripe/stripe_client.rb +886 -223
- data/lib/stripe/stripe_configuration.rb +194 -0
- data/lib/stripe/stripe_object.rb +301 -132
- data/lib/stripe/stripe_response.rb +89 -27
- data/lib/stripe/util.rb +272 -122
- data/lib/stripe/version.rb +3 -1
- data/lib/stripe/webhook.rb +121 -0
- data/lib/stripe.rb +94 -116
- data/stripe.gemspec +35 -16
- metadata +127 -156
- data/.gitattributes +0 -4
- data/.github/ISSUE_TEMPLATE.md +0 -5
- data/.gitignore +0 -5
- data/.travis.yml +0 -15
- data/lib/stripe/alipay_account.rb +0 -20
- data/lib/stripe/application_fee.rb +0 -20
- data/lib/stripe/application_fee_refund.rb +0 -18
- data/lib/stripe/balance.rb +0 -4
- data/lib/stripe/balance_transaction.rb +0 -9
- data/lib/stripe/bank_account.rb +0 -28
- data/lib/stripe/bitcoin_transaction.rb +0 -9
- data/lib/stripe/card.rb +0 -25
- data/lib/stripe/charge.rb +0 -80
- data/lib/stripe/country_spec.rb +0 -9
- data/lib/stripe/customer.rb +0 -77
- data/lib/stripe/dispute.rb +0 -15
- data/lib/stripe/event.rb +0 -5
- data/lib/stripe/file_upload.rb +0 -31
- data/lib/stripe/invoice.rb +0 -27
- data/lib/stripe/order.rb +0 -27
- data/lib/stripe/order_return.rb +0 -9
- data/lib/stripe/refund.rb +0 -7
- data/lib/stripe/reversal.rb +0 -18
- data/lib/stripe/source.rb +0 -11
- data/lib/stripe/subscription.rb +0 -31
- data/lib/stripe/subscription_item.rb +0 -12
- data/lib/stripe/token.rb +0 -5
- data/lib/stripe/transfer.rb +0 -16
- data/openapi/fixtures.json +0 -1383
- data/openapi/fixtures.yaml +0 -1130
- data/openapi/spec.json +0 -19749
- data/openapi/spec.yaml +0 -15359
- data/test/api_fixtures.rb +0 -29
- data/test/api_stub_helpers.rb +0 -125
- data/test/stripe/account_test.rb +0 -204
- data/test/stripe/alipay_account_test.rb +0 -19
- data/test/stripe/api_operations_test.rb +0 -31
- data/test/stripe/api_resource_test.rb +0 -496
- data/test/stripe/apple_pay_domain_test.rb +0 -33
- data/test/stripe/application_fee_refund_test.rb +0 -38
- data/test/stripe/application_fee_test.rb +0 -14
- data/test/stripe/balance_test.rb +0 -11
- data/test/stripe/bank_account_test.rb +0 -41
- data/test/stripe/bitcoin_receiver_test.rb +0 -70
- data/test/stripe/bitcoin_transaction_test.rb +0 -21
- data/test/stripe/charge_test.rb +0 -59
- data/test/stripe/country_spec_test.rb +0 -20
- data/test/stripe/coupon_test.rb +0 -44
- data/test/stripe/customer_card_test.rb +0 -42
- data/test/stripe/customer_test.rb +0 -116
- data/test/stripe/dispute_test.rb +0 -42
- data/test/stripe/errors_test.rb +0 -18
- data/test/stripe/file_upload_test.rb +0 -66
- data/test/stripe/invoice_item_test.rb +0 -55
- data/test/stripe/invoice_test.rb +0 -66
- data/test/stripe/list_object_test.rb +0 -170
- data/test/stripe/order_return_test.rb +0 -21
- data/test/stripe/order_test.rb +0 -59
- data/test/stripe/plan_test.rb +0 -52
- data/test/stripe/product_test.rb +0 -47
- data/test/stripe/recipient_card_test.rb +0 -40
- data/test/stripe/recipient_test.rb +0 -50
- data/test/stripe/refund_test.rb +0 -39
- data/test/stripe/reversal_test.rb +0 -43
- data/test/stripe/sku_test.rb +0 -50
- data/test/stripe/source_test.rb +0 -43
- data/test/stripe/stripe_client_test.rb +0 -440
- data/test/stripe/stripe_object_test.rb +0 -361
- data/test/stripe/stripe_response_test.rb +0 -46
- data/test/stripe/subscription_item_test.rb +0 -54
- data/test/stripe/subscription_test.rb +0 -60
- data/test/stripe/three_d_secure_test.rb +0 -23
- data/test/stripe/transfer_test.rb +0 -50
- data/test/stripe/util_test.rb +0 -149
- data/test/stripe_test.rb +0 -41
- data/test/test_data.rb +0 -59
- data/test/test_helper.rb +0 -41
@@ -1,170 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class ListObjectTest < Test::Unit::TestCase
|
5
|
-
should "provide .empty_list" do
|
6
|
-
list = Stripe::ListObject.empty_list
|
7
|
-
assert list.empty?
|
8
|
-
end
|
9
|
-
|
10
|
-
should "provide #count via enumerable" do
|
11
|
-
list = Stripe::ListObject.construct_from({
|
12
|
-
data: [API_FIXTURES.fetch(:charge)]
|
13
|
-
})
|
14
|
-
assert_equal 1, list.count
|
15
|
-
end
|
16
|
-
|
17
|
-
should "provide #each" do
|
18
|
-
arr = [
|
19
|
-
{ :id => 1 },
|
20
|
-
{ :id => 2 },
|
21
|
-
{ :id => 3 },
|
22
|
-
]
|
23
|
-
expected = Util.convert_to_stripe_object(arr, {})
|
24
|
-
list = Stripe::ListObject.construct_from({ :data => arr })
|
25
|
-
assert_equal expected, list.each.to_a
|
26
|
-
end
|
27
|
-
|
28
|
-
should "provide #auto_paging_each" do
|
29
|
-
arr = [
|
30
|
-
{ :id => 1 },
|
31
|
-
{ :id => 2 },
|
32
|
-
{ :id => 3 },
|
33
|
-
]
|
34
|
-
expected = Util.convert_to_stripe_object(arr, {})
|
35
|
-
|
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 }))
|
44
|
-
|
45
|
-
assert_equal expected, list.auto_paging_each.to_a
|
46
|
-
end
|
47
|
-
|
48
|
-
should "provide #auto_paging_each that responds to a block" do
|
49
|
-
arr = [
|
50
|
-
{ :id => 1 },
|
51
|
-
{ :id => 2 },
|
52
|
-
{ :id => 3 },
|
53
|
-
]
|
54
|
-
expected = Util.convert_to_stripe_object(arr, {})
|
55
|
-
|
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 }))
|
64
|
-
|
65
|
-
actual = []
|
66
|
-
list.auto_paging_each do |obj|
|
67
|
-
actual << obj
|
68
|
-
end
|
69
|
-
|
70
|
-
assert_equal expected, actual
|
71
|
-
end
|
72
|
-
|
73
|
-
should "provide #empty?" do
|
74
|
-
list = Stripe::ListObject.construct_from({ :data => [] })
|
75
|
-
assert list.empty?
|
76
|
-
list = Stripe::ListObject.construct_from({ :data => [{}] })
|
77
|
-
refute list.empty?
|
78
|
-
end
|
79
|
-
|
80
|
-
#
|
81
|
-
# next_page
|
82
|
-
#
|
83
|
-
|
84
|
-
should "fetch a next page through #next_page" do
|
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 }))
|
93
|
-
next_list = list.next_page
|
94
|
-
refute next_list.empty?
|
95
|
-
end
|
96
|
-
|
97
|
-
should "fetch a next page through #next_page and respect limit" do
|
98
|
-
list = TestListObject.construct_from({
|
99
|
-
:data => [{ :id => 1 }],
|
100
|
-
:has_more => true,
|
101
|
-
:url => "/things",
|
102
|
-
})
|
103
|
-
list.filters = { :expand => ['data.source'], :limit => 3 }
|
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 }))
|
107
|
-
next_list = list.next_page
|
108
|
-
assert_equal({ :expand => ['data.source'], :limit => 3 }, next_list.filters)
|
109
|
-
end
|
110
|
-
|
111
|
-
should "fetch an empty page through #next_page" do
|
112
|
-
list = TestListObject.construct_from({
|
113
|
-
:data => [{ :id => 1 }],
|
114
|
-
:has_more => false,
|
115
|
-
:url => "/things",
|
116
|
-
})
|
117
|
-
next_list = list.next_page
|
118
|
-
assert_equal Stripe::ListObject.empty_list, next_list
|
119
|
-
end
|
120
|
-
|
121
|
-
#
|
122
|
-
# previous_page
|
123
|
-
#
|
124
|
-
|
125
|
-
should "fetch a next page through #previous_page" do
|
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 }] }))
|
133
|
-
next_list = list.previous_page
|
134
|
-
refute next_list.empty?
|
135
|
-
end
|
136
|
-
|
137
|
-
should "fetch a next page through #previous_page and respect limit" do
|
138
|
-
list = TestListObject.construct_from({
|
139
|
-
:data => [{ :id => 2 }],
|
140
|
-
:url => "/things",
|
141
|
-
})
|
142
|
-
list.filters = { :expand => ['data.source'], :limit => 3 }
|
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 }] }))
|
146
|
-
next_list = list.previous_page
|
147
|
-
assert_equal({ :expand => ['data.source'], :limit => 3 }, next_list.filters)
|
148
|
-
end
|
149
|
-
|
150
|
-
#
|
151
|
-
# backward compatibility
|
152
|
-
#
|
153
|
-
|
154
|
-
# note that the name #all is deprecated, as is using it fetch the next page
|
155
|
-
# in a list
|
156
|
-
should "be able to retrieve full lists given a listobject" do
|
157
|
-
c = Stripe::Charge.all
|
158
|
-
assert c.kind_of?(Stripe::ListObject)
|
159
|
-
assert_equal('/v1/charges', c.resource_url)
|
160
|
-
all = c.all
|
161
|
-
assert all.kind_of?(Stripe::ListObject)
|
162
|
-
assert_equal('/v1/charges', all.resource_url)
|
163
|
-
assert all.data.kind_of?(Array)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
# A helper class with a URL that allows us to try out pagination.
|
169
|
-
class TestListObject < Stripe::ListObject
|
170
|
-
end
|
@@ -1,21 +0,0 @@
|
|
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
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class OrderTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:order)
|
6
|
-
|
7
|
-
should "be listable" do
|
8
|
-
orders = Stripe::Order.list
|
9
|
-
assert_requested :get, "#{Stripe.api_base}/v1/orders"
|
10
|
-
assert orders.data.kind_of?(Array)
|
11
|
-
assert orders.first.kind_of?(Stripe::Order)
|
12
|
-
end
|
13
|
-
|
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)
|
26
|
-
end
|
27
|
-
|
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]}"
|
33
|
-
end
|
34
|
-
|
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)
|
39
|
-
end
|
40
|
-
|
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
|
48
|
-
|
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
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
data/test/stripe/plan_test.rb
DELETED
@@ -1,52 +0,0 @@
|
|
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
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class ProductTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:product)
|
6
|
-
|
7
|
-
should "be listable" do
|
8
|
-
products = Stripe::Product.list
|
9
|
-
assert_requested :get, "#{Stripe.api_base}/v1/products"
|
10
|
-
assert products.data.kind_of?(Array)
|
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)
|
18
|
-
end
|
19
|
-
|
20
|
-
should "be creatable" do
|
21
|
-
_ = Stripe::Product.create(
|
22
|
-
name: "My Product"
|
23
|
-
)
|
24
|
-
assert_requested :post, "#{Stripe.api_base}/v1/products"
|
25
|
-
end
|
26
|
-
|
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]}"
|
32
|
-
end
|
33
|
-
|
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
|
-
end
|
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
|
46
|
-
end
|
47
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class RecipientCardTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:source)
|
6
|
-
|
7
|
-
setup do
|
8
|
-
@recipient =
|
9
|
-
Stripe::Recipient.retrieve(API_FIXTURES.fetch(:transfer_recipient)[:id])
|
10
|
-
end
|
11
|
-
|
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::Card)
|
16
|
-
end
|
17
|
-
|
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::Card)
|
24
|
-
end
|
25
|
-
|
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)
|
31
|
-
end
|
32
|
-
|
33
|
-
should "be saveable" do
|
34
|
-
card = Stripe::Card.construct_from(FIXTURE.merge(recipient: @recipient.id))
|
35
|
-
card.metadata['key'] = 'value'
|
36
|
-
card.save
|
37
|
-
assert_requested :post, "#{Stripe.api_base}/v1/recipients/#{@recipient.id}/cards/#{FIXTURE[:id]}"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,50 +0,0 @@
|
|
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
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class RefundTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:refund)
|
6
|
-
|
7
|
-
should "be listable" do
|
8
|
-
refunds = Stripe::Refund.list
|
9
|
-
assert_requested :get, "#{Stripe.api_base}/v1/refunds"
|
10
|
-
assert refunds.data.kind_of?(Array)
|
11
|
-
assert refunds.first.kind_of?(Stripe::Refund)
|
12
|
-
end
|
13
|
-
|
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)
|
18
|
-
end
|
19
|
-
|
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
|
25
|
-
|
26
|
-
should "be saveable" do
|
27
|
-
refund = Stripe::Refund.retrieve(FIXTURE[:id])
|
28
|
-
refund.metadata['key'] = 'value'
|
29
|
-
refund.save
|
30
|
-
assert_requested :post, "#{Stripe.api_base}/v1/refunds/#{FIXTURE[:id]}"
|
31
|
-
end
|
32
|
-
|
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)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class ReversalTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:transfer_reversal)
|
6
|
-
|
7
|
-
setup do
|
8
|
-
@transfer = Stripe::Transfer.retrieve(API_FIXTURES.fetch(:transfer)[:id])
|
9
|
-
end
|
10
|
-
|
11
|
-
should "be listable" do
|
12
|
-
reversals = @transfer.reversals.list
|
13
|
-
assert_requested :get,
|
14
|
-
"#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals"
|
15
|
-
assert reversals.data.kind_of?(Array)
|
16
|
-
assert reversals.data[0].kind_of?(Stripe::Reversal)
|
17
|
-
end
|
18
|
-
|
19
|
-
should "be retrievable" do
|
20
|
-
reversal = @transfer.reversals.retrieve(FIXTURE[:id])
|
21
|
-
assert_requested :get,
|
22
|
-
"#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals/#{FIXTURE[:id]}"
|
23
|
-
assert reversal.kind_of?(Stripe::Reversal)
|
24
|
-
end
|
25
|
-
|
26
|
-
should "be creatable" do
|
27
|
-
reversal = @transfer.reversals.create(
|
28
|
-
amount: 100
|
29
|
-
)
|
30
|
-
assert_requested :post,
|
31
|
-
"#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals"
|
32
|
-
assert reversal.kind_of?(Stripe::Reversal)
|
33
|
-
end
|
34
|
-
|
35
|
-
should "be saveable" do
|
36
|
-
reversal = @transfer.reversals.retrieve(FIXTURE[:id])
|
37
|
-
reversal.metadata['key'] = 'value'
|
38
|
-
reversal.save
|
39
|
-
assert_requested :post,
|
40
|
-
"#{Stripe.api_base}/v1/transfers/#{@transfer.id}/reversals/#{FIXTURE[:id]}"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/test/stripe/sku_test.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class SKUTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:sku)
|
6
|
-
|
7
|
-
should "be listable" do
|
8
|
-
skus = Stripe::SKU.list
|
9
|
-
assert_requested :get, "#{Stripe.api_base}/v1/skus"
|
10
|
-
assert skus.data.kind_of?(Array)
|
11
|
-
assert skus.data[0].kind_of?(Stripe::SKU)
|
12
|
-
end
|
13
|
-
|
14
|
-
should "be retrievable" do
|
15
|
-
sku = Stripe::SKU.retrieve(FIXTURE[:id])
|
16
|
-
assert_requested :get, "#{Stripe.api_base}/v1/skus/#{FIXTURE[:id]}"
|
17
|
-
assert sku.kind_of?(Stripe::SKU)
|
18
|
-
end
|
19
|
-
|
20
|
-
should "be creatable" do
|
21
|
-
_ = Stripe::SKU.create(
|
22
|
-
currency: "USD",
|
23
|
-
inventory: { type: "finite", quantity: 500 },
|
24
|
-
price: 100,
|
25
|
-
product: API_FIXTURES.fetch(:product)[:id]
|
26
|
-
)
|
27
|
-
assert_requested :post, "#{Stripe.api_base}/v1/skus"
|
28
|
-
end
|
29
|
-
|
30
|
-
should "be saveable" do
|
31
|
-
sku = Stripe::SKU.retrieve(FIXTURE[:id])
|
32
|
-
sku.metadata['key'] = 'value'
|
33
|
-
sku.save
|
34
|
-
assert_requested :post, "#{Stripe.api_base}/v1/skus/#{FIXTURE[:id]}"
|
35
|
-
end
|
36
|
-
|
37
|
-
should "be updateable" do
|
38
|
-
sku = Stripe::SKU.update(FIXTURE[:id], metadata: {foo: 'bar'})
|
39
|
-
assert_requested :post, "#{Stripe.api_base}/v1/skus/#{FIXTURE[:id]}"
|
40
|
-
assert sku.kind_of?(Stripe::SKU)
|
41
|
-
end
|
42
|
-
|
43
|
-
should "be deletable" do
|
44
|
-
sku = Stripe::SKU.retrieve(FIXTURE[:id])
|
45
|
-
sku = sku.delete
|
46
|
-
assert_requested :delete, "#{Stripe.api_base}/v1/skus/#{FIXTURE[:id]}"
|
47
|
-
assert sku.kind_of?(Stripe::SKU)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/test/stripe/source_test.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class SourceTest < Test::Unit::TestCase
|
5
|
-
FIXTURE = API_FIXTURES.fetch(:source)
|
6
|
-
|
7
|
-
should "be retrievable" do
|
8
|
-
source = Stripe::Source.retrieve(FIXTURE[:id])
|
9
|
-
assert_requested :get, "#{Stripe.api_base}/v1/sources/#{FIXTURE[:id]}"
|
10
|
-
assert source.kind_of?(Stripe::Source)
|
11
|
-
end
|
12
|
-
|
13
|
-
should "be creatable" do
|
14
|
-
source = Stripe::Source.create(
|
15
|
-
type: 'card',
|
16
|
-
token: API_FIXTURES.fetch(:token)[:id]
|
17
|
-
)
|
18
|
-
assert_requested :post, "#{Stripe.api_base}/v1/sources"
|
19
|
-
assert source.kind_of?(Stripe::Card)
|
20
|
-
end
|
21
|
-
|
22
|
-
should "be saveable" do
|
23
|
-
source = Stripe::Source.retrieve(FIXTURE[:id])
|
24
|
-
source.metadata['key'] = 'value'
|
25
|
-
source.save
|
26
|
-
assert_requested :post, "#{Stripe.api_base}/v1/sources/#{FIXTURE[:id]}"
|
27
|
-
end
|
28
|
-
|
29
|
-
should "be updateable" do
|
30
|
-
source = Stripe::Source.update(FIXTURE[:id], metadata: {foo: 'bar'})
|
31
|
-
assert_requested :post, "#{Stripe.api_base}/v1/sources/#{FIXTURE[:id]}"
|
32
|
-
assert source.kind_of?(Stripe::Card)
|
33
|
-
end
|
34
|
-
|
35
|
-
context "#verify" do
|
36
|
-
should "verify the source" do
|
37
|
-
source = Stripe::Source.retrieve(FIXTURE[:id])
|
38
|
-
source = source.verify(:values => [1,2])
|
39
|
-
assert source.kind_of?(Stripe::Source)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|