Permalink
Browse files

2.21.0

  • Loading branch information...
1 parent babca7d commit 7439e3bf82253dc4351408fa21fe348c82aca89f @braintreeps braintreeps committed Dec 5, 2012
View
@@ -1,5 +1,7 @@
+== 2.21.0
+* Add card type indicators to transactions and verifications
+
== 2.20.0
-* Add params for Venmo SDK
* Add additional card types for card type indicators
* Added ability to allow TR query parameters with no value (thanks @dmathieu!)
@@ -180,6 +180,7 @@ module Transaction
MerchantAccountNameIsInvalid = "91513" # Deprecated
OrderIdIsTooLong = "91501"
PaymentMethodConflict = "91515"
+ PaymentMethodConflictWithVenmoSDK = "91549"
PaymentMethodDoesNotBelongToCustomer = "91516"
PaymentMethodDoesNotBelongToSubscription = "91527"
PaymentMethodTokenCardTypeIsNotAccepted = "91517"
@@ -4,7 +4,8 @@ class CreditCardDetails # :nodoc:
include BaseModule
attr_reader :bin, :card_type, :cardholder_name, :customer_location, :expiration_month,
- :expiration_year, :last_4, :token
+ :expiration_year, :last_4, :token, :prepaid, :healthcare, :durbin_regulated, :debit,
+ :commercial, :payroll, :country_of_issuance, :issuing_bank
def initialize(attributes)
set_instance_variables_from_hash attributes unless attributes.nil?
@@ -15,7 +16,8 @@ def expiration_date
end
def inspect
- attr_order = [:token, :bin, :last_4, :card_type, :expiration_date, :cardholder_name, :customer_location]
+ attr_order = [:token, :bin, :last_4, :card_type, :expiration_date, :cardholder_name, :customer_location, :prepaid,
+ :healthcare, :durbin_regulated, :debit, :commercial, :payroll, :country_of_issuance, :issuing_bank]
formatted_attrs = attr_order.map do |attr|
"#{attr}: #{send(attr).inspect}"
end
View
@@ -26,11 +26,11 @@ def self.parse_query_string(qs)
end
def self.url_decode(text)
- CGI.unescape text.to_s
+ CGI.unescape text.to_s.to_str
end
def self.url_encode(text)
- CGI.escape text.to_s
+ CGI.escape text.to_s.to_str
end
def self.symbolize_keys(hash)
View
@@ -1,7 +1,7 @@
module Braintree
module Version
Major = 2
- Minor = 20
+ Minor = 21
Tiny = 0
String = "#{Major}.#{Minor}.#{Tiny}"
@@ -25,5 +25,31 @@
Braintree::CreditCardVerification.find("invalid-id")
end.to raise_error(Braintree::NotFoundError, 'verification with id "invalid-id" not found')
end
+
+ describe "card type indicators" do
+ it "returns prepaid on a prepaid card" do
+ cardholder_name = "Tom #{rand(1_000_000)} Smith"
+
+ result = Braintree::Customer.create(
+ :credit_card => {
+ :cardholder_name => cardholder_name,
+ :expiration_date => "05/2012",
+ :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
+ :cvv => '200',
+ :options => {
+ :verify_card => true
+ }
+ })
+
+ search_results = Braintree::CreditCardVerification.search do |search|
+ search.credit_card_cardholder_name.is cardholder_name
+ end
+
+ verification_id = search_results.first.id
+
+ found_verification = Braintree::CreditCardVerification.find(verification_id)
+ found_verification.credit_card[:prepaid].should == Braintree::CreditCard::Prepaid::Yes
+ end
+ end
end
end
@@ -115,6 +115,21 @@
end
describe "self.create" do
+
+ describe "card type indicators" do
+ it "sets the prepaid field if the card is prepaid" do
+ result = Braintree::Transaction.create(
+ :type => "sale",
+ :amount => 1_00,
+ :credit_card => {
+ :number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
+ :expiration_date => "05/2009"
+ }
+ )
+ result.transaction.credit_card_details.prepaid.should == Braintree::CreditCard::Prepaid::Yes
+ end
+ end
+
it "returns a successful result if successful" do
result = Braintree::Transaction.create(
:type => "sale",
@@ -461,7 +476,7 @@
}
result = Braintree::Transaction.create(params[:transaction])
result.success?.should == false
- result.errors.for(:transaction).on(:base).map{|error| error.code}.should include(Braintree::ErrorCodes::Transaction::PaymentMethodConflict)
+ result.errors.for(:transaction).on(:base).map{|error| error.code}.should include(Braintree::ErrorCodes::Transaction::PaymentMethodConflictWithVenmoSDK)
result.errors.for(:transaction).on(:base).map{|error| error.code}.should include(Braintree::ErrorCodes::Transaction::PaymentMethodDoesNotBelongToCustomer)
result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired
result.errors.for(:transaction).on(:customer_id)[0].code.should == Braintree::ErrorCodes::Transaction::CustomerIdIsInvalid
@@ -21,10 +21,19 @@
:expiration_year => "2012",
:last_4 => "6789",
:token => "token",
- :customer_location => "US"
+ :customer_location => "US",
+ :healthcare => "No",
+ :prepaid => "Yes",
+ :durbin_regulated => "No",
+ :debit => "Yes",
+ :commercial => "Unknown",
+ :payroll => "Unknown",
+ :country_of_issuance => "Lilliput",
+ :issuing_bank => "Gulliver Bank"
)
- details.inspect.should == %(#<token: "token", bin: "123456", last_4: "6789", card_type: "Visa", expiration_date: "05/2012", cardholder_name: "The Cardholder", customer_location: "US">)
+ 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">)
end
+
end
describe "masked_number" do
@@ -95,7 +95,15 @@
:card_type => "Visa",
:expiration_month => "08",
:expiration_year => "2009",
- :customer_location => "US"
+ :customer_location => "US",
+ :prepaid => "Yes",
+ :healthcare => "Yes",
+ :durbin_regulated => "Yes",
+ :debit => "Yes",
+ :commercial => "No",
+ :payroll => "Unknown",
+ :country_of_issuance => "Narnia",
+ :issuing_bank => "Mr Tumnus"
}
)
transaction.credit_card_details.token.should == "mzg2"
@@ -105,6 +113,13 @@
transaction.credit_card_details.expiration_month.should == "08"
transaction.credit_card_details.expiration_year.should == "2009"
transaction.credit_card_details.customer_location.should == "US"
+ transaction.credit_card_details.prepaid.should == Braintree::CreditCard::Prepaid::Yes
+ transaction.credit_card_details.healthcare.should == Braintree::CreditCard::Healthcare::Yes
+ transaction.credit_card_details.durbin_regulated.should == Braintree::CreditCard::DurbinRegulated::Yes
+ transaction.credit_card_details.debit.should == Braintree::CreditCard::Debit::Yes
+ transaction.credit_card_details.commercial.should == Braintree::CreditCard::Commercial::No
+ transaction.credit_card_details.country_of_issuance.should == "Narnia"
+ transaction.credit_card_details.issuing_bank.should == "Mr Tumnus"
end
it "sets up history attributes in status_history" do

0 comments on commit 7439e3b

Please sign in to comment.