Permalink
Browse files

2.14.0

  • Loading branch information...
braintreeps committed Mar 6, 2012
1 parent 146118d commit 42b0fcdea18ae1f012adadbc59593bb553583889
View
@@ -1,3 +1,8 @@
+== 2.14.0
+
+* Adds search for duplicate credit cards given a payment method token
+* Adds flag to fail saving credit card to vault if card is duplicate
+
== 2.13.4
* Allows both url encoded and decoded query string and hash
@@ -14,8 +14,12 @@ def initialize(name, parent)
end
end
- class EqualityNode < SearchNode # :nodoc:
- operators :is, :is_not
+ class IsNode < SearchNode # :nodoc:
+ operators :is
+ end
+
+ class EqualityNode < IsNode # :nodoc:
+ operators :is_not
end
class PartialMatchNode < EqualityNode # :nodoc:
@@ -93,6 +97,10 @@ def self.equality_fields(*fields)
_create_field_accessors(fields, EqualityNode)
end
+ def self.is_fields(*fields)
+ _create_field_accessors(fields, IsNode)
+ end
+
def self.partial_match_fields(*fields)
_create_field_accessors(fields, PartialMatchNode)
end
@@ -76,15 +76,17 @@ def self._update_signature # :nodoc:
def self._signature(type) # :nodoc:
billing_address_params = AddressGateway._shared_signature
+ options = [:make_default, :verification_merchant_account_id, :verify_card]
signature = [
:billing_address_id, :cardholder_name, :cvv, :expiration_date,
:expiration_month, :expiration_year, :number, :token,
- {:options => [:make_default, :verification_merchant_account_id, :verify_card]},
+ {:options => options},
{:billing_address => billing_address_params}
]
case type
when :create
+ options << :fail_on_duplicate_payment_method
signature << :customer_id
when :update
billing_address_params << {:options => [:update_existing]}
@@ -21,6 +21,8 @@ class CustomerSearch < AdvancedSearch # :nodoc:
:website
)
+ is_fields :payment_method_token_with_duplicates
+
equality_fields :credit_card_expiration_date
partial_match_fields :credit_card_number
@@ -36,6 +36,7 @@ module CreditCard
CustomerIdIsRequired = "91704"
CvvIsInvalid = "81707"
CvvIsRequired = "81706"
+ DuplicateCardExists = "81724"
ExpirationDateConflict = "91708"
ExpirationDateIsInvalid = "81710"
ExpirationDateIsRequired = "81709"
@@ -174,7 +175,7 @@ module Transaction
CustomerIdIsInvalid = "91510"
HasAlreadyBeenRefunded = "91512"
MerchantAccountIdIsInvalid = "91513"
- MerchantAccountIsSuspended = "91515"
+ MerchantAccountIsSuspended = "91514"
MerchantAccountDoesNotSupportRefunds = "91547"
MerchantAccountNameIsInvalid = "91513" # Deprecated
OrderIdIsTooLong = "91501"
View
@@ -1,8 +1,8 @@
module Braintree
module Version
Major = 2
- Minor = 13
- Tiny = 4
+ Minor = 14
+ Tiny = 0
String = "#{Major}.#{Minor}.#{Tiny}"
end
@@ -1088,6 +1088,25 @@
update_result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
end
+ it "fails on create if credit_card[options][fail_on_duplicate_payment_method]=true and there is a duplicated payment method" do
+ customer = Braintree::Customer.create!
+ Braintree::CreditCard.create(
+ :customer_id => customer.id,
+ :number => Braintree::Test::CreditCardNumbers::Visa,
+ :expiration_date => "05/2015"
+ )
+
+ result = Braintree::CreditCard.create(
+ :customer_id => customer.id,
+ :number => Braintree::Test::CreditCardNumbers::Visa,
+ :expiration_date => "05/2015",
+ :options => {:fail_on_duplicate_payment_method => true}
+ )
+
+ result.success?.should == false
+ result.errors.for(:credit_card).on(:number)[0].message.should == "Duplicate card exists in the vault."
+ end
+
it "allows user to specify merchant account for verification" do
customer = Braintree::Customer.create!
credit_card = Braintree::CreditCard.create!(
@@ -89,6 +89,31 @@
collection.first.id.should == customer.id
end
+ it "can find duplicate credit cards for a give payment method token " do
+ jim = Braintree::Customer.create(
+ :first_name => "Jim",
+ :credit_card => {
+ :number => Braintree::Test::CreditCardNumbers::Maestro,
+ :expiration_date => "05/2012"
+ }
+ ).customer
+
+ joe = Braintree::Customer.create(
+ :first_name => "Joe",
+ :credit_card => {
+ :number => Braintree::Test::CreditCardNumbers::Maestro,
+ :expiration_date => "05/2012"
+ }
+ ).customer
+
+ collection = Braintree::Customer.search do |search|
+ search.payment_method_token_with_duplicates.is jim.credit_cards.first.token
+ end
+
+ collection.should include(jim)
+ collection.should include(joe)
+ end
+
it "can search by created_at" do
company = "Company #{rand(1_000_000)}"
customer = Braintree::Customer.create!(
@@ -127,6 +127,27 @@
result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
end
+ it "fails on create if credit_card[options][fail_on_duplicate_payment_method]=true and there is a duplicated payment method" do
+ customer = Braintree::Customer.create!
+ Braintree::CreditCard.create(
+ :customer_id => customer.id,
+ :number => Braintree::Test::CreditCardNumbers::Visa,
+ :expiration_date => "05/2015"
+ )
+
+ result = Braintree::Customer.create(
+ :first_name => "Mike",
+ :last_name => "Jones",
+ :credit_card => {
+ :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::MasterCard,
+ :expiration_date => "05/2015",
+ :options => {:fail_on_duplicate_payment_method => true}
+ }
+ )
+ result.success?.should == false
+ result.errors.for(:customer).for(:credit_card).on(:number)[0].message.should == "Duplicate card exists in the vault."
+ end
+
it "allows the user to specify the merchant account for verification" do
result = Braintree::Customer.create(
:first_name => "Mike",
@@ -20,7 +20,7 @@
:expiration_year,
:number,
:token,
- {:options => [:make_default, :verification_merchant_account_id, :verify_card]},
+ {:options => [:make_default, :verification_merchant_account_id, :verify_card, :fail_on_duplicate_payment_method]},
{:billing_address => [
:company,
:country_code_alpha2,
@@ -83,7 +83,7 @@
:expiration_year,
:number,
:token,
- {:options => [:make_default, :verification_merchant_account_id, :verify_card]},
+ {:options => [:make_default, :verification_merchant_account_id, :verify_card, :fail_on_duplicate_payment_method]},
{:billing_address => [
:company,
:country_code_alpha2,

0 comments on commit 42b0fcd

Please sign in to comment.