stripe 1.16.0 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +5 -1
- data/History.txt +6 -0
- data/README.rdoc +7 -1
- data/VERSION +1 -1
- data/lib/stripe/api_operations/create.rb +3 -2
- data/lib/stripe/api_operations/delete.rb +3 -3
- data/lib/stripe/api_operations/list.rb +3 -2
- data/lib/stripe/api_resource.rb +1 -2
- data/lib/stripe/application_fee.rb +3 -3
- data/lib/stripe/charge.rb +32 -11
- data/lib/stripe/customer.rb +18 -10
- data/lib/stripe/invoice.rb +0 -1
- data/lib/stripe/list_object.rb +6 -4
- data/lib/stripe/singleton_api_resource.rb +1 -1
- data/lib/stripe/stripe_object.rb +4 -4
- data/lib/stripe/transfer.rb +0 -1
- data/lib/stripe/util.rb +36 -11
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/api_resource_test.rb +31 -1
- data/test/stripe/charge_test.rb +17 -1
- data/test/stripe/coupon_test.rb +10 -1
- data/test/stripe/util_test.rb +31 -1
- data/test/test_data.rb +409 -0
- data/test/test_helper.rb +3 -407
- metadata +4 -2
data/test/test_helper.rb
CHANGED
@@ -3,8 +3,9 @@ require 'test/unit'
|
|
3
3
|
require 'mocha/setup'
|
4
4
|
require 'stringio'
|
5
5
|
require 'shoulda'
|
6
|
+
require File.expand_path('../test_data', __FILE__)
|
6
7
|
|
7
|
-
#monkeypatch request methods
|
8
|
+
# monkeypatch request methods
|
8
9
|
module Stripe
|
9
10
|
@mock_rest_client = nil
|
10
11
|
|
@@ -23,412 +24,8 @@ module Stripe
|
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
|
-
def test_response(body, code=200)
|
27
|
-
# When an exception is raised, restclient clobbers method_missing. Hence we
|
28
|
-
# can't just use the stubs interface.
|
29
|
-
body = JSON.generate(body) if !(body.kind_of? String)
|
30
|
-
m = mock
|
31
|
-
m.instance_variable_set('@stripe_values', { :body => body, :code => code })
|
32
|
-
def m.body; @stripe_values[:body]; end
|
33
|
-
def m.code; @stripe_values[:code]; end
|
34
|
-
m
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_balance(params={})
|
38
|
-
{
|
39
|
-
:pending => [
|
40
|
-
{:amount => 12345, :currency => "usd"}
|
41
|
-
],
|
42
|
-
:available => [
|
43
|
-
{:amount => 6789, :currency => "usd"}
|
44
|
-
],
|
45
|
-
:livemode => false,
|
46
|
-
:object => "balance"
|
47
|
-
}.merge(params)
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_balance_transaction(params={})
|
51
|
-
{
|
52
|
-
:amount => 100,
|
53
|
-
:net => 41,
|
54
|
-
:currency => "usd",
|
55
|
-
:type => "charge",
|
56
|
-
:created => 1371945005,
|
57
|
-
:available_on => 1372549805,
|
58
|
-
:status => "pending",
|
59
|
-
:description => "A test balance transaction",
|
60
|
-
:fee => 59,
|
61
|
-
:object => "balance_transaction"
|
62
|
-
}.merge(params)
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_balance_transaction_array
|
66
|
-
{
|
67
|
-
:data => [test_balance_transaction, test_balance_transaction, test_balance_transaction],
|
68
|
-
:object => "list",
|
69
|
-
:url => "/v1/balance/history"
|
70
|
-
}
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_application_fee(params={})
|
74
|
-
id = params[:id] || 'fee_test_fee'
|
75
|
-
{
|
76
|
-
:refunded => false,
|
77
|
-
:amount => 100,
|
78
|
-
:application => "ca_test_application",
|
79
|
-
:user => "acct_test_user",
|
80
|
-
:charge => "ch_test_charge",
|
81
|
-
:id => id,
|
82
|
-
:livemode => false,
|
83
|
-
:currency => "usd",
|
84
|
-
:object => "application_fee",
|
85
|
-
:refunds => test_application_fee_refund_array(id),
|
86
|
-
:created => 1304114826
|
87
|
-
}.merge(params)
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_application_fee_refund(params = {})
|
91
|
-
{
|
92
|
-
:object => 'fee_refund',
|
93
|
-
:amount => 30,
|
94
|
-
:currency => "usd",
|
95
|
-
:created => 1308595038,
|
96
|
-
:id => "ref_test_app_fee_refund",
|
97
|
-
:fee => "ca_test_application",
|
98
|
-
:metadata => {}
|
99
|
-
}.merge(params)
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_application_fee_array
|
103
|
-
{
|
104
|
-
:data => [test_application_fee, test_application_fee, test_application_fee],
|
105
|
-
:object => 'list',
|
106
|
-
:url => '/v1/application_fees'
|
107
|
-
}
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_application_fee_refund_array(fee_id)
|
111
|
-
{
|
112
|
-
:data => [test_application_fee_refund, test_application_fee_refund, test_application_fee_refund],
|
113
|
-
:object => 'list',
|
114
|
-
:url => '/v1/application_fees/' + fee_id + '/refunds'
|
115
|
-
}
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_customer(params={})
|
119
|
-
id = params[:id] || 'c_test_customer'
|
120
|
-
{
|
121
|
-
:subscription_history => [],
|
122
|
-
:bills => [],
|
123
|
-
:charges => [],
|
124
|
-
:livemode => false,
|
125
|
-
:object => "customer",
|
126
|
-
:id => id,
|
127
|
-
:default_card => "cc_test_card",
|
128
|
-
:created => 1304114758,
|
129
|
-
:cards => test_card_array(id),
|
130
|
-
:metadata => {},
|
131
|
-
:subscriptions => test_subscription_array(id)
|
132
|
-
}.merge(params)
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_customer_array
|
136
|
-
{
|
137
|
-
:data => [test_customer, test_customer, test_customer],
|
138
|
-
:object => 'list',
|
139
|
-
:url => '/v1/customers'
|
140
|
-
}
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_charge(params={})
|
144
|
-
id = params[:id] || 'ch_test_charge'
|
145
|
-
{
|
146
|
-
:refunded => false,
|
147
|
-
:paid => true,
|
148
|
-
:amount => 100,
|
149
|
-
:card => {
|
150
|
-
:type => "Visa",
|
151
|
-
:last4 => "4242",
|
152
|
-
:exp_month => 11,
|
153
|
-
:country => "US",
|
154
|
-
:exp_year => 2012,
|
155
|
-
:id => "cc_test_card",
|
156
|
-
:object => "card"
|
157
|
-
},
|
158
|
-
:id => id,
|
159
|
-
:reason => "execute_charge",
|
160
|
-
:livemode => false,
|
161
|
-
:currency => "usd",
|
162
|
-
:object => "charge",
|
163
|
-
:created => 1304114826,
|
164
|
-
:refunds => test_refund_array(id),
|
165
|
-
:metadata => {}
|
166
|
-
}.merge(params)
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_charge_array
|
170
|
-
{
|
171
|
-
:data => [test_charge, test_charge, test_charge],
|
172
|
-
:object => 'list',
|
173
|
-
:url => '/v1/charges'
|
174
|
-
}
|
175
|
-
end
|
176
|
-
|
177
|
-
def test_card_array(customer_id)
|
178
|
-
{
|
179
|
-
:data => [test_card, test_card, test_card],
|
180
|
-
:object => 'list',
|
181
|
-
:url => '/v1/customers/' + customer_id + '/cards'
|
182
|
-
}
|
183
|
-
end
|
184
|
-
|
185
|
-
def test_card(params={})
|
186
|
-
{
|
187
|
-
:type => "Visa",
|
188
|
-
:last4 => "4242",
|
189
|
-
:exp_month => 11,
|
190
|
-
:country => "US",
|
191
|
-
:exp_year => 2012,
|
192
|
-
:id => "cc_test_card",
|
193
|
-
:customer => 'c_test_customer',
|
194
|
-
:object => "card"
|
195
|
-
}.merge(params)
|
196
|
-
end
|
197
|
-
|
198
|
-
def test_coupon(params={})
|
199
|
-
{
|
200
|
-
:duration => 'repeating',
|
201
|
-
:duration_in_months => 3,
|
202
|
-
:percent_off => 25,
|
203
|
-
:id => "co_test_coupon",
|
204
|
-
:object => "coupon"
|
205
|
-
}.merge(params)
|
206
|
-
end
|
207
|
-
|
208
|
-
#FIXME nested overrides would be better than hardcoding plan_id
|
209
|
-
def test_subscription(params = {})
|
210
|
-
plan = params.delete(:plan) || 'gold'
|
211
|
-
{
|
212
|
-
:current_period_end => 1308681468,
|
213
|
-
:status => "trialing",
|
214
|
-
:plan => {
|
215
|
-
:interval => "month",
|
216
|
-
:amount => 7500,
|
217
|
-
:trial_period_days => 30,
|
218
|
-
:object => "plan",
|
219
|
-
:identifier => plan
|
220
|
-
},
|
221
|
-
:current_period_start => 1308595038,
|
222
|
-
:start => 1308595038,
|
223
|
-
:object => "subscription",
|
224
|
-
:trial_start => 1308595038,
|
225
|
-
:trial_end => 1308681468,
|
226
|
-
:customer => "c_test_customer",
|
227
|
-
:id => 's_test_subscription'
|
228
|
-
}.merge(params)
|
229
|
-
end
|
230
|
-
|
231
|
-
def test_refund(params = {})
|
232
|
-
{
|
233
|
-
:object => 'refund',
|
234
|
-
:amount => 30,
|
235
|
-
:currency => "usd",
|
236
|
-
:created => 1308595038,
|
237
|
-
:id => "ref_test_refund",
|
238
|
-
:charge => "ch_test_charge",
|
239
|
-
:metadata => {}
|
240
|
-
}.merge(params)
|
241
|
-
end
|
242
|
-
|
243
|
-
def test_subscription_array(customer_id)
|
244
|
-
{
|
245
|
-
:data => [test_subscription, test_subscription, test_subscription],
|
246
|
-
:object => 'list',
|
247
|
-
:url => '/v1/customers/' + customer_id + '/subscriptions'
|
248
|
-
}
|
249
|
-
end
|
250
|
-
|
251
|
-
def test_refund_array(charge_id)
|
252
|
-
{
|
253
|
-
:data => [test_refund, test_refund, test_refund],
|
254
|
-
:object => 'list',
|
255
|
-
:url => '/v1/charges/' + charge_id + '/refunds'
|
256
|
-
}
|
257
|
-
end
|
258
|
-
|
259
|
-
|
260
|
-
def test_invoice
|
261
|
-
{
|
262
|
-
:id => 'in_test_invoice',
|
263
|
-
:object => 'invoice',
|
264
|
-
:livemode => false,
|
265
|
-
:amount_due => 1000,
|
266
|
-
:attempt_count => 0,
|
267
|
-
:attempted => false,
|
268
|
-
:closed => false,
|
269
|
-
:currency => 'usd',
|
270
|
-
:customer => 'c_test_customer',
|
271
|
-
:date => 1349738950,
|
272
|
-
:lines => {
|
273
|
-
"invoiceitems" => [
|
274
|
-
{
|
275
|
-
:id => 'ii_test_invoice_item',
|
276
|
-
:object => '',
|
277
|
-
:livemode => false,
|
278
|
-
:amount => 1000,
|
279
|
-
:currency => 'usd',
|
280
|
-
:customer => 'c_test_customer',
|
281
|
-
:date => 1349738950,
|
282
|
-
:description => "A Test Invoice Item",
|
283
|
-
:invoice => 'in_test_invoice'
|
284
|
-
},
|
285
|
-
],
|
286
|
-
},
|
287
|
-
:paid => false,
|
288
|
-
:period_end => 1349738950,
|
289
|
-
:period_start => 1349738950,
|
290
|
-
:starting_balance => 0,
|
291
|
-
:subtotal => 1000,
|
292
|
-
:total => 1000,
|
293
|
-
:charge => nil,
|
294
|
-
:discount => nil,
|
295
|
-
:ending_balance => nil,
|
296
|
-
:next_payemnt_attempt => 1349825350,
|
297
|
-
}
|
298
|
-
end
|
299
|
-
|
300
|
-
def test_paid_invoice
|
301
|
-
test_invoice.merge({
|
302
|
-
:attempt_count => 1,
|
303
|
-
:attempted => true,
|
304
|
-
:closed => true,
|
305
|
-
:paid => true,
|
306
|
-
:charge => 'ch_test_charge',
|
307
|
-
:ending_balance => 0,
|
308
|
-
:next_payment_attempt => nil,
|
309
|
-
})
|
310
|
-
end
|
311
|
-
|
312
|
-
def test_invoice_customer_array
|
313
|
-
{
|
314
|
-
:data => [test_invoice],
|
315
|
-
:object => 'list',
|
316
|
-
:url => '/v1/invoices?customer=test_customer'
|
317
|
-
}
|
318
|
-
end
|
319
|
-
|
320
|
-
def test_recipient(params={})
|
321
|
-
id = params[:id] || 'rp_test_recipient'
|
322
|
-
{
|
323
|
-
:name => "Stripe User",
|
324
|
-
:type => "individual",
|
325
|
-
:livemode => false,
|
326
|
-
:object => "recipient",
|
327
|
-
:id => "rp_test_recipient",
|
328
|
-
:cards => test_card_array(id),
|
329
|
-
:default_card => "debit_test_card",
|
330
|
-
:active_account => {
|
331
|
-
:last4 => "6789",
|
332
|
-
:bank_name => "STRIPE TEST BANK",
|
333
|
-
:country => "US",
|
334
|
-
:object => "bank_account"
|
335
|
-
},
|
336
|
-
:created => 1304114758,
|
337
|
-
:verified => true,
|
338
|
-
:metadata => {}
|
339
|
-
}.merge(params)
|
340
|
-
end
|
341
|
-
|
342
|
-
def test_recipient_array
|
343
|
-
{
|
344
|
-
:data => [test_recipient, test_recipient, test_recipient],
|
345
|
-
:object => 'list',
|
346
|
-
:url => '/v1/recipients'
|
347
|
-
}
|
348
|
-
end
|
349
|
-
|
350
|
-
def test_transfer(params={})
|
351
|
-
{
|
352
|
-
:status => 'pending',
|
353
|
-
:amount => 100,
|
354
|
-
:account => {
|
355
|
-
:object => 'bank_account',
|
356
|
-
:country => 'US',
|
357
|
-
:bank_name => 'STRIPE TEST BANK',
|
358
|
-
:last4 => '6789'
|
359
|
-
},
|
360
|
-
:recipient => 'test_recipient',
|
361
|
-
:fee => 0,
|
362
|
-
:fee_details => [],
|
363
|
-
:id => "tr_test_transfer",
|
364
|
-
:livemode => false,
|
365
|
-
:currency => "usd",
|
366
|
-
:object => "transfer",
|
367
|
-
:date => 1304114826,
|
368
|
-
:metadata => {}
|
369
|
-
}.merge(params)
|
370
|
-
end
|
371
|
-
|
372
|
-
def test_transfer_array
|
373
|
-
{
|
374
|
-
:data => [test_transfer, test_transfer, test_transfer],
|
375
|
-
:object => 'list',
|
376
|
-
:url => '/v1/transfers'
|
377
|
-
}
|
378
|
-
end
|
379
|
-
|
380
|
-
def test_canceled_transfer
|
381
|
-
test_transfer.merge({
|
382
|
-
:status => 'canceled'
|
383
|
-
})
|
384
|
-
end
|
385
|
-
|
386
|
-
def test_invalid_api_key_error
|
387
|
-
{
|
388
|
-
"error" => {
|
389
|
-
"type" => "invalid_request_error",
|
390
|
-
"message" => "Invalid API Key provided: invalid"
|
391
|
-
}
|
392
|
-
}
|
393
|
-
end
|
394
|
-
|
395
|
-
def test_invalid_exp_year_error
|
396
|
-
{
|
397
|
-
"error" => {
|
398
|
-
"code" => "invalid_expiry_year",
|
399
|
-
"param" => "exp_year",
|
400
|
-
"type" => "card_error",
|
401
|
-
"message" => "Your card's expiration year is invalid"
|
402
|
-
}
|
403
|
-
}
|
404
|
-
end
|
405
|
-
|
406
|
-
def test_missing_id_error
|
407
|
-
{
|
408
|
-
:error => {
|
409
|
-
:param => "id",
|
410
|
-
:type => "invalid_request_error",
|
411
|
-
:message => "Missing id"
|
412
|
-
}
|
413
|
-
}
|
414
|
-
end
|
415
|
-
|
416
|
-
def test_api_error
|
417
|
-
{
|
418
|
-
:error => {
|
419
|
-
:type => "api_error"
|
420
|
-
}
|
421
|
-
}
|
422
|
-
end
|
423
|
-
|
424
|
-
def test_delete_discount_response
|
425
|
-
{
|
426
|
-
:deleted => true,
|
427
|
-
:id => "di_test_coupon"
|
428
|
-
}
|
429
|
-
end
|
430
|
-
|
431
27
|
class Test::Unit::TestCase
|
28
|
+
include Stripe::TestData
|
432
29
|
include Mocha
|
433
30
|
|
434
31
|
setup do
|
@@ -442,4 +39,3 @@ class Test::Unit::TestCase
|
|
442
39
|
Stripe.api_key=nil
|
443
40
|
end
|
444
41
|
end
|
445
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.16.
|
4
|
+
version: 1.16.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-12-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -209,6 +209,7 @@ files:
|
|
209
209
|
- test/stripe/subscription_test.rb
|
210
210
|
- test/stripe/transfer_test.rb
|
211
211
|
- test/stripe/util_test.rb
|
212
|
+
- test/test_data.rb
|
212
213
|
- test/test_helper.rb
|
213
214
|
homepage: https://stripe.com/api
|
214
215
|
licenses:
|
@@ -254,5 +255,6 @@ test_files:
|
|
254
255
|
- test/stripe/subscription_test.rb
|
255
256
|
- test/stripe/transfer_test.rb
|
256
257
|
- test/stripe/util_test.rb
|
258
|
+
- test/test_data.rb
|
257
259
|
- test/test_helper.rb
|
258
260
|
has_rdoc:
|