stripe 1.17.3 → 1.18.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@ rvm:
6
6
  - 1.9.3
7
7
  - 2.0.0
8
8
  - 2.1
9
+ - 2.2
9
10
 
10
11
  gemfile:
11
12
  - gemfiles/default-with-activesupport.gemfile
@@ -1,3 +1,8 @@
1
+ === 1.18.0 2015-01-21
2
+
3
+ * 1 major enhancement:
4
+ * Added support for making bitcoin charges through BitcoinReceiver source object
5
+
1
6
  === 1.17.3 2015-01-12
2
7
 
3
8
  * 1 bugfix:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.17.3
1
+ 1.18.0
@@ -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'
@@ -0,0 +1,10 @@
1
+ module Stripe
2
+ class BitcoinReceiver < APIResource
3
+ include Stripe::APIOperations::Create
4
+ include Stripe::APIOperations::List
5
+
6
+ def self.url
7
+ "/v1/bitcoin/receivers"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ module Stripe
2
+ class BitcoinTransaction < APIResource
3
+ end
4
+ end
@@ -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)
@@ -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
- 'transfer' => Transfer
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]
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = '1.17.3'
2
+ VERSION = '1.18.0'
3
3
  end
@@ -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")
@@ -26,7 +26,7 @@ module Stripe
26
26
 
27
27
  should "accessing id should not issue a fetch" do
28
28
  @mock.expects(:get).never
29
- c = Stripe::Customer.new("test_customer");
29
+ c = Stripe::Customer.new("test_customer")
30
30
  c.id
31
31
  end
32
32
 
@@ -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
@@ -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
@@ -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
- :mimetype => nil,
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.17.3
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-12 00:00:00.000000000 Z
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