braintree 2.20.0 → 2.21.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/braintree/error_codes.rb +1 -0
- data/lib/braintree/transaction/credit_card_details.rb +4 -2
- data/lib/braintree/util.rb +2 -2
- data/lib/braintree/version.rb +1 -1
- data/spec/httpsd.pid +1 -1
- data/spec/integration/braintree/credit_card_verification_spec.rb +26 -0
- data/spec/integration/braintree/transaction_spec.rb +16 -1
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +11 -2
- data/spec/unit/braintree/transaction_spec.rb +16 -1
- metadata +4 -4
@@ -180,6 +180,7 @@ module Braintree
|
|
180
180
|
MerchantAccountNameIsInvalid = "91513" # Deprecated
|
181
181
|
OrderIdIsTooLong = "91501"
|
182
182
|
PaymentMethodConflict = "91515"
|
183
|
+
PaymentMethodConflictWithVenmoSDK = "91549"
|
183
184
|
PaymentMethodDoesNotBelongToCustomer = "91516"
|
184
185
|
PaymentMethodDoesNotBelongToSubscription = "91527"
|
185
186
|
PaymentMethodTokenCardTypeIsNotAccepted = "91517"
|
@@ -4,7 +4,8 @@ module Braintree
|
|
4
4
|
include BaseModule
|
5
5
|
|
6
6
|
attr_reader :bin, :card_type, :cardholder_name, :customer_location, :expiration_month,
|
7
|
-
:expiration_year, :last_4, :token
|
7
|
+
:expiration_year, :last_4, :token, :prepaid, :healthcare, :durbin_regulated, :debit,
|
8
|
+
:commercial, :payroll, :country_of_issuance, :issuing_bank
|
8
9
|
|
9
10
|
def initialize(attributes)
|
10
11
|
set_instance_variables_from_hash attributes unless attributes.nil?
|
@@ -15,7 +16,8 @@ module Braintree
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def inspect
|
18
|
-
attr_order = [:token, :bin, :last_4, :card_type, :expiration_date, :cardholder_name, :customer_location
|
19
|
+
attr_order = [:token, :bin, :last_4, :card_type, :expiration_date, :cardholder_name, :customer_location, :prepaid,
|
20
|
+
:healthcare, :durbin_regulated, :debit, :commercial, :payroll, :country_of_issuance, :issuing_bank]
|
19
21
|
formatted_attrs = attr_order.map do |attr|
|
20
22
|
"#{attr}: #{send(attr).inspect}"
|
21
23
|
end
|
data/lib/braintree/util.rb
CHANGED
@@ -26,11 +26,11 @@ module Braintree
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.url_decode(text)
|
29
|
-
CGI.unescape text.to_s
|
29
|
+
CGI.unescape text.to_s.to_str
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.url_encode(text)
|
33
|
-
CGI.escape text.to_s
|
33
|
+
CGI.escape text.to_s.to_str
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.symbolize_keys(hash)
|
data/lib/braintree/version.rb
CHANGED
data/spec/httpsd.pid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
44961
|
@@ -25,5 +25,31 @@ describe Braintree::CreditCardVerification, "search" do
|
|
25
25
|
Braintree::CreditCardVerification.find("invalid-id")
|
26
26
|
end.to raise_error(Braintree::NotFoundError, 'verification with id "invalid-id" not found')
|
27
27
|
end
|
28
|
+
|
29
|
+
describe "card type indicators" do
|
30
|
+
it "returns prepaid on a prepaid card" do
|
31
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
32
|
+
|
33
|
+
result = Braintree::Customer.create(
|
34
|
+
:credit_card => {
|
35
|
+
:cardholder_name => cardholder_name,
|
36
|
+
:expiration_date => "05/2012",
|
37
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
38
|
+
:cvv => '200',
|
39
|
+
:options => {
|
40
|
+
:verify_card => true
|
41
|
+
}
|
42
|
+
})
|
43
|
+
|
44
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
45
|
+
search.credit_card_cardholder_name.is cardholder_name
|
46
|
+
end
|
47
|
+
|
48
|
+
verification_id = search_results.first.id
|
49
|
+
|
50
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
51
|
+
found_verification.credit_card[:prepaid].should == Braintree::CreditCard::Prepaid::Yes
|
52
|
+
end
|
53
|
+
end
|
28
54
|
end
|
29
55
|
end
|
@@ -115,6 +115,21 @@ describe Braintree::Transaction do
|
|
115
115
|
end
|
116
116
|
|
117
117
|
describe "self.create" do
|
118
|
+
|
119
|
+
describe "card type indicators" do
|
120
|
+
it "sets the prepaid field if the card is prepaid" do
|
121
|
+
result = Braintree::Transaction.create(
|
122
|
+
:type => "sale",
|
123
|
+
:amount => 1_00,
|
124
|
+
:credit_card => {
|
125
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
126
|
+
:expiration_date => "05/2009"
|
127
|
+
}
|
128
|
+
)
|
129
|
+
result.transaction.credit_card_details.prepaid.should == Braintree::CreditCard::Prepaid::Yes
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
118
133
|
it "returns a successful result if successful" do
|
119
134
|
result = Braintree::Transaction.create(
|
120
135
|
:type => "sale",
|
@@ -461,7 +476,7 @@ describe Braintree::Transaction do
|
|
461
476
|
}
|
462
477
|
result = Braintree::Transaction.create(params[:transaction])
|
463
478
|
result.success?.should == false
|
464
|
-
result.errors.for(:transaction).on(:base).map{|error| error.code}.should include(Braintree::ErrorCodes::Transaction::
|
479
|
+
result.errors.for(:transaction).on(:base).map{|error| error.code}.should include(Braintree::ErrorCodes::Transaction::PaymentMethodConflictWithVenmoSDK)
|
465
480
|
result.errors.for(:transaction).on(:base).map{|error| error.code}.should include(Braintree::ErrorCodes::Transaction::PaymentMethodDoesNotBelongToCustomer)
|
466
481
|
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired
|
467
482
|
result.errors.for(:transaction).on(:customer_id)[0].code.should == Braintree::ErrorCodes::Transaction::CustomerIdIsInvalid
|
@@ -21,10 +21,19 @@ describe Braintree::Transaction::CreditCardDetails do
|
|
21
21
|
:expiration_year => "2012",
|
22
22
|
:last_4 => "6789",
|
23
23
|
:token => "token",
|
24
|
-
:customer_location => "US"
|
24
|
+
:customer_location => "US",
|
25
|
+
:healthcare => "No",
|
26
|
+
:prepaid => "Yes",
|
27
|
+
:durbin_regulated => "No",
|
28
|
+
:debit => "Yes",
|
29
|
+
:commercial => "Unknown",
|
30
|
+
:payroll => "Unknown",
|
31
|
+
:country_of_issuance => "Lilliput",
|
32
|
+
:issuing_bank => "Gulliver Bank"
|
25
33
|
)
|
26
|
-
details.inspect.should == %(#<token: "token", bin: "123456", last_4: "6789", card_type: "Visa", expiration_date: "05/2012", cardholder_name: "The Cardholder", customer_location: "US">)
|
34
|
+
details.inspect.should == %(#<token: "token", bin: "123456", last_4: "6789", card_type: "Visa", expiration_date: "05/2012", cardholder_name: "The Cardholder", customer_location: "US", prepaid: "Yes", healthcare: "No", durbin_regulated: "No", debit: "Yes", commercial: "Unknown", payroll: "Unknown", country_of_issuance: "Lilliput", issuing_bank: "Gulliver Bank">)
|
27
35
|
end
|
36
|
+
|
28
37
|
end
|
29
38
|
|
30
39
|
describe "masked_number" do
|
@@ -95,7 +95,15 @@ describe Braintree::Transaction do
|
|
95
95
|
:card_type => "Visa",
|
96
96
|
:expiration_month => "08",
|
97
97
|
:expiration_year => "2009",
|
98
|
-
:customer_location => "US"
|
98
|
+
:customer_location => "US",
|
99
|
+
:prepaid => "Yes",
|
100
|
+
:healthcare => "Yes",
|
101
|
+
:durbin_regulated => "Yes",
|
102
|
+
:debit => "Yes",
|
103
|
+
:commercial => "No",
|
104
|
+
:payroll => "Unknown",
|
105
|
+
:country_of_issuance => "Narnia",
|
106
|
+
:issuing_bank => "Mr Tumnus"
|
99
107
|
}
|
100
108
|
)
|
101
109
|
transaction.credit_card_details.token.should == "mzg2"
|
@@ -105,6 +113,13 @@ describe Braintree::Transaction do
|
|
105
113
|
transaction.credit_card_details.expiration_month.should == "08"
|
106
114
|
transaction.credit_card_details.expiration_year.should == "2009"
|
107
115
|
transaction.credit_card_details.customer_location.should == "US"
|
116
|
+
transaction.credit_card_details.prepaid.should == Braintree::CreditCard::Prepaid::Yes
|
117
|
+
transaction.credit_card_details.healthcare.should == Braintree::CreditCard::Healthcare::Yes
|
118
|
+
transaction.credit_card_details.durbin_regulated.should == Braintree::CreditCard::DurbinRegulated::Yes
|
119
|
+
transaction.credit_card_details.debit.should == Braintree::CreditCard::Debit::Yes
|
120
|
+
transaction.credit_card_details.commercial.should == Braintree::CreditCard::Commercial::No
|
121
|
+
transaction.credit_card_details.country_of_issuance.should == "Narnia"
|
122
|
+
transaction.credit_card_details.issuing_bank.should == "Mr Tumnus"
|
108
123
|
end
|
109
124
|
|
110
125
|
it "sets up history attributes in status_history" 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: 91
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
8
|
+
- 21
|
9
9
|
- 0
|
10
|
-
version: 2.
|
10
|
+
version: 2.21.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-12-05 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|