stripe 1.17.3 → 1.18.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -0
- data/History.txt +5 -0
- data/VERSION +1 -1
- data/lib/stripe.rb +2 -0
- data/lib/stripe/bitcoin_receiver.rb +10 -0
- data/lib/stripe/bitcoin_transaction.rb +4 -0
- data/lib/stripe/file_upload.rb +7 -0
- data/lib/stripe/util.rb +7 -4
- data/lib/stripe/version.rb +1 -1
- data/stripe.gemspec +1 -0
- data/test/stripe/api_resource_test.rb +1 -1
- data/test/stripe/bitcoin_receiver_test.rb +38 -0
- data/test/stripe/charge_test.rb +17 -1
- data/test/stripe/file_upload_test.rb +7 -0
- data/test/test_data.rb +49 -1
- metadata +22 -2
data/.travis.yml
CHANGED
data/History.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.18.0
|
data/lib/stripe.rb
CHANGED
@@ -41,6 +41,8 @@ require 'stripe/subscription'
|
|
41
41
|
require 'stripe/application_fee'
|
42
42
|
require 'stripe/refund'
|
43
43
|
require 'stripe/application_fee_refund'
|
44
|
+
require 'stripe/bitcoin_receiver'
|
45
|
+
require 'stripe/bitcoin_transaction'
|
44
46
|
|
45
47
|
# Errors
|
46
48
|
require 'stripe/errors/stripe_error'
|
data/lib/stripe/file_upload.rb
CHANGED
@@ -18,6 +18,13 @@ module Stripe
|
|
18
18
|
Util.convert_to_stripe_object(response, api_key)
|
19
19
|
end
|
20
20
|
|
21
|
+
def self.all(filters={}, opts={})
|
22
|
+
api_key, headers = Util.parse_opts(opts)
|
23
|
+
response, api_key = Stripe.request(
|
24
|
+
:get, self.url, api_key, filters, headers, UPLOADS_API_BASE)
|
25
|
+
Util.convert_to_stripe_object(response, api_key)
|
26
|
+
end
|
27
|
+
|
21
28
|
def refresh
|
22
29
|
response, api_key = Stripe.request(
|
23
30
|
:get, url, @api_key, @retrieve_options, self.class.request_headers, UPLOADS_API_BASE)
|
data/lib/stripe/util.rb
CHANGED
@@ -19,7 +19,7 @@ module Stripe
|
|
19
19
|
@object_classes ||= {
|
20
20
|
# data structures
|
21
21
|
'list' => ListObject,
|
22
|
-
|
22
|
+
|
23
23
|
# business objects
|
24
24
|
'application_fee' => ApplicationFee,
|
25
25
|
'balance' => Balance,
|
@@ -35,8 +35,11 @@ module Stripe
|
|
35
35
|
'plan' => Plan,
|
36
36
|
'recipient' => Recipient,
|
37
37
|
'refund' => Refund,
|
38
|
-
'subscription' => Subscription,
|
39
|
-
'
|
38
|
+
'subscription' => Subscription,
|
39
|
+
'file_upload' => FileUpload,
|
40
|
+
'transfer' => Transfer,
|
41
|
+
'bitcoin_receiver' => BitcoinReceiver,
|
42
|
+
'bitcoin_transaction' => BitcoinTransaction
|
40
43
|
}
|
41
44
|
end
|
42
45
|
|
@@ -125,7 +128,7 @@ module Stripe
|
|
125
128
|
when Hash
|
126
129
|
headers = {}
|
127
130
|
if opts[:idempotency_key]
|
128
|
-
headers[:idempotency_key] = opts[:idempotency_key]
|
131
|
+
headers[:idempotency_key] = opts[:idempotency_key]
|
129
132
|
end
|
130
133
|
if opts[:stripe_account]
|
131
134
|
headers[:stripe_account] = opts[:stripe_account]
|
data/lib/stripe/version.rb
CHANGED
data/stripe.gemspec
CHANGED
@@ -20,6 +20,7 @@ spec = Gem::Specification.new do |s|
|
|
20
20
|
s.add_development_dependency('shoulda', '~> 3.4.0')
|
21
21
|
s.add_development_dependency('test-unit')
|
22
22
|
s.add_development_dependency('rake')
|
23
|
+
s.add_development_dependency('pry')
|
23
24
|
|
24
25
|
s.files = `git ls-files`.split("\n")
|
25
26
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class BitcoinReceiverTest < Test::Unit::TestCase
|
5
|
+
should "retrieve should retrieve bitcoin receiver" do
|
6
|
+
@mock.expects(:get).once.returns(test_response(test_bitcoin_receiver))
|
7
|
+
receiver = Stripe::BitcoinReceiver.retrieve('btcrcv_test_receiver')
|
8
|
+
assert_equal 'btcrcv_test_receiver', receiver.id
|
9
|
+
end
|
10
|
+
|
11
|
+
should "create should create a bitcoin receiver" do
|
12
|
+
@mock.expects(:post).once.returns(test_response(test_bitcoin_receiver))
|
13
|
+
receiver = Stripe::BitcoinReceiver.create
|
14
|
+
assert_equal "btcrcv_test_receiver", receiver.id
|
15
|
+
end
|
16
|
+
|
17
|
+
should "all should list bitcoin receivers" do
|
18
|
+
@mock.expects(:get).once.returns(test_response(test_bitcoin_receiver_array))
|
19
|
+
receivers = Stripe::BitcoinReceiver.all
|
20
|
+
assert_equal 3, receivers.data.length
|
21
|
+
assert receivers.data.kind_of? Array
|
22
|
+
receivers.each do |receiver|
|
23
|
+
assert receiver.kind_of?(Stripe::BitcoinReceiver)
|
24
|
+
receiver.transactions.data.each do |transaction|
|
25
|
+
assert transaction.kind_of?(Stripe::BitcoinTransaction)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
should "maintain bitcoin transaction sublist" do
|
31
|
+
@mock.expects(:get).with("#{Stripe.api_base}/v1/bitcoin/receivers/btcrcv_test_receiver", nil, nil).once.returns(test_response(test_bitcoin_receiver))
|
32
|
+
receiver = Stripe::BitcoinReceiver.retrieve('btcrcv_test_receiver')
|
33
|
+
@mock.expects(:get).with("#{Stripe.api_base}/v1/bitcoin/receivers/btcrcv_test_receiver/transactions", nil, nil).once.returns(test_response(test_bitcoin_transaction_array))
|
34
|
+
transactions = receiver.transactions.all
|
35
|
+
assert_equal(3, transactions.data.length)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/test/stripe/charge_test.rb
CHANGED
@@ -58,7 +58,7 @@ module Stripe
|
|
58
58
|
assert c.card.kind_of?(Stripe::StripeObject) && c.card.object == 'card'
|
59
59
|
end
|
60
60
|
|
61
|
-
should "execute should return a new, fully executed charge when passed correct parameters" do
|
61
|
+
should "execute should return a new, fully executed charge when passed correct `card` parameters" do
|
62
62
|
@mock.expects(:post).with do |url, api_key, params|
|
63
63
|
url == "#{Stripe.api_base}/v1/charges" && api_key.nil? && CGI.parse(params) == {
|
64
64
|
'currency' => ['usd'], 'amount' => ['100'],
|
@@ -79,5 +79,21 @@ module Stripe
|
|
79
79
|
})
|
80
80
|
assert c.paid
|
81
81
|
end
|
82
|
+
|
83
|
+
should "execute should return a new, fully executed charge when passed correct `source` parameters" do
|
84
|
+
@mock.expects(:post).with do |url, api_key, params|
|
85
|
+
url == "#{Stripe.api_base}/v1/charges" && api_key.nil? && CGI.parse(params) == {
|
86
|
+
'currency' => ['usd'], 'amount' => ['100'],
|
87
|
+
'source' => ['btcrcv_test_receiver']
|
88
|
+
}
|
89
|
+
end.once.returns(test_response(test_charge))
|
90
|
+
|
91
|
+
c = Stripe::Charge.create({
|
92
|
+
:amount => 100,
|
93
|
+
:source => 'btcrcv_test_receiver',
|
94
|
+
:currency => "usd"
|
95
|
+
})
|
96
|
+
assert c.paid
|
97
|
+
end
|
82
98
|
end
|
83
99
|
end
|
@@ -17,5 +17,12 @@ module Stripe
|
|
17
17
|
c.refresh
|
18
18
|
assert_equal 1403047735, c.created
|
19
19
|
end
|
20
|
+
|
21
|
+
should "files should be listable" do
|
22
|
+
@mock.expects(:get).once.returns(test_response(test_file_array))
|
23
|
+
c = Stripe::FileUpload.all.data
|
24
|
+
assert c.kind_of? Array
|
25
|
+
assert c[0].kind_of? Stripe::FileUpload
|
26
|
+
end
|
20
27
|
end
|
21
28
|
end
|
data/test/test_data.rb
CHANGED
@@ -185,12 +185,21 @@ module Stripe
|
|
185
185
|
|
186
186
|
def test_file(params={})
|
187
187
|
{
|
188
|
+
:object => "file_upload",
|
188
189
|
:id => "fil_test_file",
|
189
190
|
:created => 1403047735,
|
190
191
|
:size => 4908,
|
191
192
|
:purpose => params[:purpose] || "dispute_evidence",
|
192
193
|
:url => nil,
|
193
|
-
:
|
194
|
+
:type => nil,
|
195
|
+
}
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_file_array
|
199
|
+
{
|
200
|
+
:data => [test_file, test_file, test_file],
|
201
|
+
:object => 'list',
|
202
|
+
:url => '/v1/files'
|
194
203
|
}
|
195
204
|
end
|
196
205
|
|
@@ -372,6 +381,45 @@ module Stripe
|
|
372
381
|
})
|
373
382
|
end
|
374
383
|
|
384
|
+
def test_bitcoin_receiver(params={})
|
385
|
+
{
|
386
|
+
:id => 'btcrcv_test_receiver',
|
387
|
+
:amount => 100,
|
388
|
+
:currency => 'usd',
|
389
|
+
:description => 'some details',
|
390
|
+
:metadata => {},
|
391
|
+
:object => 'bitcoin_receiver',
|
392
|
+
:transactions => test_bitcoin_transaction_array
|
393
|
+
}.merge(params)
|
394
|
+
end
|
395
|
+
|
396
|
+
def test_bitcoin_receiver_array
|
397
|
+
{
|
398
|
+
:data => [test_bitcoin_receiver, test_bitcoin_receiver, test_bitcoin_receiver],
|
399
|
+
:object => 'list',
|
400
|
+
:url => '/v1/bitcoin/receivers'
|
401
|
+
}
|
402
|
+
end
|
403
|
+
|
404
|
+
def test_bitcoin_transaction(params={})
|
405
|
+
{
|
406
|
+
:id => 'btctxn_test_transaction',
|
407
|
+
:object => 'bitcoin_transaction',
|
408
|
+
:amount => 100,
|
409
|
+
:currency => 'usd',
|
410
|
+
:bitcoin_amount => 90,
|
411
|
+
:receiver => 'btcrcv_test_receiver'
|
412
|
+
}.merge(params)
|
413
|
+
end
|
414
|
+
|
415
|
+
def test_bitcoin_transaction_array
|
416
|
+
{
|
417
|
+
:data => [test_bitcoin_transaction, test_bitcoin_transaction, test_bitcoin_transaction],
|
418
|
+
:object => 'list',
|
419
|
+
:url => "/v1/bitcoin/receivers/btcrcv_test_receiver/transactions"
|
420
|
+
}
|
421
|
+
end
|
422
|
+
|
375
423
|
def test_invalid_api_key_error
|
376
424
|
{
|
377
425
|
:error => {
|
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.18.0
|
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: 2015-01-
|
13
|
+
date: 2015-01-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -130,6 +130,22 @@ dependencies:
|
|
130
130
|
- - ! '>='
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: '0'
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: pry
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
137
|
+
requirements:
|
138
|
+
- - ! '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
type: :development
|
142
|
+
prerelease: false
|
143
|
+
version_requirements: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ! '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
133
149
|
description: Stripe is the easiest way to accept payments online. See https://stripe.com
|
134
150
|
for details.
|
135
151
|
email:
|
@@ -165,6 +181,8 @@ files:
|
|
165
181
|
- lib/stripe/application_fee_refund.rb
|
166
182
|
- lib/stripe/balance.rb
|
167
183
|
- lib/stripe/balance_transaction.rb
|
184
|
+
- lib/stripe/bitcoin_receiver.rb
|
185
|
+
- lib/stripe/bitcoin_transaction.rb
|
168
186
|
- lib/stripe/card.rb
|
169
187
|
- lib/stripe/certificate_blacklist.rb
|
170
188
|
- lib/stripe/charge.rb
|
@@ -196,6 +214,7 @@ files:
|
|
196
214
|
- test/stripe/api_resource_test.rb
|
197
215
|
- test/stripe/application_fee_refund_test.rb
|
198
216
|
- test/stripe/application_fee_test.rb
|
217
|
+
- test/stripe/bitcoin_receiver_test.rb
|
199
218
|
- test/stripe/certificate_blacklist_test.rb
|
200
219
|
- test/stripe/charge_test.rb
|
201
220
|
- test/stripe/coupon_test.rb
|
@@ -243,6 +262,7 @@ test_files:
|
|
243
262
|
- test/stripe/api_resource_test.rb
|
244
263
|
- test/stripe/application_fee_refund_test.rb
|
245
264
|
- test/stripe/application_fee_test.rb
|
265
|
+
- test/stripe/bitcoin_receiver_test.rb
|
246
266
|
- test/stripe/certificate_blacklist_test.rb
|
247
267
|
- test/stripe/charge_test.rb
|
248
268
|
- test/stripe/coupon_test.rb
|