braintree 2.13.4 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,8 +14,12 @@ module Braintree
14
14
  end
15
15
  end
16
16
 
17
- class EqualityNode < SearchNode # :nodoc:
18
- operators :is, :is_not
17
+ class IsNode < SearchNode # :nodoc:
18
+ operators :is
19
+ end
20
+
21
+ class EqualityNode < IsNode # :nodoc:
22
+ operators :is_not
19
23
  end
20
24
 
21
25
  class PartialMatchNode < EqualityNode # :nodoc:
@@ -93,6 +97,10 @@ module Braintree
93
97
  _create_field_accessors(fields, EqualityNode)
94
98
  end
95
99
 
100
+ def self.is_fields(*fields)
101
+ _create_field_accessors(fields, IsNode)
102
+ end
103
+
96
104
  def self.partial_match_fields(*fields)
97
105
  _create_field_accessors(fields, PartialMatchNode)
98
106
  end
@@ -76,15 +76,17 @@ module Braintree
76
76
 
77
77
  def self._signature(type) # :nodoc:
78
78
  billing_address_params = AddressGateway._shared_signature
79
+ options = [:make_default, :verification_merchant_account_id, :verify_card]
79
80
  signature = [
80
81
  :billing_address_id, :cardholder_name, :cvv, :expiration_date,
81
82
  :expiration_month, :expiration_year, :number, :token,
82
- {:options => [:make_default, :verification_merchant_account_id, :verify_card]},
83
+ {:options => options},
83
84
  {:billing_address => billing_address_params}
84
85
  ]
85
86
 
86
87
  case type
87
88
  when :create
89
+ options << :fail_on_duplicate_payment_method
88
90
  signature << :customer_id
89
91
  when :update
90
92
  billing_address_params << {:options => [:update_existing]}
@@ -21,6 +21,8 @@ module Braintree
21
21
  :website
22
22
  )
23
23
 
24
+ is_fields :payment_method_token_with_duplicates
25
+
24
26
  equality_fields :credit_card_expiration_date
25
27
 
26
28
  partial_match_fields :credit_card_number
@@ -36,6 +36,7 @@ module Braintree
36
36
  CustomerIdIsRequired = "91704"
37
37
  CvvIsInvalid = "81707"
38
38
  CvvIsRequired = "81706"
39
+ DuplicateCardExists = "81724"
39
40
  ExpirationDateConflict = "91708"
40
41
  ExpirationDateIsInvalid = "81710"
41
42
  ExpirationDateIsRequired = "81709"
@@ -174,7 +175,7 @@ module Braintree
174
175
  CustomerIdIsInvalid = "91510"
175
176
  HasAlreadyBeenRefunded = "91512"
176
177
  MerchantAccountIdIsInvalid = "91513"
177
- MerchantAccountIsSuspended = "91515"
178
+ MerchantAccountIsSuspended = "91514"
178
179
  MerchantAccountDoesNotSupportRefunds = "91547"
179
180
  MerchantAccountNameIsInvalid = "91513" # Deprecated
180
181
  OrderIdIsTooLong = "91501"
@@ -1,8 +1,8 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 2
4
- Minor = 13
5
- Tiny = 4
4
+ Minor = 14
5
+ Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
8
8
  end
@@ -1088,6 +1088,25 @@ describe Braintree::CreditCard do
1088
1088
  update_result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
1089
1089
  end
1090
1090
 
1091
+ it "fails on create if credit_card[options][fail_on_duplicate_payment_method]=true and there is a duplicated payment method" do
1092
+ customer = Braintree::Customer.create!
1093
+ Braintree::CreditCard.create(
1094
+ :customer_id => customer.id,
1095
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1096
+ :expiration_date => "05/2015"
1097
+ )
1098
+
1099
+ result = Braintree::CreditCard.create(
1100
+ :customer_id => customer.id,
1101
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1102
+ :expiration_date => "05/2015",
1103
+ :options => {:fail_on_duplicate_payment_method => true}
1104
+ )
1105
+
1106
+ result.success?.should == false
1107
+ result.errors.for(:credit_card).on(:number)[0].message.should == "Duplicate card exists in the vault."
1108
+ end
1109
+
1091
1110
  it "allows user to specify merchant account for verification" do
1092
1111
  customer = Braintree::Customer.create!
1093
1112
  credit_card = Braintree::CreditCard.create!(
@@ -89,6 +89,31 @@ describe Braintree::Transaction, "search" do
89
89
  collection.first.id.should == customer.id
90
90
  end
91
91
 
92
+ it "can find duplicate credit cards for a give payment method token " do
93
+ jim = Braintree::Customer.create(
94
+ :first_name => "Jim",
95
+ :credit_card => {
96
+ :number => Braintree::Test::CreditCardNumbers::Maestro,
97
+ :expiration_date => "05/2012"
98
+ }
99
+ ).customer
100
+
101
+ joe = Braintree::Customer.create(
102
+ :first_name => "Joe",
103
+ :credit_card => {
104
+ :number => Braintree::Test::CreditCardNumbers::Maestro,
105
+ :expiration_date => "05/2012"
106
+ }
107
+ ).customer
108
+
109
+ collection = Braintree::Customer.search do |search|
110
+ search.payment_method_token_with_duplicates.is jim.credit_cards.first.token
111
+ end
112
+
113
+ collection.should include(jim)
114
+ collection.should include(joe)
115
+ end
116
+
92
117
  it "can search by created_at" do
93
118
  company = "Company #{rand(1_000_000)}"
94
119
  customer = Braintree::Customer.create!(
@@ -127,6 +127,27 @@ describe Braintree::Customer do
127
127
  result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
128
128
  end
129
129
 
130
+ it "fails on create if credit_card[options][fail_on_duplicate_payment_method]=true and there is a duplicated payment method" do
131
+ customer = Braintree::Customer.create!
132
+ Braintree::CreditCard.create(
133
+ :customer_id => customer.id,
134
+ :number => Braintree::Test::CreditCardNumbers::Visa,
135
+ :expiration_date => "05/2015"
136
+ )
137
+
138
+ result = Braintree::Customer.create(
139
+ :first_name => "Mike",
140
+ :last_name => "Jones",
141
+ :credit_card => {
142
+ :number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::MasterCard,
143
+ :expiration_date => "05/2015",
144
+ :options => {:fail_on_duplicate_payment_method => true}
145
+ }
146
+ )
147
+ result.success?.should == false
148
+ result.errors.for(:customer).for(:credit_card).on(:number)[0].message.should == "Duplicate card exists in the vault."
149
+ end
150
+
130
151
  it "allows the user to specify the merchant account for verification" do
131
152
  result = Braintree::Customer.create(
132
153
  :first_name => "Mike",
@@ -20,7 +20,7 @@ describe Braintree::CreditCard do
20
20
  :expiration_year,
21
21
  :number,
22
22
  :token,
23
- {:options => [:make_default, :verification_merchant_account_id, :verify_card]},
23
+ {:options => [:make_default, :verification_merchant_account_id, :verify_card, :fail_on_duplicate_payment_method]},
24
24
  {:billing_address => [
25
25
  :company,
26
26
  :country_code_alpha2,
@@ -83,7 +83,7 @@ describe Braintree::Customer do
83
83
  :expiration_year,
84
84
  :number,
85
85
  :token,
86
- {:options => [:make_default, :verification_merchant_account_id, :verify_card]},
86
+ {:options => [:make_default, :verification_merchant_account_id, :verify_card, :fail_on_duplicate_payment_method]},
87
87
  {:billing_address => [
88
88
  :company,
89
89
  :country_code_alpha2,
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: 51
5
- prerelease:
4
+ hash: 55
5
+ prerelease: false
6
6
  segments:
7
7
  - 2
8
- - 13
9
- - 4
10
- version: 2.13.4
8
+ - 14
9
+ - 0
10
+ version: 2.14.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-02-07 00:00:00 -06:00
18
+ date: 2012-03-06 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  requirements: []
186
186
 
187
187
  rubyforge_project: braintree
188
- rubygems_version: 1.4.2
188
+ rubygems_version: 1.3.7
189
189
  signing_key:
190
190
  specification_version: 3
191
191
  summary: Braintree Gateway Ruby Client Library