stripe 1.8.8 → 1.9.9
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/History.txt +10 -0
- data/VERSION +1 -1
- data/lib/stripe.rb +1 -0
- data/lib/stripe/application_fee.rb +21 -0
- data/lib/stripe/util.rb +2 -1
- data/lib/stripe/version.rb +1 -1
- data/stripe.gemspec +1 -0
- data/test/stripe/api_resource_test.rb +17 -14
- data/test/stripe/application_fee_test.rb +22 -0
- data/test/stripe/customer_test.rb +3 -3
- data/test/test_helper.rb +23 -0
- metadata +21 -2
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 1.9.9 2013-12-02
|
2
|
+
|
3
|
+
* Add ApplicationFee API resource
|
4
|
+
|
5
|
+
=== 1.8.9 2013-11-14
|
6
|
+
|
7
|
+
* 2 bugfixes:
|
8
|
+
* Fix gemspec dependencies so the gem doesn't break for Ruby 1.8 users
|
9
|
+
* Fix api_resource_test to not use returns as a way of testing rescue behavior
|
10
|
+
|
1
11
|
=== 1.8.8 2013-10-3
|
2
12
|
|
3
13
|
* Add support for metadata API
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.9.9
|
data/lib/stripe.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Stripe
|
2
|
+
class ApplicationFee < APIResource
|
3
|
+
include Stripe::APIOperations::List
|
4
|
+
|
5
|
+
def self.url
|
6
|
+
'/v1/application_fees'
|
7
|
+
end
|
8
|
+
|
9
|
+
def refund(params={})
|
10
|
+
response, api_key = Stripe.request(:post, refund_url, @api_key, params)
|
11
|
+
refresh_from(response, api_key)
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def refund_url
|
18
|
+
url + '/refund'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/stripe/util.rb
CHANGED
data/lib/stripe/version.rb
CHANGED
data/stripe.gemspec
CHANGED
@@ -12,6 +12,7 @@ spec = Gem::Specification.new do |s|
|
|
12
12
|
s.homepage = 'https://stripe.com/api'
|
13
13
|
|
14
14
|
s.add_dependency('rest-client', '~> 1.4')
|
15
|
+
s.add_dependency('mime-types', '~> 1.25')
|
15
16
|
s.add_dependency('multi_json', '>= 1.0.4', '< 2')
|
16
17
|
|
17
18
|
s.add_development_dependency('mocha', '~> 0.13.2')
|
@@ -5,12 +5,12 @@ module Stripe
|
|
5
5
|
class ApiResourceTest < Test::Unit::TestCase
|
6
6
|
should "creating a new APIResource should not fetch over the network" do
|
7
7
|
@mock.expects(:get).never
|
8
|
-
|
8
|
+
Stripe::Customer.new("someid")
|
9
9
|
end
|
10
10
|
|
11
11
|
should "creating a new APIResource from a hash should not fetch over the network" do
|
12
12
|
@mock.expects(:get).never
|
13
|
-
|
13
|
+
Stripe::Customer.construct_from({
|
14
14
|
:id => "somecustomer",
|
15
15
|
:card => {:id => "somecard", :object => "card"},
|
16
16
|
:object => "customer"
|
@@ -185,14 +185,14 @@ module Stripe
|
|
185
185
|
(url =~ %r{^#{Stripe.api_base}/v1/charges?} &&
|
186
186
|
query.keys.sort == ['offset', 'sad'])
|
187
187
|
end.returns(test_response({ :count => 1, :data => [test_charge] }))
|
188
|
-
|
188
|
+
Stripe::Charge.all(:count => nil, :offset => 5, :sad => false)
|
189
189
|
|
190
190
|
@mock.expects(:post).with do |url, api_key, params|
|
191
|
-
url == "#{Stripe.api_base}/v1/charges" &&
|
192
|
-
api_key.nil? &&
|
191
|
+
url == "#{Stripe.api_base}/v1/charges" &&
|
192
|
+
api_key.nil? &&
|
193
193
|
CGI.parse(params) == { 'amount' => ['50'], 'currency' => ['usd'] }
|
194
194
|
end.returns(test_response({ :count => 1, :data => [test_charge] }))
|
195
|
-
|
195
|
+
Stripe::Charge.create(:amount => 50, :currency => 'usd', :card => { :number => nil })
|
196
196
|
end
|
197
197
|
|
198
198
|
should "requesting with a unicode ID should result in a request" do
|
@@ -210,7 +210,7 @@ module Stripe
|
|
210
210
|
should "making a GET request with parameters should have a query string and no body" do
|
211
211
|
params = { :limit => 1 }
|
212
212
|
@mock.expects(:get).once.with("#{Stripe.api_base}/v1/charges?limit=1", nil, nil).returns(test_response([test_charge]))
|
213
|
-
|
213
|
+
Stripe::Charge.all(params)
|
214
214
|
end
|
215
215
|
|
216
216
|
should "making a POST request with parameters should have a body and no query string" do
|
@@ -218,7 +218,7 @@ module Stripe
|
|
218
218
|
@mock.expects(:post).once.with do |url, get, post|
|
219
219
|
get.nil? && CGI.parse(post) == {'amount' => ['100'], 'currency' => ['usd'], 'card' => ['sc_token']}
|
220
220
|
end.returns(test_response(test_charge))
|
221
|
-
|
221
|
+
Stripe::Charge.create(params)
|
222
222
|
end
|
223
223
|
|
224
224
|
should "loading an object should issue a GET request" do
|
@@ -294,50 +294,53 @@ module Stripe
|
|
294
294
|
response = test_response(test_missing_id_error, 404)
|
295
295
|
@mock.expects(:get).once.raises(RestClient::ExceptionWithResponse.new(response, 404))
|
296
296
|
|
297
|
+
rescued = false
|
297
298
|
begin
|
298
299
|
Stripe::Customer.new("test_customer").refresh
|
299
300
|
assert false #shouldn't get here either
|
300
301
|
rescue Stripe::InvalidRequestError => e # we don't use assert_raises because we want to examine e
|
302
|
+
rescued = true
|
301
303
|
assert e.kind_of? Stripe::InvalidRequestError
|
302
304
|
assert_equal "id", e.param
|
303
305
|
assert_equal "Missing id", e.message
|
304
|
-
return
|
305
306
|
end
|
306
307
|
|
307
|
-
|
308
|
+
assert_equal true, rescued
|
308
309
|
end
|
309
310
|
|
310
311
|
should "5XXs should raise an APIError" do
|
311
312
|
response = test_response(test_api_error, 500)
|
312
313
|
@mock.expects(:get).once.raises(RestClient::ExceptionWithResponse.new(response, 500))
|
313
314
|
|
315
|
+
rescued = false
|
314
316
|
begin
|
315
317
|
Stripe::Customer.new("test_customer").refresh
|
316
318
|
assert false #shouldn't get here either
|
317
319
|
rescue Stripe::APIError => e # we don't use assert_raises because we want to examine e
|
320
|
+
rescued = true
|
318
321
|
assert e.kind_of? Stripe::APIError
|
319
|
-
return
|
320
322
|
end
|
321
323
|
|
322
|
-
|
324
|
+
assert_equal true, rescued
|
323
325
|
end
|
324
326
|
|
325
327
|
should "402s should raise a CardError" do
|
326
328
|
response = test_response(test_invalid_exp_year_error, 402)
|
327
329
|
@mock.expects(:get).once.raises(RestClient::ExceptionWithResponse.new(response, 402))
|
328
330
|
|
331
|
+
rescued = false
|
329
332
|
begin
|
330
333
|
Stripe::Customer.new("test_customer").refresh
|
331
334
|
assert false #shouldn't get here either
|
332
335
|
rescue Stripe::CardError => e # we don't use assert_raises because we want to examine e
|
336
|
+
rescued = true
|
333
337
|
assert e.kind_of? Stripe::CardError
|
334
338
|
assert_equal "invalid_expiry_year", e.code
|
335
339
|
assert_equal "exp_year", e.param
|
336
340
|
assert_equal "Your card's expiration year is invalid", e.message
|
337
|
-
return
|
338
341
|
end
|
339
342
|
|
340
|
-
|
343
|
+
assert_equal true, rescued
|
341
344
|
end
|
342
345
|
end
|
343
346
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class ApplicationFeeTest < Test::Unit::TestCase
|
5
|
+
should "application fees should be listable" do
|
6
|
+
@mock.expects(:get).once.returns(test_response(test_application_fee_array))
|
7
|
+
fees = Stripe::ApplicationFee.all
|
8
|
+
assert fees.data.kind_of? Array
|
9
|
+
fees.each do |fee|
|
10
|
+
assert fee.kind_of?(Stripe::ApplicationFee)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
should "application fees should be refundable" do
|
15
|
+
@mock.expects(:get).never
|
16
|
+
@mock.expects(:post).once.returns(test_response({:id => "fee_test_fee", :refunded => true}))
|
17
|
+
fee = Stripe::ApplicationFee.new("test_application_fee")
|
18
|
+
fee.refund
|
19
|
+
assert fee.refunded
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -52,10 +52,10 @@ module Stripe
|
|
52
52
|
# Not an accurate response, but whatever
|
53
53
|
|
54
54
|
@mock.expects(:delete).once.with("#{Stripe.api_base}/v1/customers/c_test_customer/subscription?at_period_end=true", nil, nil).returns(test_response(test_subscription('silver')))
|
55
|
-
|
55
|
+
c.cancel_subscription({:at_period_end => 'true'})
|
56
56
|
|
57
57
|
@mock.expects(:delete).once.with("#{Stripe.api_base}/v1/customers/c_test_customer/subscription", nil, nil).returns(test_response(test_subscription('silver')))
|
58
|
-
|
58
|
+
c.cancel_subscription
|
59
59
|
end
|
60
60
|
|
61
61
|
should "be able to delete a customer's discount" do
|
@@ -63,7 +63,7 @@ module Stripe
|
|
63
63
|
c = Stripe::Customer.retrieve("test_customer")
|
64
64
|
|
65
65
|
@mock.expects(:delete).once.with("#{Stripe.api_base}/v1/customers/c_test_customer/discount", nil, nil).returns(test_response(test_delete_discount_response))
|
66
|
-
|
66
|
+
c.delete_discount
|
67
67
|
assert_equal nil, c.discount
|
68
68
|
end
|
69
69
|
end
|
data/test/test_helper.rb
CHANGED
@@ -70,6 +70,29 @@ def test_balance_transaction_array
|
|
70
70
|
}
|
71
71
|
end
|
72
72
|
|
73
|
+
def test_application_fee(params={})
|
74
|
+
{
|
75
|
+
:refunded => false,
|
76
|
+
:amount => 100,
|
77
|
+
:application => "ca_test_application",
|
78
|
+
:user => "acct_test_user",
|
79
|
+
:charge => "ch_test_charge",
|
80
|
+
:id => "fee_test_fee",
|
81
|
+
:livemode => false,
|
82
|
+
:currency => "usd",
|
83
|
+
:object => "application_fee",
|
84
|
+
:created => 1304114826
|
85
|
+
}.merge(params)
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_application_fee_array
|
89
|
+
{
|
90
|
+
:data => [test_application_fee, test_application_fee, test_application_fee],
|
91
|
+
:object => 'list',
|
92
|
+
:url => '/v1/application_fees'
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
73
96
|
def test_customer(params={})
|
74
97
|
{
|
75
98
|
:subscription_history => [],
|
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.9.9
|
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: 2013-
|
13
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -28,6 +28,22 @@ dependencies:
|
|
28
28
|
- - ~>
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: '1.4'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: mime-types
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ~>
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '1.25'
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.25'
|
31
47
|
- !ruby/object:Gem::Dependency
|
32
48
|
name: multi_json
|
33
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,6 +161,7 @@ files:
|
|
145
161
|
- lib/stripe/api_operations/list.rb
|
146
162
|
- lib/stripe/api_operations/update.rb
|
147
163
|
- lib/stripe/api_resource.rb
|
164
|
+
- lib/stripe/application_fee.rb
|
148
165
|
- lib/stripe/balance.rb
|
149
166
|
- lib/stripe/balance_transaction.rb
|
150
167
|
- lib/stripe/card.rb
|
@@ -173,6 +190,7 @@ files:
|
|
173
190
|
- stripe.gemspec
|
174
191
|
- test/stripe/account_test.rb
|
175
192
|
- test/stripe/api_resource_test.rb
|
193
|
+
- test/stripe/application_fee_test.rb
|
176
194
|
- test/stripe/charge_test.rb
|
177
195
|
- test/stripe/coupon_test.rb
|
178
196
|
- test/stripe/customer_test.rb
|
@@ -208,6 +226,7 @@ summary: Ruby bindings for the Stripe API
|
|
208
226
|
test_files:
|
209
227
|
- test/stripe/account_test.rb
|
210
228
|
- test/stripe/api_resource_test.rb
|
229
|
+
- test/stripe/application_fee_test.rb
|
211
230
|
- test/stripe/charge_test.rb
|
212
231
|
- test/stripe/coupon_test.rb
|
213
232
|
- test/stripe/customer_test.rb
|