braintree 2.16.0 → 2.17.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/lib/braintree/address_gateway.rb +1 -1
- data/lib/braintree/credit_card.rb +8 -2
- data/lib/braintree/credit_card_gateway.rb +1 -1
- data/lib/braintree/customer_gateway.rb +1 -1
- data/lib/braintree/subscription_gateway.rb +1 -1
- data/lib/braintree/test/credit_card_numbers.rb +2 -1
- data/lib/braintree/version.rb +1 -1
- data/spec/integration/braintree/credit_card_spec.rb +37 -0
- data/spec/integration/braintree/customer_spec.rb +1 -1
- data/spec/unit/braintree/address_spec.rb +7 -0
- data/spec/unit/braintree/credit_card_spec.rb +7 -0
- data/spec/unit/braintree/customer_spec.rb +7 -0
- data/spec/unit/braintree/subscription_spec.rb +7 -0
- metadata +4 -4
@@ -31,7 +31,7 @@ module Braintree
|
|
31
31
|
|
32
32
|
def find(customer_or_customer_id, address_id)
|
33
33
|
customer_id = _determine_customer_id(customer_or_customer_id)
|
34
|
-
raise ArgumentError if address_id.nil? || address_id.strip
|
34
|
+
raise ArgumentError if address_id.nil? || address_id.to_s.strip == ""
|
35
35
|
response = @config.http.get("/customers/#{customer_id}/addresses/#{address_id}")
|
36
36
|
Address._new(@gateway, response[:address])
|
37
37
|
rescue NotFoundError
|
@@ -26,8 +26,14 @@ module Braintree
|
|
26
26
|
US = "us"
|
27
27
|
end
|
28
28
|
|
29
|
+
module Prepaid
|
30
|
+
Yes = "Yes"
|
31
|
+
No = "No"
|
32
|
+
Unknown = "Unknown"
|
33
|
+
end
|
34
|
+
|
29
35
|
attr_reader :billing_address, :bin, :card_type, :cardholder_name, :created_at, :customer_id, :expiration_month,
|
30
|
-
:expiration_year, :last_4, :unique_number_identifier, :subscriptions, :token, :updated_at
|
36
|
+
:expiration_year, :last_4, :prepaid, :unique_number_identifier, :subscriptions, :token, :updated_at
|
31
37
|
|
32
38
|
# See http://www.braintreepayments.com/docs/ruby/credit_cards/create
|
33
39
|
def self.create(attributes)
|
@@ -227,7 +233,7 @@ module Braintree
|
|
227
233
|
def self._attributes # :nodoc:
|
228
234
|
[
|
229
235
|
:billing_address, :bin, :card_type, :cardholder_name, :created_at, :customer_id, :expiration_month,
|
230
|
-
:expiration_year, :last_4, :token, :updated_at
|
236
|
+
:expiration_year, :last_4, :token, :updated_at, :prepaid
|
231
237
|
]
|
232
238
|
end
|
233
239
|
|
@@ -41,7 +41,7 @@ module Braintree
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def find(token)
|
44
|
-
raise ArgumentError if token.nil? || token.strip
|
44
|
+
raise ArgumentError if token.nil? || token.to_s.strip == ""
|
45
45
|
response = @config.http.get "/payment_methods/#{token}"
|
46
46
|
CreditCard._new(@gateway, response[:credit_card])
|
47
47
|
rescue NotFoundError
|
@@ -33,7 +33,7 @@ module Braintree
|
|
33
33
|
|
34
34
|
def find(customer_id)
|
35
35
|
raise ArgumentError, "customer_id contains invalid characters" unless customer_id.to_s =~ /\A[\w-]+\z/
|
36
|
-
raise ArgumentError, "customer_id cannot be blank" if customer_id.nil?|| customer_id.strip
|
36
|
+
raise ArgumentError, "customer_id cannot be blank" if customer_id.nil?|| customer_id.to_s.strip == ""
|
37
37
|
response = @config.http.get("/customers/#{customer_id}")
|
38
38
|
Customer._new(@gateway, response[:customer])
|
39
39
|
rescue NotFoundError
|
@@ -24,7 +24,7 @@ module Braintree
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def find(id)
|
27
|
-
raise ArgumentError if id.nil? || id.strip
|
27
|
+
raise ArgumentError if id.nil? || id.to_s.strip == ""
|
28
28
|
response = @config.http.get "/subscriptions/#{id}"
|
29
29
|
Subscription._new(@gateway, response[:subscription])
|
30
30
|
rescue NotFoundError
|
@@ -21,8 +21,9 @@ module Braintree
|
|
21
21
|
|
22
22
|
Visa = "4012888888881881"
|
23
23
|
VisaInternational = "4009348888881881" # :nodoc:
|
24
|
+
VisaPrepaid = "4500600000000061"
|
24
25
|
|
25
|
-
Visas = %w[4009348888881881 4012888888881881 4111111111111111 4000111111111115]
|
26
|
+
Visas = %w[4009348888881881 4012888888881881 4111111111111111 4000111111111115 4500600000000061]
|
26
27
|
Unknowns = %w[1000000000000008]
|
27
28
|
|
28
29
|
module FailsSandboxVerification
|
data/lib/braintree/version.rb
CHANGED
@@ -243,6 +243,43 @@ describe Braintree::CreditCard do
|
|
243
243
|
|
244
244
|
Braintree::CreditCard.find(card1.token).should_not be_default
|
245
245
|
end
|
246
|
+
|
247
|
+
it "sets the prepaid field if the card is prepaid" do
|
248
|
+
customer = Braintree::Customer.create!
|
249
|
+
result = Braintree::CreditCard.create(
|
250
|
+
:customer_id => customer.id,
|
251
|
+
:number => Braintree::Test::CreditCardNumbers::VisaPrepaid,
|
252
|
+
:expiration_date => "05/2014",
|
253
|
+
:options => {:verify_card => true}
|
254
|
+
)
|
255
|
+
credit_card = result.credit_card
|
256
|
+
credit_card.prepaid.should == Braintree::CreditCard::Prepaid::Yes
|
257
|
+
end
|
258
|
+
|
259
|
+
it "sets negative card type identifiers" do
|
260
|
+
customer = Braintree::Customer.create!
|
261
|
+
result = Braintree::CreditCard.create(
|
262
|
+
:customer_id => customer.id,
|
263
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
264
|
+
:expiration_date => "05/2014",
|
265
|
+
:options => {:verify_card => true}
|
266
|
+
)
|
267
|
+
credit_card = result.credit_card
|
268
|
+
credit_card.prepaid.should == Braintree::CreditCard::Prepaid::No
|
269
|
+
end
|
270
|
+
|
271
|
+
it "doesn't set the card type identifiers for an un-identified card" do
|
272
|
+
customer = Braintree::Customer.create!
|
273
|
+
result = Braintree::CreditCard.create(
|
274
|
+
:customer_id => customer.id,
|
275
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
276
|
+
:expiration_date => "05/2014",
|
277
|
+
:options => {:verify_card => true}
|
278
|
+
)
|
279
|
+
credit_card = result.credit_card
|
280
|
+
credit_card.prepaid.should == Braintree::CreditCard::Prepaid::Unknown
|
281
|
+
end
|
282
|
+
|
246
283
|
end
|
247
284
|
|
248
285
|
describe "self.create!" do
|
@@ -140,7 +140,7 @@ describe Braintree::Customer do
|
|
140
140
|
:first_name => "Mike",
|
141
141
|
:last_name => "Jones",
|
142
142
|
:credit_card => {
|
143
|
-
:number => Braintree::Test::CreditCardNumbers::
|
143
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
144
144
|
:expiration_date => "05/2015",
|
145
145
|
:options => {:fail_on_duplicate_payment_method => true}
|
146
146
|
}
|
@@ -78,6 +78,13 @@ describe Braintree::Address do
|
|
78
78
|
Braintree::Address.find("customer_id", nil)
|
79
79
|
end.to raise_error(ArgumentError)
|
80
80
|
end
|
81
|
+
|
82
|
+
it "does not raise an error if address_id does not respond to strip" do
|
83
|
+
Braintree::Http.stub(:new).and_return stub.as_null_object
|
84
|
+
expect do
|
85
|
+
Braintree::Address.find("customer_id", 8675309)
|
86
|
+
end.to_not raise_error(NoMethodError)
|
87
|
+
end
|
81
88
|
end
|
82
89
|
|
83
90
|
describe "self.new" do
|
@@ -137,6 +137,13 @@ describe Braintree::CreditCard do
|
|
137
137
|
Braintree::CreditCard.find(nil)
|
138
138
|
end.to raise_error(ArgumentError)
|
139
139
|
end
|
140
|
+
|
141
|
+
it "does not raise an error if address_id does not respond to strip" do
|
142
|
+
Braintree::Http.stub(:new).and_return stub.as_null_object
|
143
|
+
expect do
|
144
|
+
Braintree::CreditCard.find(8675309)
|
145
|
+
end.to_not raise_error(NoMethodError)
|
146
|
+
end
|
140
147
|
end
|
141
148
|
|
142
149
|
describe "inspect" do
|
@@ -53,6 +53,13 @@ describe Braintree::Customer do
|
|
53
53
|
Braintree::Customer.find(nil)
|
54
54
|
end.to raise_error(ArgumentError)
|
55
55
|
end
|
56
|
+
|
57
|
+
it "does not raise an exception if the id is a fixnum" do
|
58
|
+
Braintree::Http.stub(:new).and_return stub.as_null_object
|
59
|
+
expect do
|
60
|
+
Braintree::Customer.find(8675309)
|
61
|
+
end.to_not raise_error(NoMethodError)
|
62
|
+
end
|
56
63
|
end
|
57
64
|
|
58
65
|
describe "self.update" do
|
@@ -40,6 +40,13 @@ describe Braintree::Subscription do
|
|
40
40
|
Braintree::Subscription.find(nil)
|
41
41
|
end.to raise_error(ArgumentError)
|
42
42
|
end
|
43
|
+
|
44
|
+
it "does not raise an error if subscription id does not respond to strip" do
|
45
|
+
Braintree::Http.stub(:new).and_return stub(:get => {:subscription => default_params})
|
46
|
+
expect do
|
47
|
+
Braintree::Subscription.find(8675309)
|
48
|
+
end.to_not raise_error(NoMethodError)
|
49
|
+
end
|
43
50
|
end
|
44
51
|
|
45
52
|
describe "self.search" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: braintree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 75
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
8
|
+
- 17
|
9
9
|
- 0
|
10
|
-
version: 2.
|
10
|
+
version: 2.17.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Braintree
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-09-13 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|