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_test.rb
CHANGED
@@ -34,41 +34,8 @@ class StripeTest < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
should "
|
38
|
-
|
39
|
-
|
40
|
-
details_submitted: false,
|
41
|
-
email: "test+bindings@stripe.com"
|
42
|
-
)
|
43
|
-
Stripe.stripe_account = 'acct_1234'
|
44
|
-
|
45
|
-
Stripe.expects(:execute_request).with(
|
46
|
-
has_entry(:headers, has_entry('Stripe-Account', 'acct_1234')),
|
47
|
-
).returns(make_response(response))
|
48
|
-
|
49
|
-
Stripe.request(:post, '/v1/account', 'sk_live12334566')
|
50
|
-
end
|
51
|
-
|
52
|
-
context "#get_uname" do
|
53
|
-
should "run without failure" do
|
54
|
-
# Don't actually check the result because we try a variety of different
|
55
|
-
# strategies that will have different results depending on where this
|
56
|
-
# test and running. We're mostly making sure that no exception is thrown.
|
57
|
-
_ = Stripe.get_uname
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "#get_uname_from_system" do
|
62
|
-
should "run without failure" do
|
63
|
-
# as above, just verify that an exception is not thrown
|
64
|
-
_ = Stripe.get_uname_from_system
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context "#get_uname_from_system_ver" do
|
69
|
-
should "run without failure" do
|
70
|
-
# as above, just verify that an exception is not thrown
|
71
|
-
_ = Stripe.get_uname_from_system_ver
|
72
|
-
end
|
37
|
+
should "have default open and read timeouts" do
|
38
|
+
assert_equal Stripe.open_timeout, 30
|
39
|
+
assert_equal Stripe.read_timeout, 80
|
73
40
|
end
|
74
41
|
end
|
data/test/test_data.rb
CHANGED
@@ -1,542 +1,11 @@
|
|
1
1
|
module Stripe
|
2
2
|
module TestData
|
3
|
-
def
|
4
|
-
# When an exception is raised, restclient clobbers method_missing. Hence we
|
5
|
-
# can't just use the stubs interface.
|
6
|
-
body = JSON.generate(body) if !(body.kind_of? String)
|
7
|
-
m = mock
|
8
|
-
m.instance_variable_set('@stripe_values', {
|
9
|
-
:body => body,
|
10
|
-
:code => code,
|
11
|
-
:headers => {},
|
12
|
-
})
|
13
|
-
def m.body; @stripe_values[:body]; end
|
14
|
-
def m.code; @stripe_values[:code]; end
|
15
|
-
def m.headers; @stripe_values[:headers]; end
|
16
|
-
m
|
17
|
-
end
|
18
|
-
|
19
|
-
def make_account(params={})
|
20
|
-
{
|
21
|
-
:charges_enabled => false,
|
22
|
-
:details_submitted => false,
|
23
|
-
:email => "test+bindings@stripe.com",
|
24
|
-
}.merge(params)
|
25
|
-
end
|
26
|
-
|
27
|
-
def make_balance(params={})
|
28
|
-
{
|
29
|
-
:pending => [
|
30
|
-
{:amount => 12345, :currency => "usd"}
|
31
|
-
],
|
32
|
-
:available => [
|
33
|
-
{:amount => 6789, :currency => "usd"}
|
34
|
-
],
|
35
|
-
:livemode => false,
|
36
|
-
:object => "balance"
|
37
|
-
}.merge(params)
|
38
|
-
end
|
39
|
-
|
40
|
-
def make_balance_transaction(params={})
|
41
|
-
{
|
42
|
-
:amount => 100,
|
43
|
-
:net => 41,
|
44
|
-
:currency => "usd",
|
45
|
-
:type => "charge",
|
46
|
-
:created => 1371945005,
|
47
|
-
:available_on => 1372549805,
|
48
|
-
:status => "pending",
|
49
|
-
:description => "A test balance transaction",
|
50
|
-
:fee => 59,
|
51
|
-
:object => "balance_transaction"
|
52
|
-
}.merge(params)
|
53
|
-
end
|
54
|
-
|
55
|
-
def make_balance_transaction_array
|
56
|
-
{
|
57
|
-
:data => [make_balance_transaction, make_balance_transaction, make_balance_transaction],
|
58
|
-
:object => "list",
|
59
|
-
:resource_url => "/v1/balance/history"
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
def make_application_fee(params={})
|
64
|
-
id = params[:id] || 'fee_test_fee'
|
65
|
-
{
|
66
|
-
:refunded => false,
|
67
|
-
:amount => 100,
|
68
|
-
:application => "ca_test_application",
|
69
|
-
:user => "acct_test_user",
|
70
|
-
:charge => "ch_test_charge",
|
71
|
-
:id => id,
|
72
|
-
:livemode => false,
|
73
|
-
:currency => "usd",
|
74
|
-
:object => "application_fee",
|
75
|
-
:refunds => make_application_fee_refund_array(id),
|
76
|
-
:created => 1304114826
|
77
|
-
}.merge(params)
|
78
|
-
end
|
79
|
-
|
80
|
-
def make_application_fee_refund(params = {})
|
81
|
-
{
|
82
|
-
:object => 'fee_refund',
|
83
|
-
:amount => 30,
|
84
|
-
:currency => "usd",
|
85
|
-
:created => 1308595038,
|
86
|
-
:id => "ref_test_app_fee_refund",
|
87
|
-
:fee => "ca_test_application",
|
88
|
-
:metadata => {}
|
89
|
-
}.merge(params)
|
90
|
-
end
|
91
|
-
|
92
|
-
def make_application_fee_array
|
93
|
-
{
|
94
|
-
:data => [make_application_fee, make_application_fee, make_application_fee],
|
95
|
-
:object => 'list',
|
96
|
-
:resource_url => '/v1/application_fees'
|
97
|
-
}
|
98
|
-
end
|
99
|
-
|
100
|
-
def make_application_fee_refund_array(fee_id)
|
101
|
-
{
|
102
|
-
:data => [make_application_fee_refund, make_application_fee_refund, make_application_fee_refund],
|
103
|
-
:object => 'list',
|
104
|
-
:resource_url => '/v1/application_fees/' + fee_id + '/refunds'
|
105
|
-
}
|
106
|
-
end
|
107
|
-
|
108
|
-
def make_customer(params={})
|
109
|
-
id = params[:id] || 'c_test_customer'
|
110
|
-
{
|
111
|
-
:subscription_history => [],
|
112
|
-
:bills => [],
|
113
|
-
:charges => [],
|
114
|
-
:livemode => false,
|
115
|
-
:object => "customer",
|
116
|
-
:id => id,
|
117
|
-
:default_card => "cc_test_card",
|
118
|
-
:created => 1304114758,
|
119
|
-
:sources => make_customer_card_array(id),
|
120
|
-
:metadata => {},
|
121
|
-
:subscriptions => make_customer_subscription_array(id)
|
122
|
-
}.merge(params)
|
123
|
-
end
|
124
|
-
|
125
|
-
def make_customer_array
|
126
|
-
{
|
127
|
-
:data => [make_customer, make_customer, make_customer],
|
128
|
-
:object => 'list',
|
129
|
-
:resource_url => '/v1/customers'
|
130
|
-
}
|
131
|
-
end
|
132
|
-
|
133
|
-
def make_charge(params={})
|
134
|
-
id = params[:id] || 'ch_test_charge'
|
135
|
-
{
|
136
|
-
:refunded => false,
|
137
|
-
:paid => true,
|
138
|
-
:amount => 100,
|
139
|
-
:card => {
|
140
|
-
:type => "Visa",
|
141
|
-
:last4 => "4242",
|
142
|
-
:exp_month => 11,
|
143
|
-
:country => "US",
|
144
|
-
:exp_year => 2012,
|
145
|
-
:id => "cc_test_card",
|
146
|
-
:object => "card"
|
147
|
-
},
|
148
|
-
:id => id,
|
149
|
-
:reason => "execute_charge",
|
150
|
-
:livemode => false,
|
151
|
-
:currency => "usd",
|
152
|
-
:object => "charge",
|
153
|
-
:created => 1304114826,
|
154
|
-
:refunds => make_refund_array(id),
|
155
|
-
:metadata => {},
|
156
|
-
:outcome => {
|
157
|
-
type: 'authorized',
|
158
|
-
reason: nil,
|
159
|
-
seller_message: 'Payment complete.',
|
160
|
-
network_status: 'approved_by_network',
|
161
|
-
},
|
162
|
-
}.merge(params)
|
163
|
-
end
|
164
|
-
|
165
|
-
def make_charge_array
|
166
|
-
{
|
167
|
-
:data => [make_charge, make_charge, make_charge],
|
168
|
-
:object => 'list',
|
169
|
-
:resource_url => '/v1/charges'
|
170
|
-
}
|
171
|
-
end
|
172
|
-
|
173
|
-
def make_dispute(params={})
|
174
|
-
id = params[:id] || 'dp_test_dispute'
|
175
|
-
{
|
176
|
-
:id => id,
|
177
|
-
:charge => "ch_test_charge",
|
178
|
-
:amount => 500,
|
179
|
-
:created => 1304114758,
|
180
|
-
:status => 'needs_response',
|
181
|
-
:livemode => false,
|
182
|
-
:currency => 'usd',
|
183
|
-
:object => 'dispute',
|
184
|
-
:reason => 'fraudulent',
|
185
|
-
:evidence => {},
|
186
|
-
}.merge(params)
|
187
|
-
end
|
188
|
-
|
189
|
-
def make_dispute_array
|
190
|
-
{
|
191
|
-
:data => [make_dispute, make_dispute, make_dispute],
|
192
|
-
:object => 'list',
|
193
|
-
:resource_url => '/v1/disputes'
|
194
|
-
}
|
195
|
-
end
|
196
|
-
|
197
|
-
def make_recipient_card_array(recipient_id)
|
198
|
-
{
|
199
|
-
:data => [make_card, make_card, make_card],
|
200
|
-
:object => 'list',
|
201
|
-
:resource_url => '/v1/recipients/' + recipient_id + '/cards'
|
202
|
-
}
|
203
|
-
end
|
204
|
-
|
205
|
-
def make_customer_card_array(customer_id)
|
206
|
-
{
|
207
|
-
:data => [make_card, make_card, make_card],
|
208
|
-
:object => 'list',
|
209
|
-
:resource_url => '/v1/customers/' + customer_id + '/sources'
|
210
|
-
}
|
211
|
-
end
|
212
|
-
|
213
|
-
def make_card(params={})
|
214
|
-
{
|
215
|
-
:type => "Visa",
|
216
|
-
:last4 => "4242",
|
217
|
-
:exp_month => 11,
|
218
|
-
:country => "US",
|
219
|
-
:exp_year => 2012,
|
220
|
-
:id => "cc_test_card",
|
221
|
-
:customer => 'c_test_customer',
|
222
|
-
:object => "card"
|
223
|
-
}.merge(params)
|
224
|
-
end
|
225
|
-
|
226
|
-
def make_coupon(params={})
|
227
|
-
{
|
228
|
-
:duration => 'repeating',
|
229
|
-
:duration_in_months => 3,
|
230
|
-
:percent_off => 25,
|
231
|
-
:id => "co_test_coupon",
|
232
|
-
:object => "coupon",
|
233
|
-
:metadata => {},
|
234
|
-
}.merge(params)
|
235
|
-
end
|
236
|
-
|
237
|
-
def make_file(params={})
|
238
|
-
{
|
239
|
-
:object => "file_upload",
|
240
|
-
:id => "fil_test_file",
|
241
|
-
:created => 1403047735,
|
242
|
-
:size => 4908,
|
243
|
-
:purpose => params[:purpose] || "dispute_evidence",
|
244
|
-
:resource_url => nil,
|
245
|
-
:type => nil,
|
246
|
-
}
|
247
|
-
end
|
248
|
-
|
249
|
-
def make_file_array
|
250
|
-
{
|
251
|
-
:data => [make_file, make_file, make_file],
|
252
|
-
:object => 'list',
|
253
|
-
:resource_url => '/v1/files'
|
254
|
-
}
|
255
|
-
end
|
256
|
-
|
257
|
-
#FIXME nested overrides would be better than hardcoding plan_id
|
258
|
-
def make_subscription(params = {})
|
259
|
-
plan = params.delete(:plan) || 'gold'
|
260
|
-
{
|
261
|
-
:current_period_end => 1308681468,
|
262
|
-
:status => "trialing",
|
263
|
-
:plan => {
|
264
|
-
:interval => "month",
|
265
|
-
:amount => 7500,
|
266
|
-
:trial_period_days => 30,
|
267
|
-
:object => "plan",
|
268
|
-
:identifier => plan
|
269
|
-
},
|
270
|
-
:current_period_start => 1308595038,
|
271
|
-
:start => 1308595038,
|
272
|
-
:object => "subscription",
|
273
|
-
:trial_start => 1308595038,
|
274
|
-
:trial_end => 1308681468,
|
275
|
-
:customer => "c_test_customer",
|
276
|
-
:id => 's_test_subscription'
|
277
|
-
}.merge(params)
|
278
|
-
end
|
279
|
-
|
280
|
-
def make_subscription_item(params = {})
|
281
|
-
plan = params.delete(:plan) || 'gold'
|
282
|
-
{
|
283
|
-
:id => "si_test_subscription_item",
|
284
|
-
:object => "subscription_item",
|
285
|
-
:created => 1473875521,
|
286
|
-
:plan => {
|
287
|
-
:id => plan,
|
288
|
-
:object => "plan",
|
289
|
-
:amount => 1000,
|
290
|
-
:created => 1468349629,
|
291
|
-
:currency => "usd",
|
292
|
-
:interval => "month",
|
293
|
-
},
|
294
|
-
:quantity => 1
|
295
|
-
}.merge(params)
|
296
|
-
end
|
297
|
-
|
298
|
-
def make_refund(params = {})
|
299
|
-
{
|
300
|
-
:object => 'refund',
|
301
|
-
:amount => 30,
|
302
|
-
:currency => "usd",
|
303
|
-
:created => 1308595038,
|
304
|
-
:id => "ref_test_refund",
|
305
|
-
:charge => "ch_test_charge",
|
306
|
-
:metadata => {}
|
307
|
-
}.merge(params)
|
308
|
-
end
|
309
|
-
|
310
|
-
def make_subscription_array
|
311
|
-
{
|
312
|
-
:data => [make_subscription, make_subscription, make_subscription],
|
313
|
-
:object => 'list',
|
314
|
-
:resource_url => '/v1/subscriptions'
|
315
|
-
}
|
316
|
-
end
|
317
|
-
|
318
|
-
def make_subscription_item_array
|
319
|
-
{
|
320
|
-
:data => [make_subscription_item, make_subscription_item, make_subscription_item],
|
321
|
-
:object => 'list',
|
322
|
-
:resource_url => '/v1/subscription_items'
|
323
|
-
}
|
324
|
-
end
|
325
|
-
|
326
|
-
def make_customer_subscription_array(customer_id)
|
327
|
-
{
|
328
|
-
:data => [make_subscription, make_subscription, make_subscription],
|
329
|
-
:object => 'list',
|
330
|
-
:resource_url => '/v1/customers/' + customer_id + '/subscriptions'
|
331
|
-
}
|
332
|
-
end
|
333
|
-
|
334
|
-
def make_refund_array(charge=nil)
|
335
|
-
p = charge ? {:charge => charge} : {}
|
336
|
-
|
337
|
-
{
|
338
|
-
:data => [make_refund(p), make_refund(p), make_refund(p)],
|
339
|
-
:object => 'list',
|
340
|
-
:resource_url => charge ? "/v1/charges/#{charge}/refunds" : '/v1/refunds'
|
341
|
-
}
|
342
|
-
end
|
343
|
-
|
344
|
-
def make_reversal_array(transfer_id)
|
345
|
-
{
|
346
|
-
:data => [make_reversal, make_reversal, make_reversal],
|
347
|
-
:object => 'list',
|
348
|
-
:resource_url => '/v1/transfers/' + transfer_id + '/reversals'
|
349
|
-
}
|
350
|
-
end
|
351
|
-
|
352
|
-
def make_invoice(params={})
|
353
|
-
{
|
354
|
-
:id => 'in_test_invoice',
|
355
|
-
:object => 'invoice',
|
356
|
-
:livemode => false,
|
357
|
-
:amount_due => 1000,
|
358
|
-
:attempt_count => 0,
|
359
|
-
:attempted => false,
|
360
|
-
:closed => false,
|
361
|
-
:currency => 'usd',
|
362
|
-
:customer => 'c_test_customer',
|
363
|
-
:date => 1349738950,
|
364
|
-
:lines => {
|
365
|
-
:object => 'list',
|
366
|
-
:data => [
|
367
|
-
{
|
368
|
-
:id => 'ii_test_invoice_item',
|
369
|
-
:object => 'invoiceitem',
|
370
|
-
:livemode => false,
|
371
|
-
:amount => 1000,
|
372
|
-
:currency => 'usd',
|
373
|
-
:customer => 'c_test_customer',
|
374
|
-
:date => 1349738950,
|
375
|
-
:description => "A Test Invoice Item",
|
376
|
-
:invoice => 'in_test_invoice'
|
377
|
-
},
|
378
|
-
],
|
379
|
-
},
|
380
|
-
:paid => false,
|
381
|
-
:period_end => 1349738950,
|
382
|
-
:period_start => 1349738950,
|
383
|
-
:starting_balance => 0,
|
384
|
-
:subtotal => 1000,
|
385
|
-
:total => 1000,
|
386
|
-
:charge => nil,
|
387
|
-
:discount => nil,
|
388
|
-
:ending_balance => nil,
|
389
|
-
:next_payment_attempt => 1349825350,
|
390
|
-
}.merge(params)
|
391
|
-
end
|
392
|
-
|
393
|
-
def make_paid_invoice
|
394
|
-
make_invoice.merge({
|
395
|
-
:attempt_count => 1,
|
396
|
-
:attempted => true,
|
397
|
-
:closed => true,
|
398
|
-
:paid => true,
|
399
|
-
:charge => 'ch_test_charge',
|
400
|
-
:ending_balance => 0,
|
401
|
-
:next_payment_attempt => nil,
|
402
|
-
})
|
403
|
-
end
|
404
|
-
|
405
|
-
def make_invoice_item(params={})
|
406
|
-
{
|
407
|
-
id: "ii_test_invoice_item",
|
408
|
-
object: "invoiceitem",
|
409
|
-
date: 1466982411,
|
410
|
-
invoice: "in_test_invoice",
|
411
|
-
livemode: false,
|
412
|
-
metadata: {},
|
413
|
-
}.merge(params)
|
414
|
-
end
|
415
|
-
|
416
|
-
def make_invoice_customer_array
|
417
|
-
{
|
418
|
-
:data => [make_invoice],
|
419
|
-
:object => 'list',
|
420
|
-
:resource_url => '/v1/invoices?customer=test_customer'
|
421
|
-
}
|
422
|
-
end
|
423
|
-
|
424
|
-
def make_recipient(params={})
|
425
|
-
id = params[:id] || 'rp_test_recipient'
|
426
|
-
{
|
427
|
-
:name => "Stripe User",
|
428
|
-
:type => "individual",
|
429
|
-
:livemode => false,
|
430
|
-
:object => "recipient",
|
431
|
-
:id => "rp_test_recipient",
|
432
|
-
:cards => make_recipient_card_array(id),
|
433
|
-
:default_card => "debit_test_card",
|
434
|
-
:active_account => {
|
435
|
-
:last4 => "6789",
|
436
|
-
:bank_name => "STRIPE TEST BANK",
|
437
|
-
:country => "US",
|
438
|
-
:object => "bank_account"
|
439
|
-
},
|
440
|
-
:created => 1304114758,
|
441
|
-
:verified => true,
|
442
|
-
:metadata => {}
|
443
|
-
}.merge(params)
|
444
|
-
end
|
445
|
-
|
446
|
-
def make_recipient_array
|
447
|
-
{
|
448
|
-
:data => [make_recipient, make_recipient, make_recipient],
|
449
|
-
:object => 'list',
|
450
|
-
:resource_url => '/v1/recipients'
|
451
|
-
}
|
452
|
-
end
|
453
|
-
|
454
|
-
def make_transfer(params={})
|
455
|
-
{
|
456
|
-
:status => 'pending',
|
457
|
-
:amount => 100,
|
458
|
-
:account => {
|
459
|
-
:object => 'bank_account',
|
460
|
-
:country => 'US',
|
461
|
-
:bank_name => 'STRIPE TEST BANK',
|
462
|
-
:last4 => '6789'
|
463
|
-
},
|
464
|
-
:recipient => 'test_recipient',
|
465
|
-
:fee => 0,
|
466
|
-
:fee_details => [],
|
467
|
-
:id => "tr_test_transfer",
|
468
|
-
:reversals => make_reversal_array('tr_test_transfer'),
|
469
|
-
:livemode => false,
|
470
|
-
:currency => "usd",
|
471
|
-
:object => "transfer",
|
472
|
-
:date => 1304114826,
|
473
|
-
:metadata => {}
|
474
|
-
}.merge(params)
|
475
|
-
end
|
476
|
-
|
477
|
-
def make_transfer_array
|
478
|
-
{
|
479
|
-
:data => [make_transfer, make_transfer, make_transfer],
|
480
|
-
:object => 'list',
|
481
|
-
:resource_url => '/v1/transfers'
|
482
|
-
}
|
483
|
-
end
|
484
|
-
|
485
|
-
def make_canceled_transfer
|
486
|
-
make_transfer.merge({
|
487
|
-
:status => 'canceled'
|
488
|
-
})
|
489
|
-
end
|
490
|
-
|
491
|
-
def make_reversal(params={})
|
492
|
-
{
|
493
|
-
:object => 'transfer_reversal',
|
494
|
-
:amount => 30,
|
495
|
-
:currency => "usd",
|
496
|
-
:created => 1308595038,
|
497
|
-
:id => "ref_test_reversal",
|
498
|
-
:transfer => "tr_test_transfer",
|
499
|
-
:metadata => {}
|
500
|
-
}.merge(params)
|
501
|
-
end
|
502
|
-
|
503
|
-
def make_bitcoin_receiver(params={})
|
3
|
+
def make_error(type, message)
|
504
4
|
{
|
505
|
-
:
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
:metadata => {},
|
510
|
-
:object => 'bitcoin_receiver',
|
511
|
-
:customer => nil,
|
512
|
-
:transactions => make_bitcoin_transaction_array
|
513
|
-
}.merge(params)
|
514
|
-
end
|
515
|
-
|
516
|
-
def make_bitcoin_receiver_array
|
517
|
-
{
|
518
|
-
:data => [make_bitcoin_receiver, make_bitcoin_receiver, make_bitcoin_receiver],
|
519
|
-
:object => 'list',
|
520
|
-
:resource_url => '/v1/bitcoin/receivers'
|
521
|
-
}
|
522
|
-
end
|
523
|
-
|
524
|
-
def make_bitcoin_transaction(params={})
|
525
|
-
{
|
526
|
-
:id => 'btctxn_test_transaction',
|
527
|
-
:object => 'bitcoin_transaction',
|
528
|
-
:amount => 100,
|
529
|
-
:currency => 'usd',
|
530
|
-
:bitcoin_amount => 90,
|
531
|
-
:receiver => 'btcrcv_test_receiver'
|
532
|
-
}.merge(params)
|
533
|
-
end
|
534
|
-
|
535
|
-
def make_bitcoin_transaction_array
|
536
|
-
{
|
537
|
-
:data => [make_bitcoin_transaction, make_bitcoin_transaction, make_bitcoin_transaction],
|
538
|
-
:object => 'list',
|
539
|
-
:resource_url => "/v1/bitcoin/receivers/btcrcv_test_receiver/transactions"
|
5
|
+
:error => {
|
6
|
+
:type => type,
|
7
|
+
:message => message,
|
8
|
+
}
|
540
9
|
}
|
541
10
|
end
|
542
11
|
|
@@ -586,400 +55,5 @@ module Stripe
|
|
586
55
|
}
|
587
56
|
}
|
588
57
|
end
|
589
|
-
|
590
|
-
def make_delete_discount_response
|
591
|
-
{
|
592
|
-
:deleted => true,
|
593
|
-
:id => "di_test_coupon"
|
594
|
-
}
|
595
|
-
end
|
596
|
-
|
597
|
-
def make_product(params={})
|
598
|
-
{
|
599
|
-
:id => "pr_test_product",
|
600
|
-
:created => 1441992477,
|
601
|
-
:updated => 1441992477,
|
602
|
-
:object => "product",
|
603
|
-
:livemode => false,
|
604
|
-
:name => "Test Product",
|
605
|
-
:caption => "Comfy comfu",
|
606
|
-
:description => "Testing",
|
607
|
-
:active => true,
|
608
|
-
:attributes => [],
|
609
|
-
:shippable => true,
|
610
|
-
:metadata => {},
|
611
|
-
:url => "http://example.com/product",
|
612
|
-
:package_dimensions => nil,
|
613
|
-
:images => [],
|
614
|
-
:skus => make_sku_array("pr_test_product")
|
615
|
-
}.merge(params)
|
616
|
-
end
|
617
|
-
|
618
|
-
def make_product_array
|
619
|
-
{
|
620
|
-
:object => "list",
|
621
|
-
:resource_url => "/v1/products",
|
622
|
-
:data => [
|
623
|
-
make_product,
|
624
|
-
make_product,
|
625
|
-
make_product,
|
626
|
-
],
|
627
|
-
}
|
628
|
-
end
|
629
|
-
|
630
|
-
def make_sku(params={})
|
631
|
-
{
|
632
|
-
:id => "12345",
|
633
|
-
:created => 1441992494,
|
634
|
-
:updated => 1441992494,
|
635
|
-
:object => "sku",
|
636
|
-
:livemode => false,
|
637
|
-
:product => "pr_test_product",
|
638
|
-
:image => nil,
|
639
|
-
:active => true,
|
640
|
-
:price => 999,
|
641
|
-
:currency => "usd",
|
642
|
-
:inventory => {
|
643
|
-
:type => "infinite",
|
644
|
-
:quantity => nil,
|
645
|
-
:value => nil,
|
646
|
-
},
|
647
|
-
:attributes => {},
|
648
|
-
:metadata => {},
|
649
|
-
:package_dimensions => nil,
|
650
|
-
}.merge(params)
|
651
|
-
end
|
652
|
-
|
653
|
-
def make_sku_array(product_id, params={})
|
654
|
-
{
|
655
|
-
:object => "list",
|
656
|
-
:resource_url => "/v1/skus",
|
657
|
-
:data => [
|
658
|
-
make_sku(:product => product_id),
|
659
|
-
make_sku(:product => product_id),
|
660
|
-
make_sku(:product => product_id),
|
661
|
-
]
|
662
|
-
}
|
663
|
-
end
|
664
|
-
|
665
|
-
def make_order(params={})
|
666
|
-
{
|
667
|
-
:id => "or_16kg0uDAu10Yox5RReNVCthv",
|
668
|
-
:created => 1442171988,
|
669
|
-
:updated => nil,
|
670
|
-
:object => "order",
|
671
|
-
:livemode => false,
|
672
|
-
:status => "created",
|
673
|
-
:metadata => {},
|
674
|
-
:customer => nil,
|
675
|
-
:shipping => {
|
676
|
-
:name => "Jenny Rosen",
|
677
|
-
:address => {
|
678
|
-
:line1 => "1234 Main street",
|
679
|
-
:line2 => nil,
|
680
|
-
:city => "Anytown",
|
681
|
-
:state => nil,
|
682
|
-
:postal_code => "123456",
|
683
|
-
:country => "US"
|
684
|
-
},
|
685
|
-
:phone => nil,
|
686
|
-
},
|
687
|
-
:email => nil,
|
688
|
-
:items => [
|
689
|
-
{
|
690
|
-
:parent => "sk_16bHXrDAu10Yox5RU2007dpU",
|
691
|
-
:object => "order_item",
|
692
|
-
:type => "sku",
|
693
|
-
:description => "T-shirt",
|
694
|
-
:amount => 1500,
|
695
|
-
:currency => "usd",
|
696
|
-
:quantity => nil,
|
697
|
-
}
|
698
|
-
],
|
699
|
-
:shipping_methods => nil,
|
700
|
-
:selected_shipping_method => nil,
|
701
|
-
:amount => 1500,
|
702
|
-
:currency => "usd",
|
703
|
-
:charge => nil,
|
704
|
-
}.merge(params)
|
705
|
-
end
|
706
|
-
|
707
|
-
def make_order_array(params={})
|
708
|
-
{
|
709
|
-
:object => "list",
|
710
|
-
:resource_url => "/v1/orders",
|
711
|
-
:data => [
|
712
|
-
make_order,
|
713
|
-
make_order,
|
714
|
-
make_order,
|
715
|
-
]
|
716
|
-
}
|
717
|
-
end
|
718
|
-
|
719
|
-
def make_paid_order(params={})
|
720
|
-
make_order.merge({
|
721
|
-
:status => "paid",
|
722
|
-
:charge => make_charge,
|
723
|
-
}).merge(params)
|
724
|
-
end
|
725
|
-
|
726
|
-
def make_partially_returned_order(params={})
|
727
|
-
make_paid_order.merge({
|
728
|
-
:returns => make_order_return_array,
|
729
|
-
}).merge(params)
|
730
|
-
end
|
731
|
-
|
732
|
-
def make_order_return(params={})
|
733
|
-
{
|
734
|
-
:id => "orret_18CI1jDAu10Yox5R5kGPgbLN",
|
735
|
-
:object => "order_return",
|
736
|
-
:amount => 1220,
|
737
|
-
:created => 1463529303,
|
738
|
-
:currency => "usd",
|
739
|
-
:items => [
|
740
|
-
{
|
741
|
-
:object => "order_item",
|
742
|
-
:amount => 200,
|
743
|
-
:currency => "usd",
|
744
|
-
:description => "Just a SKU",
|
745
|
-
:parent => "sku_80NAUPJ9dpYtck",
|
746
|
-
:quantity => 2,
|
747
|
-
:type => "sku"
|
748
|
-
},
|
749
|
-
{
|
750
|
-
:object => "order_item",
|
751
|
-
:amount => 20,
|
752
|
-
:currency => "usd",
|
753
|
-
:description => "Fair enough",
|
754
|
-
:parent => nil,
|
755
|
-
:quantity => nil,
|
756
|
-
:type => "tax"
|
757
|
-
},
|
758
|
-
],
|
759
|
-
:livemode => false,
|
760
|
-
:order => "or_189jaGDAu10Yox5R0F6LoH6K",
|
761
|
-
:refund => nil,
|
762
|
-
}.merge(params)
|
763
|
-
end
|
764
|
-
|
765
|
-
def make_order_return_array
|
766
|
-
{
|
767
|
-
:object => "list",
|
768
|
-
:resource_url => "/v1/order_returns",
|
769
|
-
:data => [
|
770
|
-
make_order_return,
|
771
|
-
make_order_return,
|
772
|
-
make_order_return,
|
773
|
-
]
|
774
|
-
}
|
775
|
-
end
|
776
|
-
|
777
|
-
def country_spec_array
|
778
|
-
{
|
779
|
-
:object => "list",
|
780
|
-
:resource_url => "/v1/country_specs",
|
781
|
-
:data => [
|
782
|
-
make_country_spec,
|
783
|
-
make_country_spec,
|
784
|
-
make_country_spec,
|
785
|
-
]
|
786
|
-
}
|
787
|
-
end
|
788
|
-
|
789
|
-
def make_country_spec(params={})
|
790
|
-
{
|
791
|
-
:id => "US",
|
792
|
-
:object => "country_spec",
|
793
|
-
:supported_bank_account_currencies => {
|
794
|
-
:usd => ["US"]
|
795
|
-
},
|
796
|
-
:supported_payment_currencies => [
|
797
|
-
"usd", "aed", "afn", "all"
|
798
|
-
],
|
799
|
-
:supported_payment_methods => [
|
800
|
-
"alipay",
|
801
|
-
"card",
|
802
|
-
"stripe"
|
803
|
-
],
|
804
|
-
:verification_fields =>
|
805
|
-
{
|
806
|
-
:individual => {
|
807
|
-
:minimum => [
|
808
|
-
"external_account",
|
809
|
-
"legal_entity.address.city",
|
810
|
-
"tos_acceptance.date",
|
811
|
-
"tos_acceptance.ip"
|
812
|
-
],
|
813
|
-
:additional => [
|
814
|
-
"legal_entity.personal_id_number",
|
815
|
-
"legal_entity.verification.document"
|
816
|
-
]
|
817
|
-
},
|
818
|
-
:company => {
|
819
|
-
:minimum => [
|
820
|
-
"external_account",
|
821
|
-
"legal_entity.address.city",
|
822
|
-
"legal_entity.address.line1",
|
823
|
-
"tos_acceptance.ip"
|
824
|
-
],
|
825
|
-
:additional => [
|
826
|
-
"legal_entity.personal_id_number",
|
827
|
-
"legal_entity.verification.document"
|
828
|
-
]
|
829
|
-
}
|
830
|
-
}
|
831
|
-
}.merge(params)
|
832
|
-
end
|
833
|
-
|
834
|
-
def make_plan(params={})
|
835
|
-
{
|
836
|
-
id: "silver",
|
837
|
-
object: "plan",
|
838
|
-
amount: 1000,
|
839
|
-
created: 1463962497,
|
840
|
-
currency: "usd",
|
841
|
-
interval: "year",
|
842
|
-
interval_count: 1,
|
843
|
-
livemode: false,
|
844
|
-
metadata: {},
|
845
|
-
name: "Silver",
|
846
|
-
statement_descriptor: nil,
|
847
|
-
trial_period_days: nil,
|
848
|
-
}.merge(params)
|
849
|
-
end
|
850
|
-
|
851
|
-
def make_plan_array
|
852
|
-
{
|
853
|
-
:object => "list",
|
854
|
-
:resource_url => "/v1/plans",
|
855
|
-
:data => [
|
856
|
-
make_plan,
|
857
|
-
make_plan,
|
858
|
-
make_plan,
|
859
|
-
]
|
860
|
-
}
|
861
|
-
end
|
862
|
-
|
863
|
-
def make_three_d_secure(params={})
|
864
|
-
{
|
865
|
-
:id => 'tdsrc_test',
|
866
|
-
:object => 'three_d_secure',
|
867
|
-
:amount => 1500,
|
868
|
-
:authenticate => true,
|
869
|
-
:card => make_card,
|
870
|
-
:created => 1456908210,
|
871
|
-
:currency => 'usd',
|
872
|
-
:livemode => false,
|
873
|
-
:redirect_url => nil,
|
874
|
-
:status => 'succeeded',
|
875
|
-
}.merge(params)
|
876
|
-
end
|
877
|
-
|
878
|
-
def make_apple_pay_domain(params={})
|
879
|
-
{
|
880
|
-
:id => "apwc_test_domain",
|
881
|
-
:object => "apple_pay_domain",
|
882
|
-
:domain_name => "test.com",
|
883
|
-
:livemode => false
|
884
|
-
}.merge(params)
|
885
|
-
end
|
886
|
-
|
887
|
-
def make_apple_pay_domain_array
|
888
|
-
{
|
889
|
-
:object => "list",
|
890
|
-
:resource_url => "/v1/apple_pay/domains",
|
891
|
-
:data => [
|
892
|
-
make_apple_pay_domain,
|
893
|
-
make_apple_pay_domain,
|
894
|
-
make_apple_pay_domain
|
895
|
-
]
|
896
|
-
}
|
897
|
-
end
|
898
|
-
|
899
|
-
def make_source_card(params={})
|
900
|
-
id = params[:id] || 'src_test_card'
|
901
|
-
{
|
902
|
-
:id => id,
|
903
|
-
:object => 'source',
|
904
|
-
:type => 'card',
|
905
|
-
:amount => nil,
|
906
|
-
:card => {
|
907
|
-
:address_line1_check => nil,
|
908
|
-
:address_zip_check => nil,
|
909
|
-
:brand => 'Visa',
|
910
|
-
:country => 'US',
|
911
|
-
:cvc_check => 'unchecked',
|
912
|
-
:description => nil,
|
913
|
-
:dynamic_last4 => nil,
|
914
|
-
:exp_month => 1,
|
915
|
-
:exp_year => 2020,
|
916
|
-
:fingerprint => 'NrVafqTONZfbLkQK',
|
917
|
-
:funding => 'credit',
|
918
|
-
:google_reference => nil,
|
919
|
-
:iin => nil,
|
920
|
-
:issuer => nil,
|
921
|
-
:last4 => '4242',
|
922
|
-
:three_d_secure => 'optional',
|
923
|
-
:tokenization_method => 'nil',
|
924
|
-
},
|
925
|
-
:client_secret => 'src_client_secret_test',
|
926
|
-
:created => 1484841032,
|
927
|
-
:currency => nil,
|
928
|
-
:flow => 'none',
|
929
|
-
:livemode => false,
|
930
|
-
:metadata => {},
|
931
|
-
:owner => {
|
932
|
-
:address => nil,
|
933
|
-
:email => nil,
|
934
|
-
:name => nil,
|
935
|
-
:phone => nil,
|
936
|
-
:verified_address => nil,
|
937
|
-
:verified_email => nil,
|
938
|
-
:verified_name => nil,
|
939
|
-
:verified_phone => nil,
|
940
|
-
},
|
941
|
-
:status => 'chargeable',
|
942
|
-
:usage => 'reusable',
|
943
|
-
}.merge(params)
|
944
|
-
end
|
945
|
-
|
946
|
-
def make_source_ach_debit(params={})
|
947
|
-
id = params[:id] || 'src_test_ach_debit'
|
948
|
-
{
|
949
|
-
:id => id,
|
950
|
-
:object => 'source',
|
951
|
-
:type => 'ach_debit',
|
952
|
-
:ach_debit => {
|
953
|
-
:country => 'US',
|
954
|
-
:fingerprint => 'yY5BWKwnW98uydOa',
|
955
|
-
:last4 => '6789',
|
956
|
-
:routing_number => '110000000',
|
957
|
-
:type => 'individual',
|
958
|
-
},
|
959
|
-
:amount => nil,
|
960
|
-
:client_secret => 'src_client_secret_test',
|
961
|
-
:created => 1484842122,
|
962
|
-
:currency => 'usd',
|
963
|
-
:flow => 'verification',
|
964
|
-
:livemode => false,
|
965
|
-
:metadata => {},
|
966
|
-
:owner => {
|
967
|
-
:address => nil,
|
968
|
-
:email => nil,
|
969
|
-
:name => 'Jenny Rosen',
|
970
|
-
:phone => nil,
|
971
|
-
:verified_address => nil,
|
972
|
-
:verified_email => nil,
|
973
|
-
:verified_name => nil,
|
974
|
-
:verified_phone => nil,
|
975
|
-
},
|
976
|
-
:status => 'pending',
|
977
|
-
:usage => 'reusable',
|
978
|
-
:verification => {
|
979
|
-
:attempts_remaining => 10,
|
980
|
-
:status => 'pending',
|
981
|
-
},
|
982
|
-
}.merge(params)
|
983
|
-
end
|
984
58
|
end
|
985
59
|
end
|