stripe 1.7.11 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -0
- data/VERSION +1 -1
- data/lib/stripe.rb +2 -4
- data/lib/stripe/invoice.rb +2 -2
- data/lib/stripe/recipient.rb +12 -0
- data/lib/stripe/transfer.rb +1 -0
- data/lib/stripe/util.rb +1 -0
- data/lib/stripe/version.rb +1 -1
- data/test/test_helper.rb +63 -0
- data/test/test_stripe.rb +92 -0
- metadata +49 -15
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
=== 1.8.1 2013-04-19
|
2
|
+
|
3
|
+
* 1 minor enhancement:
|
4
|
+
* Add support for specifying an API key when retrieving an upcoming invoice
|
5
|
+
|
6
|
+
=== 1.8.0 2013-04-11
|
7
|
+
|
8
|
+
* 1 major enhancement:
|
9
|
+
* Add new Recipient API resource
|
10
|
+
* Allow Transfers to be createable
|
11
|
+
|
1
12
|
=== 1.7.11 2013-02-21
|
2
13
|
* Add 'id' to the list of permanent attributes
|
3
14
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.8.1
|
data/lib/stripe.rb
CHANGED
@@ -2,10 +2,7 @@
|
|
2
2
|
# API spec at https://stripe.com/docs/api
|
3
3
|
require 'cgi'
|
4
4
|
require 'set'
|
5
|
-
require 'rubygems'
|
6
5
|
require 'openssl'
|
7
|
-
|
8
|
-
gem 'rest-client', '~> 1.4'
|
9
6
|
require 'rest_client'
|
10
7
|
require 'multi_json'
|
11
8
|
|
@@ -35,6 +32,7 @@ require 'stripe/coupon'
|
|
35
32
|
require 'stripe/token'
|
36
33
|
require 'stripe/event'
|
37
34
|
require 'stripe/transfer'
|
35
|
+
require 'stripe/recipient'
|
38
36
|
|
39
37
|
# Errors
|
40
38
|
require 'stripe/errors/stripe_error'
|
@@ -127,7 +125,7 @@ module Stripe
|
|
127
125
|
# Make params into GET parameters
|
128
126
|
if params && params.count > 0
|
129
127
|
query_string = Util.flatten_params(params).collect{|key, value| "#{key}=#{Util.url_encode(value)}"}.join('&')
|
130
|
-
url += "
|
128
|
+
url += "#{URI.parse(url).query ? '&' : '?'}#{query_string}"
|
131
129
|
end
|
132
130
|
payload = nil
|
133
131
|
else
|
data/lib/stripe/invoice.rb
CHANGED
@@ -4,8 +4,8 @@ module Stripe
|
|
4
4
|
include Stripe::APIOperations::Update
|
5
5
|
include Stripe::APIOperations::Create
|
6
6
|
|
7
|
-
def self.upcoming(params)
|
8
|
-
response, api_key = Stripe.request(:get, upcoming_url,
|
7
|
+
def self.upcoming(params, api_key = nil)
|
8
|
+
response, api_key = Stripe.request(:get, upcoming_url, api_key, params)
|
9
9
|
Util.convert_to_stripe_object(response, api_key)
|
10
10
|
end
|
11
11
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Stripe
|
2
|
+
class Recipient < APIResource
|
3
|
+
include Stripe::APIOperations::Create
|
4
|
+
include Stripe::APIOperations::Delete
|
5
|
+
include Stripe::APIOperations::Update
|
6
|
+
include Stripe::APIOperations::List
|
7
|
+
|
8
|
+
def transfers
|
9
|
+
Transfer.all({ :recipient => id }, @api_key)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/stripe/transfer.rb
CHANGED
data/lib/stripe/util.rb
CHANGED
data/lib/stripe/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -189,6 +189,69 @@ def test_paid_invoice
|
|
189
189
|
})
|
190
190
|
end
|
191
191
|
|
192
|
+
def test_invoice_customer_array
|
193
|
+
{
|
194
|
+
:data => [test_invoice],
|
195
|
+
:object => 'list',
|
196
|
+
:url => '/v1/invoices?customer=test_customer'
|
197
|
+
}
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_recipient(params={})
|
201
|
+
{
|
202
|
+
:name => "Stripe User",
|
203
|
+
:type => "individual",
|
204
|
+
:livemode => false,
|
205
|
+
:object => "recipient",
|
206
|
+
:id => "rp_test_recipient",
|
207
|
+
:active_account => {
|
208
|
+
:last4 => "6789",
|
209
|
+
:bank_name => "STRIPE TEST BANK",
|
210
|
+
:country => "US",
|
211
|
+
:object => "bank_account"
|
212
|
+
},
|
213
|
+
:created => 1304114758,
|
214
|
+
:verified => true
|
215
|
+
}.merge(params)
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_recipient_array
|
219
|
+
{
|
220
|
+
:data => [test_recipient, test_recipient, test_recipient],
|
221
|
+
:object => 'list',
|
222
|
+
:url => '/v1/recipients'
|
223
|
+
}
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_transfer(params={})
|
227
|
+
{
|
228
|
+
:status => 'pending',
|
229
|
+
:amount => 100,
|
230
|
+
:account => {
|
231
|
+
:object => 'bank_account',
|
232
|
+
:country => 'US',
|
233
|
+
:bank_name => 'STRIPE TEST BANK',
|
234
|
+
:last4 => '6789'
|
235
|
+
},
|
236
|
+
:recipient => 'test_recipient',
|
237
|
+
:fee => 0,
|
238
|
+
:fee_details => [],
|
239
|
+
:id => "tr_test_transfer",
|
240
|
+
:livemode => false,
|
241
|
+
:currency => "usd",
|
242
|
+
:object => "transfer",
|
243
|
+
:date => 1304114826
|
244
|
+
}.merge(params)
|
245
|
+
end
|
246
|
+
|
247
|
+
def test_transfer_array
|
248
|
+
{
|
249
|
+
:data => [test_transfer, test_transfer, test_transfer],
|
250
|
+
:object => 'list',
|
251
|
+
:url => '/v1/transfers'
|
252
|
+
}
|
253
|
+
end
|
254
|
+
|
192
255
|
def test_invalid_api_key_error
|
193
256
|
{
|
194
257
|
"error" => {
|
data/test/test_stripe.rb
CHANGED
@@ -120,6 +120,15 @@ class TestStripeRuby < Test::Unit::TestCase
|
|
120
120
|
assert charges.kind_of? Array
|
121
121
|
end
|
122
122
|
|
123
|
+
should "construct URL properly with base query parameters" do
|
124
|
+
response = test_response(test_invoice_customer_array)
|
125
|
+
@mock.expects(:get).with("#{Stripe.api_base}/v1/invoices?customer=test_customer", nil, nil).returns(response)
|
126
|
+
invoices = Stripe::Invoice.all(:customer => 'test_customer')
|
127
|
+
|
128
|
+
@mock.expects(:get).with("#{Stripe.api_base}/v1/invoices?customer=test_customer&paid=true", nil, nil).returns(response)
|
129
|
+
invoices.all(:paid => true)
|
130
|
+
end
|
131
|
+
|
123
132
|
should "a 400 should give an InvalidRequestError with http status, body, and JSON body" do
|
124
133
|
response = test_response(test_missing_id_error, 400)
|
125
134
|
@mock.expects(:get).once.raises(RestClient::ExceptionWithResponse.new(response, 404))
|
@@ -468,6 +477,89 @@ class TestStripeRuby < Test::Unit::TestCase
|
|
468
477
|
end
|
469
478
|
end
|
470
479
|
|
480
|
+
context "transfer tests" do
|
481
|
+
|
482
|
+
should "transfers should be listable" do
|
483
|
+
@mock.expects(:get).once.returns(test_response(test_transfer_array))
|
484
|
+
t = Stripe::Transfer.all
|
485
|
+
assert t.data.kind_of? Array
|
486
|
+
t.each do |transfer|
|
487
|
+
assert transfer.kind_of?(Stripe::Transfer)
|
488
|
+
end
|
489
|
+
end
|
490
|
+
|
491
|
+
should "transfers should not be deletable" do
|
492
|
+
assert_raises NoMethodError do
|
493
|
+
@mock.expects(:get).once.returns(test_response(test_transfer))
|
494
|
+
t = Stripe::Transfer.retrieve("test_transfer")
|
495
|
+
t.delete
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
should "transfers should have BankAccount objects associated with their account property" do
|
500
|
+
@mock.expects(:get).once.returns(test_response(test_transfer))
|
501
|
+
t = Stripe::Transfer.retrieve("test_transfer")
|
502
|
+
assert t.account.kind_of?(Stripe::StripeObject) && t.account.object == 'bank_account'
|
503
|
+
end
|
504
|
+
|
505
|
+
should "create a transfer should return a new transfer when passed correct parameters" do
|
506
|
+
@mock.expects(:post).with do |url, api_key, params|
|
507
|
+
url == "#{Stripe.api_base}/v1/transfers" && api_key.nil? && CGI.parse(params) == {
|
508
|
+
'currency' => ['usd'], 'amount' => ['100'],
|
509
|
+
'recipient' => ['test_recipient']
|
510
|
+
}
|
511
|
+
end.once.returns(test_response(test_transfer))
|
512
|
+
|
513
|
+
t = Stripe::Transfer.create({
|
514
|
+
:amount => 100,
|
515
|
+
:currency => "usd",
|
516
|
+
:recipient => "test_recipient"
|
517
|
+
})
|
518
|
+
|
519
|
+
assert_equal 'pending', t.status
|
520
|
+
end
|
521
|
+
|
522
|
+
end
|
523
|
+
|
524
|
+
context "recipient tests" do
|
525
|
+
|
526
|
+
should "recipients should be listable" do
|
527
|
+
@mock.expects(:get).once.returns(test_response(test_recipient_array))
|
528
|
+
r = Stripe::Recipient.all.data
|
529
|
+
assert r.kind_of? Array
|
530
|
+
assert r[0].kind_of? Stripe::Recipient
|
531
|
+
end
|
532
|
+
|
533
|
+
should "recipients should be deletable" do
|
534
|
+
@mock.expects(:delete).once.returns(test_response(test_recipient({:deleted => true})))
|
535
|
+
r = Stripe::Recipient.new("test_recipient")
|
536
|
+
r.delete
|
537
|
+
assert r.deleted
|
538
|
+
end
|
539
|
+
|
540
|
+
should "recipients should be updateable" do
|
541
|
+
@mock.expects(:get).once.returns(test_response(test_recipient({:description => "foo"})))
|
542
|
+
@mock.expects(:post).once.returns(test_response(test_recipient({:description => "bar"})))
|
543
|
+
r = Stripe::Recipient.new("test_recipient").refresh
|
544
|
+
assert_equal r.description, "foo"
|
545
|
+
r.description = "bar"
|
546
|
+
r.save
|
547
|
+
assert_equal r.description, "bar"
|
548
|
+
end
|
549
|
+
|
550
|
+
should "recipients should have BankAccount objects associated with their active_account property" do
|
551
|
+
@mock.expects(:get).once.returns(test_response(test_recipient))
|
552
|
+
r = Stripe::Recipient.retrieve("test_recipient")
|
553
|
+
assert r.active_account.kind_of?(Stripe::StripeObject) && r.active_account.object == 'bank_account'
|
554
|
+
end
|
555
|
+
|
556
|
+
should "create should return a new recipient" do
|
557
|
+
@mock.expects(:post).once.returns(test_response(test_recipient))
|
558
|
+
r = Stripe::Recipient.create(:name => 'Stripe User', :type => 'individual')
|
559
|
+
assert_equal "rp_test_recipient", r.id
|
560
|
+
end
|
561
|
+
end
|
562
|
+
|
471
563
|
context "error checking" do
|
472
564
|
|
473
565
|
should "404s should raise an InvalidRequestError" do
|
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.
|
4
|
+
version: 1.8.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-04-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,15 @@ dependencies:
|
|
22
22
|
version: '1.4'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '1.4'
|
26
31
|
- !ruby/object:Gem::Dependency
|
27
32
|
name: multi_json
|
28
|
-
requirement:
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
29
34
|
none: false
|
30
35
|
requirements:
|
31
36
|
- - ! '>='
|
@@ -36,10 +41,18 @@ dependencies:
|
|
36
41
|
version: '2'
|
37
42
|
type: :runtime
|
38
43
|
prerelease: false
|
39
|
-
version_requirements:
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.0.4
|
50
|
+
- - <
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '2'
|
40
53
|
- !ruby/object:Gem::Dependency
|
41
54
|
name: mocha
|
42
|
-
requirement:
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
43
56
|
none: false
|
44
57
|
requirements:
|
45
58
|
- - ! '>='
|
@@ -47,10 +60,15 @@ dependencies:
|
|
47
60
|
version: '0'
|
48
61
|
type: :development
|
49
62
|
prerelease: false
|
50
|
-
version_requirements:
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
51
69
|
- !ruby/object:Gem::Dependency
|
52
70
|
name: shoulda
|
53
|
-
requirement:
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
54
72
|
none: false
|
55
73
|
requirements:
|
56
74
|
- - ! '>='
|
@@ -58,10 +76,15 @@ dependencies:
|
|
58
76
|
version: '0'
|
59
77
|
type: :development
|
60
78
|
prerelease: false
|
61
|
-
version_requirements:
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
62
85
|
- !ruby/object:Gem::Dependency
|
63
86
|
name: test-unit
|
64
|
-
requirement:
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
65
88
|
none: false
|
66
89
|
requirements:
|
67
90
|
- - ! '>='
|
@@ -69,10 +92,15 @@ dependencies:
|
|
69
92
|
version: '0'
|
70
93
|
type: :development
|
71
94
|
prerelease: false
|
72
|
-
version_requirements:
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
73
101
|
- !ruby/object:Gem::Dependency
|
74
102
|
name: rake
|
75
|
-
requirement:
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
76
104
|
none: false
|
77
105
|
requirements:
|
78
106
|
- - ! '>='
|
@@ -80,7 +108,12 @@ dependencies:
|
|
80
108
|
version: '0'
|
81
109
|
type: :development
|
82
110
|
prerelease: false
|
83
|
-
version_requirements:
|
111
|
+
version_requirements: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
84
117
|
description: Stripe is the easiest way to accept payments online. See https://stripe.com
|
85
118
|
for details.
|
86
119
|
email:
|
@@ -127,6 +160,7 @@ files:
|
|
127
160
|
- lib/stripe/json.rb
|
128
161
|
- lib/stripe/list_object.rb
|
129
162
|
- lib/stripe/plan.rb
|
163
|
+
- lib/stripe/recipient.rb
|
130
164
|
- lib/stripe/singleton_api_resource.rb
|
131
165
|
- lib/stripe/stripe_object.rb
|
132
166
|
- lib/stripe/token.rb
|
@@ -157,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
191
|
version: '0'
|
158
192
|
requirements: []
|
159
193
|
rubyforge_project:
|
160
|
-
rubygems_version: 1.8.
|
194
|
+
rubygems_version: 1.8.23
|
161
195
|
signing_key:
|
162
196
|
specification_version: 3
|
163
197
|
summary: Ruby bindings for the Stripe API
|