stripe 1.11.0 → 1.12.0
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 +5 -0
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/stripe/card.rb +5 -1
- data/lib/stripe/certificate_blacklist.rb +8 -0
- data/lib/stripe/version.rb +1 -1
- data/test/stripe/customer_card_test.rb +57 -0
- data/test/stripe/recipient_card_test.rb +57 -0
- data/test/test_helper.rb +3 -0
- metadata +7 -2
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= Stripe Ruby bindings {<img src="https://gemnasium.com/stripe/stripe-ruby.png" alt="Dependency Status" />}[https://gemnasium.com/stripe/stripe-ruby]
|
1
|
+
= Stripe Ruby bindings {<img src="https://travis-ci.org/stripe/stripe-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/stripe/stripe-ruby] {<img src="https://gemnasium.com/stripe/stripe-ruby.png" alt="Dependency Status" />}[https://gemnasium.com/stripe/stripe-ruby]
|
2
2
|
|
3
3
|
== Installation
|
4
4
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.12.0
|
data/lib/stripe/card.rb
CHANGED
@@ -5,7 +5,11 @@ module Stripe
|
|
5
5
|
include Stripe::APIOperations::List
|
6
6
|
|
7
7
|
def url
|
8
|
-
|
8
|
+
if respond_to?(:recipient)
|
9
|
+
"#{Recipient.url}/#{CGI.escape(recipient)}/cards/#{CGI.escape(id)}"
|
10
|
+
elsif respond_to?(:customer)
|
11
|
+
"#{Customer.url}/#{CGI.escape(customer)}/cards/#{CGI.escape(id)}"
|
12
|
+
end
|
9
13
|
end
|
10
14
|
|
11
15
|
def self.retrieve(id, api_key=nil)
|
@@ -13,6 +13,14 @@ module Stripe
|
|
13
13
|
]
|
14
14
|
}
|
15
15
|
|
16
|
+
# Preflight the SSL certificate presented by the backend. This isn't 100%
|
17
|
+
# bulletproof, in that we're not actually validating the transport used to
|
18
|
+
# communicate with Stripe, merely that the first attempt to does not use a
|
19
|
+
# revoked certificate.
|
20
|
+
|
21
|
+
# Unfortunately the interface to OpenSSL doesn't make it easy to check the
|
22
|
+
# certificate before sending potentially sensitive data on the wire. This
|
23
|
+
# approach raises the bar for an attacker significantly.
|
16
24
|
|
17
25
|
def self.check_ssl_cert(uri, ca_file)
|
18
26
|
uri = URI.parse(uri)
|
data/lib/stripe/version.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class CustomerCardTest < Test::Unit::TestCase
|
5
|
+
CUSTOMER_CARD_URL = '/v1/customers/test_customer/cards/test_card'
|
6
|
+
|
7
|
+
def customer
|
8
|
+
@mock.expects(:get).once.returns(test_response(test_customer))
|
9
|
+
Stripe::Customer.retrieve('test_customer')
|
10
|
+
end
|
11
|
+
|
12
|
+
should "customer cards should be listable" do
|
13
|
+
c = customer
|
14
|
+
@mock.expects(:get).once.returns(test_response(test_card_array(customer.id)))
|
15
|
+
cards = c.cards.all.data
|
16
|
+
assert cards.kind_of? Array
|
17
|
+
assert cards[0].kind_of? Stripe::Card
|
18
|
+
end
|
19
|
+
|
20
|
+
should "customer cards should have the correct url" do
|
21
|
+
c = customer
|
22
|
+
@mock.expects(:get).once.returns(test_response(test_card(
|
23
|
+
:id => 'test_card',
|
24
|
+
:customer => 'test_customer'
|
25
|
+
)))
|
26
|
+
card = c.cards.retrieve('card')
|
27
|
+
assert_equal CUSTOMER_CARD_URL, card.url
|
28
|
+
end
|
29
|
+
|
30
|
+
should "customer cards should be deletable" do
|
31
|
+
c = customer
|
32
|
+
@mock.expects(:get).once.returns(test_response(test_card))
|
33
|
+
@mock.expects(:delete).once.returns(test_response(test_card(:deleted => true)))
|
34
|
+
card = c.cards.retrieve('card')
|
35
|
+
card.delete
|
36
|
+
assert card.deleted
|
37
|
+
end
|
38
|
+
|
39
|
+
should "customer cards should be updateable" do
|
40
|
+
c = customer
|
41
|
+
@mock.expects(:get).once.returns(test_response(test_card(:exp_year => "2000")))
|
42
|
+
@mock.expects(:post).once.returns(test_response(test_card(:exp_year => "2100")))
|
43
|
+
card = c.cards.retrieve('card')
|
44
|
+
assert_equal "2000", card.exp_year
|
45
|
+
card.exp_year = "2100"
|
46
|
+
card.save
|
47
|
+
assert_equal "2100", card.exp_year
|
48
|
+
end
|
49
|
+
|
50
|
+
should "create should return a new customer card" do
|
51
|
+
c = customer
|
52
|
+
@mock.expects(:post).once.returns(test_response(test_card(:id => "test_card")))
|
53
|
+
card = c.cards.create(:card => "tok_41YJ05ijAaWaFS")
|
54
|
+
assert_equal "test_card", card.id
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class RecipientCardTest < Test::Unit::TestCase
|
5
|
+
RECIPIENT_CARD_URL = '/v1/recipients/test_recipient/cards/test_card'
|
6
|
+
|
7
|
+
def recipient
|
8
|
+
@mock.expects(:get).once.returns(test_response(test_recipient))
|
9
|
+
Stripe::Recipient.retrieve('test_recipient')
|
10
|
+
end
|
11
|
+
|
12
|
+
should "recipient cards should be listable" do
|
13
|
+
c = recipient
|
14
|
+
@mock.expects(:get).once.returns(test_response(test_card_array(recipient.id)))
|
15
|
+
cards = c.cards.all.data
|
16
|
+
assert cards.kind_of? Array
|
17
|
+
assert cards[0].kind_of? Stripe::Card
|
18
|
+
end
|
19
|
+
|
20
|
+
should "recipient cards should have the correct url" do
|
21
|
+
c = recipient
|
22
|
+
@mock.expects(:get).once.returns(test_response(test_card(
|
23
|
+
:id => 'test_card',
|
24
|
+
:recipient => 'test_recipient'
|
25
|
+
)))
|
26
|
+
card = c.cards.retrieve('card')
|
27
|
+
assert_equal RECIPIENT_CARD_URL, card.url
|
28
|
+
end
|
29
|
+
|
30
|
+
should "recipient cards should be deletable" do
|
31
|
+
c = recipient
|
32
|
+
@mock.expects(:get).once.returns(test_response(test_card))
|
33
|
+
@mock.expects(:delete).once.returns(test_response(test_card(:deleted => true)))
|
34
|
+
card = c.cards.retrieve('card')
|
35
|
+
card.delete
|
36
|
+
assert card.deleted
|
37
|
+
end
|
38
|
+
|
39
|
+
should "recipient cards should be updateable" do
|
40
|
+
c = recipient
|
41
|
+
@mock.expects(:get).once.returns(test_response(test_card(:exp_year => "2000")))
|
42
|
+
@mock.expects(:post).once.returns(test_response(test_card(:exp_year => "2100")))
|
43
|
+
card = c.cards.retrieve('card')
|
44
|
+
assert_equal "2000", card.exp_year
|
45
|
+
card.exp_year = "2100"
|
46
|
+
card.save
|
47
|
+
assert_equal "2100", card.exp_year
|
48
|
+
end
|
49
|
+
|
50
|
+
should "create should return a new recipient card" do
|
51
|
+
c = recipient
|
52
|
+
@mock.expects(:post).once.returns(test_response(test_card(:id => "test_card")))
|
53
|
+
card = c.cards.create(:card => "tok_41YJ05ijAaWaFS")
|
54
|
+
assert_equal "test_card", card.id
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -273,12 +273,15 @@ def test_invoice_customer_array
|
|
273
273
|
end
|
274
274
|
|
275
275
|
def test_recipient(params={})
|
276
|
+
id = params[:id] || 'rp_test_recipient'
|
276
277
|
{
|
277
278
|
:name => "Stripe User",
|
278
279
|
:type => "individual",
|
279
280
|
:livemode => false,
|
280
281
|
:object => "recipient",
|
281
282
|
:id => "rp_test_recipient",
|
283
|
+
:cards => test_card_array(id),
|
284
|
+
:default_card => "debit_test_card",
|
282
285
|
:active_account => {
|
283
286
|
:last4 => "6789",
|
284
287
|
:bank_name => "STRIPE TEST BANK",
|
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.12.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: 2014-
|
13
|
+
date: 2014-05-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
@@ -189,10 +189,12 @@ files:
|
|
189
189
|
- test/stripe/certificate_blacklist_test.rb
|
190
190
|
- test/stripe/charge_test.rb
|
191
191
|
- test/stripe/coupon_test.rb
|
192
|
+
- test/stripe/customer_card_test.rb
|
192
193
|
- test/stripe/customer_test.rb
|
193
194
|
- test/stripe/invoice_test.rb
|
194
195
|
- test/stripe/list_object_test.rb
|
195
196
|
- test/stripe/metadata_test.rb
|
197
|
+
- test/stripe/recipient_card_test.rb
|
196
198
|
- test/stripe/stripe_object_test.rb
|
197
199
|
- test/stripe/subscription_test.rb
|
198
200
|
- test/stripe/util_test.rb
|
@@ -229,11 +231,14 @@ test_files:
|
|
229
231
|
- test/stripe/certificate_blacklist_test.rb
|
230
232
|
- test/stripe/charge_test.rb
|
231
233
|
- test/stripe/coupon_test.rb
|
234
|
+
- test/stripe/customer_card_test.rb
|
232
235
|
- test/stripe/customer_test.rb
|
233
236
|
- test/stripe/invoice_test.rb
|
234
237
|
- test/stripe/list_object_test.rb
|
235
238
|
- test/stripe/metadata_test.rb
|
239
|
+
- test/stripe/recipient_card_test.rb
|
236
240
|
- test/stripe/stripe_object_test.rb
|
237
241
|
- test/stripe/subscription_test.rb
|
238
242
|
- test/stripe/util_test.rb
|
239
243
|
- test/test_helper.rb
|
244
|
+
has_rdoc:
|