braintree 3.1.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/braintree.gemspec +3 -3
- data/lib/braintree.rb +8 -1
- data/lib/braintree/account_updater_daily_report.rb +1 -1
- data/lib/braintree/address.rb +2 -1
- data/lib/braintree/apple_pay.rb +1 -1
- data/lib/braintree/apple_pay_card.rb +1 -1
- data/lib/braintree/apple_pay_options.rb +1 -1
- data/lib/braintree/authorization_adjustment.rb +1 -1
- data/lib/braintree/client_token.rb +1 -1
- data/lib/braintree/configuration.rb +11 -11
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
- data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
- data/lib/braintree/credit_card.rb +2 -2
- data/lib/braintree/credit_card_gateway.rb +14 -4
- data/lib/braintree/credit_card_verification.rb +5 -5
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +6 -4
- data/lib/braintree/customer_gateway.rb +2 -0
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/disbursement.rb +1 -1
- data/lib/braintree/dispute.rb +15 -1
- data/lib/braintree/dispute/paypal_message.rb +15 -0
- data/lib/braintree/dispute_gateway.rb +2 -2
- data/lib/braintree/dispute_search.rb +3 -2
- data/lib/braintree/document_upload.rb +1 -1
- data/lib/braintree/error_codes.rb +12 -4
- data/lib/braintree/google_pay_card.rb +1 -1
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +7 -7
- data/lib/braintree/http.rb +3 -3
- data/lib/braintree/local_payment_completed.rb +1 -1
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +1 -1
- data/lib/braintree/merchant_account.rb +1 -1
- data/lib/braintree/merchant_account_gateway.rb +1 -1
- data/lib/braintree/merchant_gateway.rb +1 -1
- data/lib/braintree/modification.rb +1 -1
- data/lib/braintree/oauth_credentials.rb +1 -1
- data/lib/braintree/oauth_gateway.rb +5 -5
- data/lib/braintree/payment_instrument_type.rb +10 -10
- data/lib/braintree/payment_method_gateway.rb +11 -8
- data/lib/braintree/payment_method_nonce.rb +1 -1
- data/lib/braintree/payment_method_nonce_details.rb +37 -0
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/processor_response_types.rb +3 -3
- data/lib/braintree/resource_collection.rb +8 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data.rb +3 -1
- data/lib/braintree/samsung_pay_card.rb +1 -1
- data/lib/braintree/settlement_batch_summary.rb +2 -2
- data/lib/braintree/subscription.rb +6 -6
- data/lib/braintree/test/credit_card.rb +1 -0
- data/lib/braintree/three_d_secure_info.rb +22 -12
- data/lib/braintree/transaction.rb +40 -24
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction_gateway.rb +27 -6
- data/lib/braintree/transaction_line_item.rb +1 -1
- data/lib/braintree/transaction_search.rb +3 -1
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +3 -3
- data/lib/braintree/us_bank_account_verification.rb +1 -1
- data/lib/braintree/us_bank_account_verification_gateway.rb +1 -1
- data/lib/braintree/util.rb +4 -4
- data/lib/braintree/venmo_account.rb +1 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +2 -2
- data/lib/braintree/webhook_notification.rb +30 -20
- data/lib/braintree/webhook_notification_gateway.rb +5 -5
- data/lib/braintree/webhook_testing_gateway.rb +30 -0
- data/lib/braintree/xml/generator.rb +5 -4
- data/lib/braintree/xml/libxml.rb +0 -1
- data/lib/braintree/xml/parser.rb +22 -12
- data/lib/braintree/xml/rexml.rb +70 -0
- data/spec/integration/braintree/add_on_spec.rb +1 -1
- data/spec/integration/braintree/address_spec.rb +28 -24
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +3 -3
- data/spec/integration/braintree/braintree_gateway_spec.rb +2 -1
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -14
- data/spec/integration/braintree/client_api/spec_helper.rb +5 -5
- data/spec/integration/braintree/credit_card_spec.rb +213 -122
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
- data/spec/integration/braintree/customer_search_spec.rb +8 -8
- data/spec/integration/braintree/customer_spec.rb +433 -149
- data/spec/integration/braintree/dispute_search_spec.rb +28 -3
- data/spec/integration/braintree/dispute_spec.rb +6 -6
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- data/spec/integration/braintree/http_spec.rb +2 -2
- data/spec/integration/braintree/merchant_account_spec.rb +25 -26
- data/spec/integration/braintree/merchant_spec.rb +14 -14
- data/spec/integration/braintree/oauth_spec.rb +11 -11
- data/spec/integration/braintree/payment_method_nonce_spec.rb +26 -35
- data/spec/integration/braintree/payment_method_spec.rb +430 -149
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +17 -13
- data/spec/integration/braintree/paypal_account_spec.rb +28 -28
- data/spec/integration/braintree/samsung_pay_card_spec.rb +9 -9
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
- data/spec/integration/braintree/subscription_spec.rb +133 -133
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +10 -10
- data/spec/integration/braintree/transaction_search_spec.rb +93 -67
- data/spec/integration/braintree/transaction_spec.rb +752 -383
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -26
- data/spec/integration/braintree/us_bank_account_spec.rb +6 -6
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +8 -8
- data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
- data/spec/integration/spec_helper.rb +9 -3
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +6 -3
- data/spec/unit/braintree/address_spec.rb +1 -1
- data/spec/unit/braintree/apple_pay_card_spec.rb +1 -1
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +42 -42
- data/spec/unit/braintree/credit_card_spec.rb +13 -13
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +8 -4
- data/spec/unit/braintree/customer_spec.rb +21 -10
- data/spec/unit/braintree/disbursement_spec.rb +7 -7
- data/spec/unit/braintree/dispute_search_spec.rb +1 -0
- data/spec/unit/braintree/dispute_spec.rb +34 -9
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- data/spec/unit/braintree/http_spec.rb +5 -5
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +43 -0
- data/spec/unit/braintree/payment_method_spec.rb +1 -1
- data/spec/unit/braintree/paypal_account_spec.rb +2 -2
- data/spec/unit/braintree/resource_collection_spec.rb +30 -1
- data/spec/unit/braintree/risk_data_spec.rb +9 -5
- data/spec/unit/braintree/subscription_search_spec.rb +1 -1
- data/spec/unit/braintree/successful_result_spec.rb +1 -1
- data/spec/unit/braintree/three_d_secure_info_spec.rb +32 -14
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +3 -3
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +25 -17
- data/spec/unit/braintree/util_spec.rb +18 -18
- data/spec/unit/braintree/validation_error_collection_spec.rb +36 -36
- data/spec/unit/braintree/webhook_notification_spec.rb +88 -56
- data/spec/unit/braintree/xml/rexml_spec.rb +51 -0
- data/spec/unit/braintree/xml_spec.rb +31 -31
- metadata +18 -8
- data/lib/braintree/settlement_batch.rb +0 -0
@@ -108,7 +108,7 @@ describe Braintree::CreditCardVerification, "search" do
|
|
108
108
|
search.id.is verification.id
|
109
109
|
search.created_at.between(
|
110
110
|
created_at - 60,
|
111
|
-
created_at + 60
|
111
|
+
created_at + 60,
|
112
112
|
)
|
113
113
|
end
|
114
114
|
|
@@ -135,7 +135,7 @@ describe Braintree::CreditCardVerification, "search" do
|
|
135
135
|
search.id.is verification.id
|
136
136
|
search.created_at.between(
|
137
137
|
created_at - 300,
|
138
|
-
created_at - 100
|
138
|
+
created_at - 100,
|
139
139
|
)
|
140
140
|
end
|
141
141
|
|
@@ -242,7 +242,7 @@ describe Braintree::CreditCardVerification, "search" do
|
|
242
242
|
:cardholder_name => cardholder_name,
|
243
243
|
:expiration_date => "05/2012",
|
244
244
|
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Prepaid,
|
245
|
-
:cvv =>
|
245
|
+
:cvv => "200",
|
246
246
|
:options => {
|
247
247
|
:verify_card => true
|
248
248
|
}
|
@@ -36,7 +36,7 @@ describe Braintree::Transaction, "search" do
|
|
36
36
|
:postal_code => "60622",
|
37
37
|
:country_name => "United States of America"
|
38
38
|
}
|
39
|
-
}
|
39
|
+
},
|
40
40
|
)
|
41
41
|
|
42
42
|
customer = Braintree::Customer.find(customer.id)
|
@@ -96,7 +96,7 @@ describe Braintree::Transaction, "search" do
|
|
96
96
|
:credit_card => {
|
97
97
|
:number => Braintree::Test::CreditCardNumbers::Maestro,
|
98
98
|
:expiration_date => "05/2012"
|
99
|
-
}
|
99
|
+
},
|
100
100
|
).customer
|
101
101
|
|
102
102
|
joe = Braintree::Customer.create(
|
@@ -104,7 +104,7 @@ describe Braintree::Transaction, "search" do
|
|
104
104
|
:credit_card => {
|
105
105
|
:number => Braintree::Test::CreditCardNumbers::Maestro,
|
106
106
|
:expiration_date => "05/2012"
|
107
|
-
}
|
107
|
+
},
|
108
108
|
).customer
|
109
109
|
|
110
110
|
collection = Braintree::Customer.search do |search|
|
@@ -118,7 +118,7 @@ describe Braintree::Transaction, "search" do
|
|
118
118
|
it "can search by created_at" do
|
119
119
|
company = "Company #{rand(1_000_000)}"
|
120
120
|
customer = Braintree::Customer.create!(
|
121
|
-
:company => company
|
121
|
+
:company => company,
|
122
122
|
)
|
123
123
|
|
124
124
|
created_at = customer.created_at
|
@@ -128,7 +128,7 @@ describe Braintree::Transaction, "search" do
|
|
128
128
|
search.company.is company
|
129
129
|
search.created_at.between(
|
130
130
|
created_at - 60,
|
131
|
-
created_at + 60
|
131
|
+
created_at + 60,
|
132
132
|
)
|
133
133
|
end
|
134
134
|
|
@@ -155,7 +155,7 @@ describe Braintree::Transaction, "search" do
|
|
155
155
|
search.company.is customer.company
|
156
156
|
search.created_at.between(
|
157
157
|
created_at - 300,
|
158
|
-
created_at - 100
|
158
|
+
created_at - 100,
|
159
159
|
)
|
160
160
|
end
|
161
161
|
|
@@ -175,13 +175,13 @@ describe Braintree::Transaction, "search" do
|
|
175
175
|
paypal_token = rand(36**3).to_s(36)
|
176
176
|
nonce = nonce_for_paypal_account(
|
177
177
|
:consent_code => "PAYPAL_CONSENT_CODE",
|
178
|
-
:token => paypal_token
|
178
|
+
:token => paypal_token,
|
179
179
|
)
|
180
180
|
|
181
181
|
customer_id = "UNIQUE_CUSTOMER_ID_" + rand(36**3).to_s(36)
|
182
182
|
customer = Braintree::Customer.create!(
|
183
183
|
:payment_method_nonce => nonce,
|
184
|
-
:id => customer_id
|
184
|
+
:id => customer_id,
|
185
185
|
)
|
186
186
|
|
187
187
|
collection = Braintree::Customer.search do |search|
|
@@ -8,7 +8,7 @@ describe Braintree::Customer do
|
|
8
8
|
customers = Braintree::Customer.all
|
9
9
|
customers.maximum_size.should > 100
|
10
10
|
|
11
|
-
customer_ids = customers.map {|c| c.id }.uniq.compact
|
11
|
+
customer_ids = customers.map { |c| c.id }.uniq.compact
|
12
12
|
customer_ids.size.should == customers.maximum_size
|
13
13
|
end
|
14
14
|
end
|
@@ -17,7 +17,7 @@ describe Braintree::Customer do
|
|
17
17
|
it "deletes the customer with the given id" do
|
18
18
|
create_result = Braintree::Customer.create(
|
19
19
|
:first_name => "Joe",
|
20
|
-
:last_name => "Cool"
|
20
|
+
:last_name => "Cool",
|
21
21
|
)
|
22
22
|
create_result.success?.should == true
|
23
23
|
customer = create_result.customer
|
@@ -39,7 +39,8 @@ describe Braintree::Customer do
|
|
39
39
|
:email => "bill@microsoft.com",
|
40
40
|
:phone => "312.555.1234",
|
41
41
|
:fax => "614.555.5678",
|
42
|
-
:website => "www.microsoft.com"
|
42
|
+
:website => "www.microsoft.com",
|
43
|
+
:tax_identifiers => [{:country_code => "US", :identifier => "987654321"}],
|
43
44
|
)
|
44
45
|
result.success?.should == true
|
45
46
|
result.customer.id.should =~ /^\d{6,}$/
|
@@ -58,7 +59,7 @@ describe Braintree::Customer do
|
|
58
59
|
oauth_gateway = Braintree::Gateway.new(
|
59
60
|
:client_id => "client_id$#{Braintree::Configuration.environment}$integration_client_id",
|
60
61
|
:client_secret => "client_secret$#{Braintree::Configuration.environment}$integration_client_secret",
|
61
|
-
:logger => Logger.new("/dev/null")
|
62
|
+
:logger => Logger.new("/dev/null"),
|
62
63
|
)
|
63
64
|
access_token = Braintree::OAuthTestHelper.create_token(oauth_gateway, {
|
64
65
|
:merchant_public_id => "integration_merchant_id",
|
@@ -67,7 +68,7 @@ describe Braintree::Customer do
|
|
67
68
|
|
68
69
|
gateway = Braintree::Gateway.new(
|
69
70
|
:access_token => access_token,
|
70
|
-
:logger => Logger.new("/dev/null")
|
71
|
+
:logger => Logger.new("/dev/null"),
|
71
72
|
)
|
72
73
|
|
73
74
|
result = gateway.customer.create(
|
@@ -77,7 +78,7 @@ describe Braintree::Customer do
|
|
77
78
|
:email => "joe@example.com",
|
78
79
|
:phone => "312.555.1234",
|
79
80
|
:fax => "614.555.5678",
|
80
|
-
:website => "www.example.com"
|
81
|
+
:website => "www.example.com",
|
81
82
|
)
|
82
83
|
result.success?.should == true
|
83
84
|
result.customer.id.should =~ /^\d{6,}$/
|
@@ -92,7 +93,7 @@ describe Braintree::Customer do
|
|
92
93
|
:expiration_date => "05/2010",
|
93
94
|
:cvv => "100",
|
94
95
|
:device_data => "device_data",
|
95
|
-
}
|
96
|
+
},
|
96
97
|
)
|
97
98
|
|
98
99
|
result.should be_success
|
@@ -108,7 +109,58 @@ describe Braintree::Customer do
|
|
108
109
|
:risk_data => {
|
109
110
|
:customer_browser => "IE5",
|
110
111
|
:customer_ip => "192.168.0.1"
|
111
|
-
}
|
112
|
+
},
|
113
|
+
)
|
114
|
+
|
115
|
+
result.should be_success
|
116
|
+
end
|
117
|
+
|
118
|
+
it "includes risk data when skip_advanced_fraud_checking is false" do
|
119
|
+
with_fraud_protection_enterprise_merchant do
|
120
|
+
result = Braintree::Customer.create(
|
121
|
+
:credit_card => {
|
122
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
123
|
+
:expiration_date => "05/2010",
|
124
|
+
:cvv => "100",
|
125
|
+
:options => {
|
126
|
+
:skip_advanced_fraud_checking => false,
|
127
|
+
:verify_card => true,
|
128
|
+
},
|
129
|
+
},
|
130
|
+
)
|
131
|
+
|
132
|
+
expect(result).to be_success
|
133
|
+
verification = result.customer.credit_cards.first.verification
|
134
|
+
expect(verification.risk_data).not_to be_nil
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
it "does not include risk data when skip_advanced_fraud_checking is true" do
|
139
|
+
with_fraud_protection_enterprise_merchant do
|
140
|
+
result = Braintree::Customer.create(
|
141
|
+
:credit_card => {
|
142
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
143
|
+
:expiration_date => "05/2010",
|
144
|
+
:cvv => "100",
|
145
|
+
:options => {
|
146
|
+
:skip_advanced_fraud_checking => true,
|
147
|
+
:verify_card => true,
|
148
|
+
},
|
149
|
+
},
|
150
|
+
)
|
151
|
+
|
152
|
+
expect(result).to be_success
|
153
|
+
verification = result.customer.credit_cards.first.verification
|
154
|
+
expect(verification.risk_data).to be_nil
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
it "supports creation with tax_identifiers" do
|
159
|
+
result = Braintree::Customer.create(
|
160
|
+
:tax_identifiers => [
|
161
|
+
{:country_code => "US", :identifier => "987654321"},
|
162
|
+
{:country_code => "CL", :identifier => "123456789"}
|
163
|
+
],
|
112
164
|
)
|
113
165
|
|
114
166
|
result.should be_success
|
@@ -134,21 +186,21 @@ describe Braintree::Customer do
|
|
134
186
|
found_customer.last_name.should == last_name
|
135
187
|
else
|
136
188
|
result.customer.first_name.should == "José"
|
137
|
-
result.customer.first_name.bytes.map {|b| b.to_s(8)}.should == ["112", "157", "163", "303", "251"]
|
189
|
+
result.customer.first_name.bytes.map { |b| b.to_s(8) }.should == ["112", "157", "163", "303", "251"]
|
138
190
|
result.customer.last_name.should == "Muñoz"
|
139
|
-
result.customer.last_name.bytes.map {|b| b.to_s(8)}.should == ["115", "165", "303", "261", "157", "172"]
|
191
|
+
result.customer.last_name.bytes.map { |b| b.to_s(8) }.should == ["115", "165", "303", "261", "157", "172"]
|
140
192
|
|
141
193
|
found_customer = Braintree::Customer.find(result.customer.id)
|
142
194
|
found_customer.first_name.should == "José"
|
143
|
-
found_customer.first_name.bytes.map {|b| b.to_s(8)}.should == ["112", "157", "163", "303", "251"]
|
195
|
+
found_customer.first_name.bytes.map { |b| b.to_s(8) }.should == ["112", "157", "163", "303", "251"]
|
144
196
|
found_customer.last_name.should == "Muñoz"
|
145
|
-
found_customer.last_name.bytes.map {|b| b.to_s(8)}.should == ["115", "165", "303", "261", "157", "172"]
|
197
|
+
found_customer.last_name.bytes.map { |b| b.to_s(8) }.should == ["115", "165", "303", "261", "157", "172"]
|
146
198
|
end
|
147
199
|
end
|
148
200
|
|
149
201
|
it "returns an error response if invalid" do
|
150
202
|
result = Braintree::Customer.create(
|
151
|
-
:email => "@invalid.com"
|
203
|
+
:email => "@invalid.com",
|
152
204
|
)
|
153
205
|
result.success?.should == false
|
154
206
|
result.errors.for(:customer).on(:email)[0].message.should == "Email is an invalid format."
|
@@ -162,7 +214,7 @@ describe Braintree::Customer do
|
|
162
214
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
163
215
|
:expiration_date => "05/2010",
|
164
216
|
:cvv => "100"
|
165
|
-
}
|
217
|
+
},
|
166
218
|
)
|
167
219
|
|
168
220
|
result.success?.should == true
|
@@ -182,7 +234,7 @@ describe Braintree::Customer do
|
|
182
234
|
:email => "other@example.com",
|
183
235
|
:billing_agreement_id => "B-123456",
|
184
236
|
:options => {:make_default => true}
|
185
|
-
}
|
237
|
+
},
|
186
238
|
)
|
187
239
|
|
188
240
|
result.success?.should == true
|
@@ -200,7 +252,7 @@ describe Braintree::Customer do
|
|
200
252
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::MasterCard,
|
201
253
|
:expiration_date => "05/2010",
|
202
254
|
:options => {:verify_card => true}
|
203
|
-
}
|
255
|
+
},
|
204
256
|
)
|
205
257
|
result.success?.should == false
|
206
258
|
result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
@@ -214,7 +266,7 @@ describe Braintree::Customer do
|
|
214
266
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
215
267
|
:expiration_date => "05/2019",
|
216
268
|
:options => {:verify_card => true, :verification_amount => "2.00"}
|
217
|
-
}
|
269
|
+
},
|
218
270
|
)
|
219
271
|
result.success?.should == true
|
220
272
|
end
|
@@ -224,7 +276,7 @@ describe Braintree::Customer do
|
|
224
276
|
Braintree::CreditCard.create(
|
225
277
|
:customer_id => customer.id,
|
226
278
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
227
|
-
:expiration_date => "05/2015"
|
279
|
+
:expiration_date => "05/2015",
|
228
280
|
)
|
229
281
|
|
230
282
|
result = Braintree::Customer.create(
|
@@ -234,7 +286,7 @@ describe Braintree::Customer do
|
|
234
286
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
235
287
|
:expiration_date => "05/2015",
|
236
288
|
:options => {:fail_on_duplicate_payment_method => true}
|
237
|
-
}
|
289
|
+
},
|
238
290
|
)
|
239
291
|
result.success?.should == false
|
240
292
|
result.errors.for(:customer).for(:credit_card).on(:number)[0].message.should == "Duplicate card exists in the vault."
|
@@ -251,12 +303,98 @@ describe Braintree::Customer do
|
|
251
303
|
:verify_card => true,
|
252
304
|
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
|
253
305
|
}
|
254
|
-
}
|
306
|
+
},
|
255
307
|
)
|
256
308
|
result.success?.should == false
|
257
309
|
result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
258
310
|
end
|
259
311
|
|
312
|
+
it "can create a customer and a payment method at the same time after validating verification_currency_iso_code" do
|
313
|
+
result = Braintree::Customer.create(
|
314
|
+
:first_name => "Mike",
|
315
|
+
:last_name => "Jones",
|
316
|
+
:credit_card => {
|
317
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
318
|
+
:expiration_date => "05/2010",
|
319
|
+
:cvv => "100",
|
320
|
+
:options => {
|
321
|
+
:verify_card => true,
|
322
|
+
:verification_currency_iso_code => "USD"
|
323
|
+
}
|
324
|
+
},
|
325
|
+
)
|
326
|
+
|
327
|
+
result.success?.should == true
|
328
|
+
result.customer.first_name.should == "Mike"
|
329
|
+
result.customer.last_name.should == "Jones"
|
330
|
+
result.customer.credit_cards[0].bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
|
331
|
+
result.customer.credit_cards[0].last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
|
332
|
+
result.customer.credit_cards[0].expiration_date.should == "05/2010"
|
333
|
+
result.customer.credit_cards[0].unique_number_identifier.should =~ /\A\w{32}\z/
|
334
|
+
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
335
|
+
end
|
336
|
+
|
337
|
+
it "errors when verification_currency_iso_code is not supported by merchant account" do
|
338
|
+
result = Braintree::Customer.create(
|
339
|
+
:first_name => "Mike",
|
340
|
+
:last_name => "Jones",
|
341
|
+
:credit_card => {
|
342
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
343
|
+
:expiration_date => "05/2010",
|
344
|
+
:cvv => "100",
|
345
|
+
:options => {
|
346
|
+
:verify_card => true,
|
347
|
+
:verification_currency_iso_code => "GBP"
|
348
|
+
}
|
349
|
+
},
|
350
|
+
)
|
351
|
+
expect(result).to_not be_success
|
352
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
353
|
+
end
|
354
|
+
|
355
|
+
it "validates verification_currency_iso_code of the given verification_merchant_account_id and creates customer" do
|
356
|
+
result = Braintree::Customer.create(
|
357
|
+
:first_name => "Mike",
|
358
|
+
:last_name => "Jones",
|
359
|
+
:credit_card => {
|
360
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
361
|
+
:expiration_date => "05/2010",
|
362
|
+
:options => {
|
363
|
+
:verify_card => true,
|
364
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
365
|
+
:verification_currency_iso_code => "USD"
|
366
|
+
}
|
367
|
+
},
|
368
|
+
)
|
369
|
+
result.success?.should == true
|
370
|
+
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
371
|
+
result.customer.first_name.should == "Mike"
|
372
|
+
result.customer.last_name.should == "Jones"
|
373
|
+
result.customer.credit_cards[0].bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
|
374
|
+
result.customer.credit_cards[0].last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
|
375
|
+
result.customer.credit_cards[0].expiration_date.should == "05/2010"
|
376
|
+
result.customer.credit_cards[0].unique_number_identifier.should =~ /\A\w{32}\z/
|
377
|
+
end
|
378
|
+
|
379
|
+
it "validates verification_currency_iso_code of the given verification_merchant_account_id and returns error" do
|
380
|
+
result = Braintree::Customer.create(
|
381
|
+
:first_name => "Mike",
|
382
|
+
:last_name => "Jones",
|
383
|
+
:credit_card => {
|
384
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
385
|
+
:expiration_date => "05/2010",
|
386
|
+
:options => {
|
387
|
+
:verify_card => true,
|
388
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
389
|
+
:verification_currency_iso_code => "GBP"
|
390
|
+
}
|
391
|
+
},
|
392
|
+
)
|
393
|
+
expect(result).to_not be_success
|
394
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
395
|
+
end
|
396
|
+
|
397
|
+
|
260
398
|
it "can create a customer, payment method, and billing address at the same time" do
|
261
399
|
result = Braintree::Customer.create(
|
262
400
|
:first_name => "Mike",
|
@@ -272,7 +410,7 @@ describe Braintree::Customer do
|
|
272
410
|
:postal_code => "60622",
|
273
411
|
:country_name => "United States of America"
|
274
412
|
}
|
275
|
-
}
|
413
|
+
},
|
276
414
|
)
|
277
415
|
result.success?.should == true
|
278
416
|
result.customer.first_name.should == "Mike"
|
@@ -303,7 +441,7 @@ describe Braintree::Customer do
|
|
303
441
|
:country_code_alpha3 => "COM",
|
304
442
|
:country_code_numeric => "174"
|
305
443
|
}
|
306
|
-
}
|
444
|
+
},
|
307
445
|
)
|
308
446
|
result.success?.should == true
|
309
447
|
result.customer.addresses[0].country_name.should == "Comoros"
|
@@ -318,7 +456,7 @@ describe Braintree::Customer do
|
|
318
456
|
:last_name => "Gates",
|
319
457
|
:custom_fields => {
|
320
458
|
:store_me => "custom value"
|
321
|
-
}
|
459
|
+
},
|
322
460
|
)
|
323
461
|
result.success?.should == true
|
324
462
|
result.customer.custom_fields[:store_me].should == "custom value"
|
@@ -328,7 +466,7 @@ describe Braintree::Customer do
|
|
328
466
|
result = Braintree::Customer.create(
|
329
467
|
:first_name => "Bill",
|
330
468
|
:last_name => "Gates",
|
331
|
-
:custom_fields => {
|
469
|
+
:custom_fields => {:store_me => ""},
|
332
470
|
)
|
333
471
|
result.success?.should == true
|
334
472
|
result.customer.custom_fields.should == {}
|
@@ -342,7 +480,7 @@ describe Braintree::Customer do
|
|
342
480
|
:billing_address => {
|
343
481
|
:country_name => "invalid"
|
344
482
|
}
|
345
|
-
}
|
483
|
+
},
|
346
484
|
)
|
347
485
|
result.success?.should == false
|
348
486
|
result.errors.for(:customer).on(:email)[0].message.should == "Email is an invalid format."
|
@@ -362,10 +500,10 @@ describe Braintree::Customer do
|
|
362
500
|
:country_code_alpha2 => "US",
|
363
501
|
:country_code_alpha3 => "COM",
|
364
502
|
}
|
365
|
-
}
|
503
|
+
},
|
366
504
|
)
|
367
505
|
result.success?.should == false
|
368
|
-
result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:base).map {|e| e.code}.should include(Braintree::ErrorCodes::Address::InconsistentCountry)
|
506
|
+
result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:base).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::InconsistentCountry)
|
369
507
|
end
|
370
508
|
|
371
509
|
it "returns an error if country code alpha2 is invalid" do
|
@@ -378,10 +516,10 @@ describe Braintree::Customer do
|
|
378
516
|
:billing_address => {
|
379
517
|
:country_code_alpha2 => "zz",
|
380
518
|
}
|
381
|
-
}
|
519
|
+
},
|
382
520
|
)
|
383
521
|
result.success?.should == false
|
384
|
-
result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_alpha2).map {|e| e.code}.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha2IsNotAccepted)
|
522
|
+
result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_alpha2).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha2IsNotAccepted)
|
385
523
|
end
|
386
524
|
|
387
525
|
it "returns an error if country code alpha3 is invalid" do
|
@@ -394,10 +532,10 @@ describe Braintree::Customer do
|
|
394
532
|
:billing_address => {
|
395
533
|
:country_code_alpha3 => "zzz",
|
396
534
|
}
|
397
|
-
}
|
535
|
+
},
|
398
536
|
)
|
399
537
|
result.success?.should == false
|
400
|
-
result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_alpha3).map {|e| e.code}.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha3IsNotAccepted)
|
538
|
+
result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_alpha3).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::CountryCodeAlpha3IsNotAccepted)
|
401
539
|
end
|
402
540
|
|
403
541
|
it "returns an error if country code numeric is invalid" do
|
@@ -410,10 +548,10 @@ describe Braintree::Customer do
|
|
410
548
|
:billing_address => {
|
411
549
|
:country_code_numeric => "zzz",
|
412
550
|
}
|
413
|
-
}
|
551
|
+
},
|
414
552
|
)
|
415
553
|
result.success?.should == false
|
416
|
-
result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_numeric).map {|e| e.code}.should include(Braintree::ErrorCodes::Address::CountryCodeNumericIsNotAccepted)
|
554
|
+
result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_numeric).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::CountryCodeNumericIsNotAccepted)
|
417
555
|
end
|
418
556
|
|
419
557
|
it "returns errors if custom_fields are not registered" do
|
@@ -422,7 +560,7 @@ describe Braintree::Customer do
|
|
422
560
|
:last_name => "Kennedy",
|
423
561
|
:custom_fields => {
|
424
562
|
:spouse_name => "Jacqueline"
|
425
|
-
}
|
563
|
+
},
|
426
564
|
)
|
427
565
|
result.success?.should == false
|
428
566
|
result.errors.for(:customer).on(:custom_fields)[0].message.should == "Custom field is invalid: spouse_name."
|
@@ -435,7 +573,7 @@ describe Braintree::Customer do
|
|
435
573
|
:last_name => "Hamlin",
|
436
574
|
:credit_card => {
|
437
575
|
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode
|
438
|
-
}
|
576
|
+
},
|
439
577
|
)
|
440
578
|
result.success?.should == true
|
441
579
|
result.customer.credit_cards.first.bin.should == "400934"
|
@@ -452,7 +590,7 @@ describe Braintree::Customer do
|
|
452
590
|
:options => {
|
453
591
|
:venmo_sdk_session => Braintree::Test::VenmoSDK::Session
|
454
592
|
}
|
455
|
-
}
|
593
|
+
},
|
456
594
|
)
|
457
595
|
result.success?.should == true
|
458
596
|
result.customer.credit_cards.first.venmo_sdk?.should == false
|
@@ -467,13 +605,13 @@ describe Braintree::Customer do
|
|
467
605
|
:expiration_month => "11",
|
468
606
|
:expiration_year => "2099",
|
469
607
|
},
|
470
|
-
:share => true
|
608
|
+
:share => true,
|
471
609
|
)
|
472
610
|
|
473
611
|
result = Braintree::Customer.create(
|
474
612
|
:credit_card => {
|
475
613
|
:payment_method_nonce => nonce
|
476
|
-
}
|
614
|
+
},
|
477
615
|
)
|
478
616
|
|
479
617
|
result.success?.should == true
|
@@ -503,7 +641,7 @@ describe Braintree::Customer do
|
|
503
641
|
:number => Braintree::Test::CreditCardNumbers::Hiper,
|
504
642
|
:expiration_month => "11",
|
505
643
|
:expiration_year => "2099",
|
506
|
-
}
|
644
|
+
},
|
507
645
|
)
|
508
646
|
result = Braintree::Customer.create(
|
509
647
|
:payment_method_nonce => nonce,
|
@@ -513,7 +651,7 @@ describe Braintree::Customer do
|
|
513
651
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
514
652
|
:verification_account_type => "debit",
|
515
653
|
}
|
516
|
-
}
|
654
|
+
},
|
517
655
|
)
|
518
656
|
|
519
657
|
expect(result).to be_success
|
@@ -525,7 +663,7 @@ describe Braintree::Customer do
|
|
525
663
|
:number => Braintree::Test::CreditCardNumbers::Hiper,
|
526
664
|
:expiration_month => "11",
|
527
665
|
:expiration_year => "2099",
|
528
|
-
}
|
666
|
+
},
|
529
667
|
)
|
530
668
|
result = Braintree::Customer.create(
|
531
669
|
:payment_method_nonce => nonce,
|
@@ -535,7 +673,7 @@ describe Braintree::Customer do
|
|
535
673
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
536
674
|
:verification_account_type => "credit",
|
537
675
|
}
|
538
|
-
}
|
676
|
+
},
|
539
677
|
)
|
540
678
|
|
541
679
|
expect(result).to be_success
|
@@ -547,7 +685,7 @@ describe Braintree::Customer do
|
|
547
685
|
:number => Braintree::Test::CreditCardNumbers::Hiper,
|
548
686
|
:expiration_month => "11",
|
549
687
|
:expiration_year => "2099",
|
550
|
-
}
|
688
|
+
},
|
551
689
|
)
|
552
690
|
result = Braintree::Customer.create(
|
553
691
|
:payment_method_nonce => nonce,
|
@@ -557,7 +695,7 @@ describe Braintree::Customer do
|
|
557
695
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
558
696
|
:verification_account_type => "ach",
|
559
697
|
}
|
560
|
-
}
|
698
|
+
},
|
561
699
|
)
|
562
700
|
|
563
701
|
expect(result).to_not be_success
|
@@ -570,7 +708,7 @@ describe Braintree::Customer do
|
|
570
708
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
571
709
|
:expiration_month => "11",
|
572
710
|
:expiration_year => "2099",
|
573
|
-
}
|
711
|
+
},
|
574
712
|
)
|
575
713
|
result = Braintree::Customer.create(
|
576
714
|
:payment_method_nonce => nonce,
|
@@ -579,7 +717,7 @@ describe Braintree::Customer do
|
|
579
717
|
:verify_card => true,
|
580
718
|
:verification_account_type => "credit",
|
581
719
|
}
|
582
|
-
}
|
720
|
+
},
|
583
721
|
)
|
584
722
|
|
585
723
|
expect(result).to_not be_success
|
@@ -592,7 +730,7 @@ describe Braintree::Customer do
|
|
592
730
|
it "returns the customer if successful" do
|
593
731
|
customer = Braintree::Customer.create!(
|
594
732
|
:first_name => "Jim",
|
595
|
-
:last_name => "Smith"
|
733
|
+
:last_name => "Smith",
|
596
734
|
)
|
597
735
|
customer.id.should =~ /\d+/
|
598
736
|
customer.first_name.should == "Jim"
|
@@ -617,7 +755,7 @@ describe Braintree::Customer do
|
|
617
755
|
:credit_card => {
|
618
756
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
619
757
|
:expiration_date => "05/2010"
|
620
|
-
}
|
758
|
+
},
|
621
759
|
)
|
622
760
|
result = Braintree::Customer.credit(customer.id, :amount => "100.00")
|
623
761
|
result.success?.should == true
|
@@ -637,7 +775,7 @@ describe Braintree::Customer do
|
|
637
775
|
:credit_card => {
|
638
776
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
639
777
|
:expiration_date => "05/2010"
|
640
|
-
}
|
778
|
+
},
|
641
779
|
)
|
642
780
|
transaction = Braintree::Customer.credit!(customer.id, :amount => "100.00")
|
643
781
|
transaction.amount.should == BigDecimal("100.00")
|
@@ -656,7 +794,7 @@ describe Braintree::Customer do
|
|
656
794
|
:credit_card => {
|
657
795
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
658
796
|
:expiration_date => "05/2010"
|
659
|
-
}
|
797
|
+
},
|
660
798
|
)
|
661
799
|
result = Braintree::Customer.sale(customer.id, :amount => "100.00")
|
662
800
|
result.success?.should == true
|
@@ -676,7 +814,7 @@ describe Braintree::Customer do
|
|
676
814
|
:credit_card => {
|
677
815
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
678
816
|
:expiration_date => "05/2010"
|
679
|
-
}
|
817
|
+
},
|
680
818
|
)
|
681
819
|
transaction = Braintree::Customer.sale!(customer.id, :amount => "100.00")
|
682
820
|
transaction.amount.should == BigDecimal("100.00")
|
@@ -695,7 +833,7 @@ describe Braintree::Customer do
|
|
695
833
|
:credit_card => {
|
696
834
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
697
835
|
:expiration_date => "05/2010"
|
698
|
-
}
|
836
|
+
},
|
699
837
|
)
|
700
838
|
transaction = Braintree::Customer.sale!(customer.id, :amount => "100.00")
|
701
839
|
collection = Braintree::Customer.transactions(customer.id)
|
@@ -709,10 +847,10 @@ describe Braintree::Customer do
|
|
709
847
|
:credit_card => {
|
710
848
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
711
849
|
:expiration_date => "05/2010"
|
712
|
-
}
|
850
|
+
},
|
713
851
|
)
|
714
852
|
result = customer.credit(
|
715
|
-
:amount => "100.00"
|
853
|
+
:amount => "100.00",
|
716
854
|
)
|
717
855
|
result.success?.should == true
|
718
856
|
result.transaction.amount.should == BigDecimal("100.00")
|
@@ -731,7 +869,7 @@ describe Braintree::Customer do
|
|
731
869
|
:credit_card => {
|
732
870
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
733
871
|
:expiration_date => "05/2010"
|
734
|
-
}
|
872
|
+
},
|
735
873
|
)
|
736
874
|
transaction = customer.credit!(:amount => "100.00")
|
737
875
|
transaction.amount.should == BigDecimal("100.00")
|
@@ -748,7 +886,7 @@ describe Braintree::Customer do
|
|
748
886
|
it "deletes the customer" do
|
749
887
|
result = Braintree::Customer.create(
|
750
888
|
:first_name => "Joe",
|
751
|
-
:last_name => "Cool"
|
889
|
+
:last_name => "Cool",
|
752
890
|
)
|
753
891
|
result.success?.should == true
|
754
892
|
|
@@ -765,7 +903,7 @@ describe Braintree::Customer do
|
|
765
903
|
it "finds the customer with the given id" do
|
766
904
|
result = Braintree::Customer.create(
|
767
905
|
:first_name => "Joe",
|
768
|
-
:last_name => "Cool"
|
906
|
+
:last_name => "Cool",
|
769
907
|
)
|
770
908
|
result.success?.should == true
|
771
909
|
|
@@ -781,13 +919,13 @@ describe Braintree::Customer do
|
|
781
919
|
credit_card = Braintree::CreditCard.create(
|
782
920
|
:customer_id => customer.id,
|
783
921
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
784
|
-
:expiration_date => "05/2012"
|
922
|
+
:expiration_date => "05/2012",
|
785
923
|
).credit_card
|
786
924
|
|
787
925
|
subscription = Braintree::Subscription.create(
|
788
926
|
:payment_method_token => credit_card.token,
|
789
927
|
:plan_id => "integration_trialless_plan",
|
790
|
-
:price => "1.00"
|
928
|
+
:price => "1.00",
|
791
929
|
).subscription
|
792
930
|
|
793
931
|
found_customer = Braintree::Customer.find(customer.id)
|
@@ -802,7 +940,7 @@ describe Braintree::Customer do
|
|
802
940
|
customer = Braintree::Customer.create(
|
803
941
|
:custom_fields => {
|
804
942
|
:store_me => "custom value"
|
805
|
-
}
|
943
|
+
},
|
806
944
|
).customer
|
807
945
|
credit_card = Braintree::CreditCard.create(
|
808
946
|
:customer_id => customer.id,
|
@@ -814,13 +952,13 @@ describe Braintree::Customer do
|
|
814
952
|
:region => "Illinois",
|
815
953
|
:postal_code => "60622",
|
816
954
|
:country_name => "United States of America"
|
817
|
-
}
|
955
|
+
},
|
818
956
|
).credit_card
|
819
957
|
|
820
958
|
subscription = Braintree::Subscription.create(
|
821
959
|
:payment_method_token => credit_card.token,
|
822
960
|
:plan_id => "integration_trialless_plan",
|
823
|
-
:price => "1.00"
|
961
|
+
:price => "1.00",
|
824
962
|
).subscription
|
825
963
|
|
826
964
|
found_customer = Braintree::Customer.find(customer.id, {
|
@@ -836,7 +974,7 @@ describe Braintree::Customer do
|
|
836
974
|
customer = Braintree::Customer.create(
|
837
975
|
:custom_fields => {
|
838
976
|
:store_me => "custom value"
|
839
|
-
}
|
977
|
+
},
|
840
978
|
).customer
|
841
979
|
credit_card = Braintree::CreditCard.create(
|
842
980
|
:customer_id => customer.id,
|
@@ -848,13 +986,13 @@ describe Braintree::Customer do
|
|
848
986
|
:region => "Illinois",
|
849
987
|
:postal_code => "60622",
|
850
988
|
:country_name => "United States of America"
|
851
|
-
}
|
989
|
+
},
|
852
990
|
).credit_card
|
853
991
|
|
854
992
|
subscription = Braintree::Subscription.create(
|
855
993
|
:payment_method_token => credit_card.token,
|
856
994
|
:plan_id => "integration_trialless_plan",
|
857
|
-
:price => "1.00"
|
995
|
+
:price => "1.00",
|
858
996
|
).subscription
|
859
997
|
|
860
998
|
found_customer = Braintree::Customer.find(customer.id, {
|
@@ -872,7 +1010,7 @@ describe Braintree::Customer do
|
|
872
1010
|
|
873
1011
|
it "returns associated ApplePayCards" do
|
874
1012
|
result = Braintree::Customer.create(
|
875
|
-
:payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx
|
1013
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx,
|
876
1014
|
)
|
877
1015
|
result.success?.should == true
|
878
1016
|
|
@@ -887,7 +1025,7 @@ describe Braintree::Customer do
|
|
887
1025
|
|
888
1026
|
it "returns associated google pay proxy cards" do
|
889
1027
|
result = Braintree::Customer.create(
|
890
|
-
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover
|
1028
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
891
1029
|
)
|
892
1030
|
result.success?.should == true
|
893
1031
|
|
@@ -903,7 +1041,7 @@ describe Braintree::Customer do
|
|
903
1041
|
|
904
1042
|
it "returns associated google pay network tokens" do
|
905
1043
|
result = Braintree::Customer.create(
|
906
|
-
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard
|
1044
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
|
907
1045
|
)
|
908
1046
|
result.success?.should == true
|
909
1047
|
|
@@ -919,7 +1057,7 @@ describe Braintree::Customer do
|
|
919
1057
|
|
920
1058
|
it "returns associated venmo accounts" do
|
921
1059
|
result = Braintree::Customer.create(
|
922
|
-
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount
|
1060
|
+
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
|
923
1061
|
)
|
924
1062
|
result.success?.should == true
|
925
1063
|
|
@@ -939,7 +1077,7 @@ describe Braintree::Customer do
|
|
939
1077
|
:options => {
|
940
1078
|
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
|
941
1079
|
}
|
942
|
-
}
|
1080
|
+
},
|
943
1081
|
)
|
944
1082
|
result.should be_success
|
945
1083
|
|
@@ -985,7 +1123,7 @@ describe Braintree::Customer do
|
|
985
1123
|
it "updates the credit card with three_d_secure pass thru params" do
|
986
1124
|
customer = Braintree::Customer.create!(
|
987
1125
|
:first_name => "Joe",
|
988
|
-
:last_name => "Cool"
|
1126
|
+
:last_name => "Cool",
|
989
1127
|
)
|
990
1128
|
result = Braintree::Customer.update(
|
991
1129
|
customer.id,
|
@@ -998,17 +1136,17 @@ describe Braintree::Customer do
|
|
998
1136
|
:number => 4111111111111111,
|
999
1137
|
:expiration_date => "05/2060",
|
1000
1138
|
:three_d_secure_pass_thru => {
|
1001
|
-
:eci_flag =>
|
1002
|
-
:cavv =>
|
1003
|
-
:xid =>
|
1004
|
-
:three_d_secure_version =>
|
1005
|
-
:authentication_response =>
|
1006
|
-
:directory_response =>
|
1007
|
-
:cavv_algorithm =>
|
1008
|
-
:ds_transaction_id =>
|
1139
|
+
:eci_flag => "02",
|
1140
|
+
:cavv => "some_cavv",
|
1141
|
+
:xid => "some_xid",
|
1142
|
+
:three_d_secure_version => "1.0.2",
|
1143
|
+
:authentication_response => "Y",
|
1144
|
+
:directory_response => "Y",
|
1145
|
+
:cavv_algorithm => "2",
|
1146
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
1009
1147
|
},
|
1010
1148
|
:options => {:verify_card => true},
|
1011
|
-
}
|
1149
|
+
},
|
1012
1150
|
)
|
1013
1151
|
result.success?.should == true
|
1014
1152
|
result.customer.id.should == customer.id
|
@@ -1020,7 +1158,7 @@ describe Braintree::Customer do
|
|
1020
1158
|
it "validates the presence of three_d_secure_version while passing three_d_secure_pass_thru in update" do
|
1021
1159
|
customer = Braintree::Customer.create!(
|
1022
1160
|
:first_name => "Joe",
|
1023
|
-
:last_name => "Cool"
|
1161
|
+
:last_name => "Cool",
|
1024
1162
|
)
|
1025
1163
|
result = Braintree::Customer.update(
|
1026
1164
|
customer.id,
|
@@ -1033,16 +1171,16 @@ describe Braintree::Customer do
|
|
1033
1171
|
:number => 4111111111111111,
|
1034
1172
|
:expiration_date => "05/2060",
|
1035
1173
|
:three_d_secure_pass_thru => {
|
1036
|
-
:eci_flag =>
|
1037
|
-
:cavv =>
|
1038
|
-
:xid =>
|
1039
|
-
:authentication_response =>
|
1040
|
-
:directory_response =>
|
1041
|
-
:cavv_algorithm =>
|
1042
|
-
:ds_transaction_id =>
|
1174
|
+
:eci_flag => "02",
|
1175
|
+
:cavv => "some_cavv",
|
1176
|
+
:xid => "some_xid",
|
1177
|
+
:authentication_response => "Y",
|
1178
|
+
:directory_response => "Y",
|
1179
|
+
:cavv_algorithm => "2",
|
1180
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
1043
1181
|
},
|
1044
1182
|
options: {:verify_card => true}
|
1045
|
-
}
|
1183
|
+
},
|
1046
1184
|
)
|
1047
1185
|
expect(result).to_not be_success
|
1048
1186
|
error = result.errors.for(:verification).first
|
@@ -1053,7 +1191,7 @@ describe Braintree::Customer do
|
|
1053
1191
|
it "updates the customer with the given id if successful" do
|
1054
1192
|
customer = Braintree::Customer.create!(
|
1055
1193
|
:first_name => "Joe",
|
1056
|
-
:last_name => "Cool"
|
1194
|
+
:last_name => "Cool",
|
1057
1195
|
)
|
1058
1196
|
result = Braintree::Customer.update(
|
1059
1197
|
customer.id,
|
@@ -1061,7 +1199,7 @@ describe Braintree::Customer do
|
|
1061
1199
|
:last_name => "Super Cool",
|
1062
1200
|
:custom_fields => {
|
1063
1201
|
:store_me => "a value"
|
1064
|
-
}
|
1202
|
+
},
|
1065
1203
|
)
|
1066
1204
|
result.success?.should == true
|
1067
1205
|
result.customer.id.should == customer.id
|
@@ -1075,7 +1213,7 @@ describe Braintree::Customer do
|
|
1075
1213
|
:credit_card => {
|
1076
1214
|
:number => 4111111111111111,
|
1077
1215
|
:expiration_date => "05/2010",
|
1078
|
-
}
|
1216
|
+
},
|
1079
1217
|
)
|
1080
1218
|
result = Braintree::Customer.update(
|
1081
1219
|
customer.id,
|
@@ -1085,7 +1223,7 @@ describe Braintree::Customer do
|
|
1085
1223
|
:options=> {
|
1086
1224
|
:fail_on_duplicate_payment_method => true
|
1087
1225
|
}
|
1088
|
-
}
|
1226
|
+
},
|
1089
1227
|
)
|
1090
1228
|
result.success?.should == false
|
1091
1229
|
result.errors.for(:customer).for(:credit_card).on(:number)[0].message.should == "Duplicate card exists in the vault."
|
@@ -1094,7 +1232,7 @@ describe Braintree::Customer do
|
|
1094
1232
|
it "updates the default payment method" do
|
1095
1233
|
customer = Braintree::Customer.create!(
|
1096
1234
|
:first_name => "Joe",
|
1097
|
-
:last_name => "Brown"
|
1235
|
+
:last_name => "Brown",
|
1098
1236
|
)
|
1099
1237
|
|
1100
1238
|
token1 = random_payment_method_token
|
@@ -1102,7 +1240,7 @@ describe Braintree::Customer do
|
|
1102
1240
|
payment_method1 = Braintree::PaymentMethod.create(
|
1103
1241
|
:customer_id => customer.id,
|
1104
1242
|
:payment_method_nonce => Braintree::Test::Nonce::TransactableVisa,
|
1105
|
-
:token => token1
|
1243
|
+
:token => token1,
|
1106
1244
|
)
|
1107
1245
|
|
1108
1246
|
payment_method1 = Braintree::PaymentMethod.find(token1)
|
@@ -1113,11 +1251,11 @@ describe Braintree::Customer do
|
|
1113
1251
|
payment_method2 = Braintree::PaymentMethod.create(
|
1114
1252
|
:customer_id => customer.id,
|
1115
1253
|
:payment_method_nonce => Braintree::Test::Nonce::TransactableMasterCard,
|
1116
|
-
:token => token2
|
1254
|
+
:token => token2,
|
1117
1255
|
)
|
1118
1256
|
|
1119
1257
|
Braintree::Customer.update(customer.id,
|
1120
|
-
:default_payment_method_token => token2
|
1258
|
+
:default_payment_method_token => token2,
|
1121
1259
|
)
|
1122
1260
|
|
1123
1261
|
payment_method2 = Braintree::PaymentMethod.find(token2)
|
@@ -1127,7 +1265,7 @@ describe Braintree::Customer do
|
|
1127
1265
|
it "updates the default payment method in the options" do
|
1128
1266
|
customer = Braintree::Customer.create!(
|
1129
1267
|
:first_name => "Joe",
|
1130
|
-
:last_name => "Brown"
|
1268
|
+
:last_name => "Brown",
|
1131
1269
|
)
|
1132
1270
|
|
1133
1271
|
token1 = random_payment_method_token
|
@@ -1135,7 +1273,7 @@ describe Braintree::Customer do
|
|
1135
1273
|
payment_method1 = Braintree::PaymentMethod.create(
|
1136
1274
|
:customer_id => customer.id,
|
1137
1275
|
:payment_method_nonce => Braintree::Test::Nonce::TransactableVisa,
|
1138
|
-
:token => token1
|
1276
|
+
:token => token1,
|
1139
1277
|
)
|
1140
1278
|
|
1141
1279
|
payment_method1 = Braintree::PaymentMethod.find(token1)
|
@@ -1146,7 +1284,7 @@ describe Braintree::Customer do
|
|
1146
1284
|
payment_method2 = Braintree::PaymentMethod.create(
|
1147
1285
|
:customer_id => customer.id,
|
1148
1286
|
:payment_method_nonce => Braintree::Test::Nonce::TransactableMasterCard,
|
1149
|
-
:token => token2
|
1287
|
+
:token => token2,
|
1150
1288
|
)
|
1151
1289
|
|
1152
1290
|
Braintree::Customer.update(customer.id,
|
@@ -1155,7 +1293,7 @@ describe Braintree::Customer do
|
|
1155
1293
|
:update_existing_token => token2,
|
1156
1294
|
:make_default => true
|
1157
1295
|
}
|
1158
|
-
}
|
1296
|
+
},
|
1159
1297
|
)
|
1160
1298
|
|
1161
1299
|
payment_method2 = Braintree::PaymentMethod.find(token2)
|
@@ -1165,7 +1303,7 @@ describe Braintree::Customer do
|
|
1165
1303
|
it "can use any country code" do
|
1166
1304
|
customer = Braintree::Customer.create!(
|
1167
1305
|
:first_name => "Alex",
|
1168
|
-
:last_name => "Matterson"
|
1306
|
+
:last_name => "Matterson",
|
1169
1307
|
)
|
1170
1308
|
result = Braintree::Customer.update(
|
1171
1309
|
customer.id,
|
@@ -1180,7 +1318,7 @@ describe Braintree::Customer do
|
|
1180
1318
|
:country_code_alpha3 => "FJI",
|
1181
1319
|
:country_code_numeric => "242"
|
1182
1320
|
}
|
1183
|
-
}
|
1321
|
+
},
|
1184
1322
|
)
|
1185
1323
|
result.success?.should == true
|
1186
1324
|
result.customer.addresses[0].country_name.should == "Fiji"
|
@@ -1199,7 +1337,7 @@ describe Braintree::Customer do
|
|
1199
1337
|
:first_name => "Joe",
|
1200
1338
|
:postal_code => "60622"
|
1201
1339
|
}
|
1202
|
-
}
|
1340
|
+
},
|
1203
1341
|
)
|
1204
1342
|
|
1205
1343
|
result = Braintree::Customer.update(
|
@@ -1207,13 +1345,13 @@ describe Braintree::Customer do
|
|
1207
1345
|
:first_name => "New Joe",
|
1208
1346
|
:credit_card => {
|
1209
1347
|
:cardholder_name => "New Joe Cardholder",
|
1210
|
-
:options => {
|
1348
|
+
:options => {:update_existing_token => customer.credit_cards.first.token},
|
1211
1349
|
:billing_address => {
|
1212
1350
|
:last_name => "Cool",
|
1213
1351
|
:postal_code => "60666",
|
1214
|
-
:options => {
|
1352
|
+
:options => {:update_existing => true}
|
1215
1353
|
}
|
1216
|
-
}
|
1354
|
+
},
|
1217
1355
|
)
|
1218
1356
|
result.success?.should == true
|
1219
1357
|
result.customer.id.should == customer.id
|
@@ -1231,7 +1369,7 @@ describe Braintree::Customer do
|
|
1231
1369
|
|
1232
1370
|
it "can update the customer and verify_card with a specific verification_amount" do
|
1233
1371
|
customer = Braintree::Customer.create!(
|
1234
|
-
:first_name => "Joe"
|
1372
|
+
:first_name => "Joe",
|
1235
1373
|
)
|
1236
1374
|
|
1237
1375
|
result = Braintree::Customer.update(
|
@@ -1241,8 +1379,73 @@ describe Braintree::Customer do
|
|
1241
1379
|
:cardholder_name => "New Joe Cardholder",
|
1242
1380
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1243
1381
|
:expiration_date => "12/2009",
|
1244
|
-
:options => {
|
1245
|
-
}
|
1382
|
+
:options => {:verify_card => true, :verification_amount => "2.00"}
|
1383
|
+
},
|
1384
|
+
)
|
1385
|
+
result.success?.should == true
|
1386
|
+
end
|
1387
|
+
|
1388
|
+
it "includes risk data when skip_advanced_fraud_checking is false" do
|
1389
|
+
with_fraud_protection_enterprise_merchant do
|
1390
|
+
customer = Braintree::Customer.create!(
|
1391
|
+
:first_name => "Joe",
|
1392
|
+
)
|
1393
|
+
|
1394
|
+
updated_result = Braintree::Customer.update(
|
1395
|
+
customer.id,
|
1396
|
+
:credit_card => {
|
1397
|
+
:cardholder_name => "New Joe Cardholder",
|
1398
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1399
|
+
:expiration_date => "12/2009",
|
1400
|
+
:options => {
|
1401
|
+
:skip_advanced_fraud_checking => false,
|
1402
|
+
:verify_card => true,
|
1403
|
+
},
|
1404
|
+
},
|
1405
|
+
)
|
1406
|
+
|
1407
|
+
expect(updated_result).to be_success
|
1408
|
+
verification = updated_result.customer.credit_cards.first.verification
|
1409
|
+
expect(verification.risk_data).not_to be_nil
|
1410
|
+
end
|
1411
|
+
end
|
1412
|
+
|
1413
|
+
it "does not include risk data when skip_advanced_fraud_checking is true" do
|
1414
|
+
with_fraud_protection_enterprise_merchant do
|
1415
|
+
customer = Braintree::Customer.create!(
|
1416
|
+
:first_name => "Joe",
|
1417
|
+
)
|
1418
|
+
|
1419
|
+
updated_result = Braintree::Customer.update(
|
1420
|
+
customer.id,
|
1421
|
+
:credit_card => {
|
1422
|
+
:cardholder_name => "New Joe Cardholder",
|
1423
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1424
|
+
:expiration_date => "12/2009",
|
1425
|
+
:options => {
|
1426
|
+
:skip_advanced_fraud_checking => true,
|
1427
|
+
:verify_card => true,
|
1428
|
+
},
|
1429
|
+
},
|
1430
|
+
)
|
1431
|
+
|
1432
|
+
expect(updated_result).to be_success
|
1433
|
+
verification = updated_result.customer.credit_cards.first.verification
|
1434
|
+
expect(verification.risk_data).to be_nil
|
1435
|
+
end
|
1436
|
+
end
|
1437
|
+
|
1438
|
+
it "can update a tax_identifier" do
|
1439
|
+
customer = Braintree::Customer.create!(
|
1440
|
+
:tax_identifiers => [
|
1441
|
+
{:country_code => "US", :identifier => "987654321"},
|
1442
|
+
{:country_code => "CL", :identifier => "123456789"}
|
1443
|
+
],
|
1444
|
+
)
|
1445
|
+
|
1446
|
+
result = Braintree::Customer.update(
|
1447
|
+
customer.id,
|
1448
|
+
:tax_identifiers => [{:country_code => "US", :identifier => "567891234"}],
|
1246
1449
|
)
|
1247
1450
|
result.success?.should == true
|
1248
1451
|
end
|
@@ -1252,17 +1455,17 @@ describe Braintree::Customer do
|
|
1252
1455
|
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
1253
1456
|
:credit_card => {
|
1254
1457
|
:three_d_secure_pass_thru => {
|
1255
|
-
:eci_flag =>
|
1256
|
-
:cavv =>
|
1257
|
-
:xid =>
|
1258
|
-
:three_d_secure_version =>
|
1259
|
-
:authentication_response =>
|
1260
|
-
:directory_response =>
|
1261
|
-
:cavv_algorithm =>
|
1262
|
-
:ds_transaction_id =>
|
1458
|
+
:eci_flag => "02",
|
1459
|
+
:cavv => "some_cavv",
|
1460
|
+
:xid => "some_xid",
|
1461
|
+
:three_d_secure_version => "xx",
|
1462
|
+
:authentication_response => "Y",
|
1463
|
+
:directory_response => "Y",
|
1464
|
+
:cavv_algorithm => "2",
|
1465
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
1263
1466
|
},
|
1264
1467
|
:options => {:verify_card => true}
|
1265
|
-
}
|
1468
|
+
},
|
1266
1469
|
)
|
1267
1470
|
|
1268
1471
|
expect(result).not_to be_success
|
@@ -1276,17 +1479,17 @@ describe Braintree::Customer do
|
|
1276
1479
|
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
1277
1480
|
:credit_card => {
|
1278
1481
|
:three_d_secure_pass_thru => {
|
1279
|
-
:eci_flag =>
|
1280
|
-
:cavv =>
|
1281
|
-
:xid =>
|
1282
|
-
:three_d_secure_version =>
|
1283
|
-
:authentication_response =>
|
1284
|
-
:directory_response =>
|
1285
|
-
:cavv_algorithm =>
|
1286
|
-
:ds_transaction_id =>
|
1482
|
+
:eci_flag => "02",
|
1483
|
+
:cavv => "some_cavv",
|
1484
|
+
:xid => "some_xid",
|
1485
|
+
:three_d_secure_version => "2.2.1",
|
1486
|
+
:authentication_response => "Y",
|
1487
|
+
:directory_response => "Y",
|
1488
|
+
:cavv_algorithm => "2",
|
1489
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
1287
1490
|
},
|
1288
1491
|
:options => {:verify_card => true}
|
1289
|
-
}
|
1492
|
+
},
|
1290
1493
|
)
|
1291
1494
|
|
1292
1495
|
expect(result).to be_success
|
@@ -1297,7 +1500,7 @@ describe Braintree::Customer do
|
|
1297
1500
|
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
1298
1501
|
:credit_card => {
|
1299
1502
|
:options => {:verify_card => true}
|
1300
|
-
}
|
1503
|
+
},
|
1301
1504
|
)
|
1302
1505
|
result.success?.should == true
|
1303
1506
|
|
@@ -1319,7 +1522,7 @@ describe Braintree::Customer do
|
|
1319
1522
|
address = Braintree::Address.create!(
|
1320
1523
|
:customer_id => customer.id,
|
1321
1524
|
:first_name => "John",
|
1322
|
-
:last_name => "Doe"
|
1525
|
+
:last_name => "Doe",
|
1323
1526
|
)
|
1324
1527
|
|
1325
1528
|
customer = Braintree::Customer.update(
|
@@ -1328,7 +1531,7 @@ describe Braintree::Customer do
|
|
1328
1531
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1329
1532
|
:expiration_date => "12/2009",
|
1330
1533
|
:billing_address_id => address.id
|
1331
|
-
}
|
1534
|
+
},
|
1332
1535
|
).customer
|
1333
1536
|
|
1334
1537
|
billing_address = customer.credit_cards.first.billing_address
|
@@ -1341,12 +1544,93 @@ describe Braintree::Customer do
|
|
1341
1544
|
customer = Braintree::Customer.create!(:email => "valid@email.com")
|
1342
1545
|
result = Braintree::Customer.update(
|
1343
1546
|
customer.id,
|
1344
|
-
:email => "@invalid.com"
|
1547
|
+
:email => "@invalid.com",
|
1345
1548
|
)
|
1346
1549
|
result.success?.should == false
|
1347
1550
|
result.errors.for(:customer).on(:email)[0].message.should == "Email is an invalid format."
|
1348
1551
|
end
|
1349
1552
|
|
1553
|
+
context "verification_currency_iso_code" do
|
1554
|
+
it "can update the customer after validating verification_currency_iso_code" do
|
1555
|
+
customer = Braintree::Customer.create!(
|
1556
|
+
:first_name => "Joe",
|
1557
|
+
)
|
1558
|
+
|
1559
|
+
result = Braintree::Customer.update(
|
1560
|
+
customer.id,
|
1561
|
+
:first_name => "New Joe",
|
1562
|
+
:credit_card => {
|
1563
|
+
:cardholder_name => "New Joe Cardholder",
|
1564
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1565
|
+
:expiration_date => "12/2009",
|
1566
|
+
:options => {:verify_card => true, :verification_currency_iso_code => "USD"}
|
1567
|
+
},
|
1568
|
+
)
|
1569
|
+
result.success?.should == true
|
1570
|
+
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
1571
|
+
end
|
1572
|
+
|
1573
|
+
it "can update the customer after validating verification_currency_iso_code against the given verification_merchant_account_id" do
|
1574
|
+
customer = Braintree::Customer.create!(
|
1575
|
+
:first_name => "Joe",
|
1576
|
+
)
|
1577
|
+
|
1578
|
+
result = Braintree::Customer.update(
|
1579
|
+
customer.id,
|
1580
|
+
:first_name => "New Joe",
|
1581
|
+
:credit_card => {
|
1582
|
+
:cardholder_name => "New Joe Cardholder",
|
1583
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1584
|
+
:expiration_date => "12/2009",
|
1585
|
+
:options => {:verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "USD"}
|
1586
|
+
},
|
1587
|
+
)
|
1588
|
+
result.success?.should == true
|
1589
|
+
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
1590
|
+
result.customer.credit_cards[0].verification.merchant_account_id == SpecHelper::NonDefaultMerchantAccountId
|
1591
|
+
end
|
1592
|
+
|
1593
|
+
it "throws error due to verification_currency_iso_code not matching against the currency configured in default merchant account" do
|
1594
|
+
customer = Braintree::Customer.create!(
|
1595
|
+
:first_name => "Joe",
|
1596
|
+
)
|
1597
|
+
|
1598
|
+
result = Braintree::Customer.update(
|
1599
|
+
customer.id,
|
1600
|
+
:first_name => "New Joe",
|
1601
|
+
:credit_card => {
|
1602
|
+
:cardholder_name => "New Joe Cardholder",
|
1603
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1604
|
+
:expiration_date => "12/2009",
|
1605
|
+
:options => {:verify_card => true, :verification_currency_iso_code => "GBP"}
|
1606
|
+
},
|
1607
|
+
)
|
1608
|
+
result.success?.should == false
|
1609
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
1610
|
+
|
1611
|
+
end
|
1612
|
+
|
1613
|
+
it "throws error due to verification_currency_iso_code not matching against the currency configured in the given verification merchant account" do
|
1614
|
+
customer = Braintree::Customer.create!(
|
1615
|
+
:first_name => "Joe",
|
1616
|
+
)
|
1617
|
+
|
1618
|
+
result = Braintree::Customer.update(
|
1619
|
+
customer.id,
|
1620
|
+
:first_name => "New Joe",
|
1621
|
+
:credit_card => {
|
1622
|
+
:cardholder_name => "New Joe Cardholder",
|
1623
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1624
|
+
:expiration_date => "12/2009",
|
1625
|
+
:options => {:verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "GBP"}
|
1626
|
+
},
|
1627
|
+
)
|
1628
|
+
result.success?.should == false
|
1629
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
1630
|
+
|
1631
|
+
end
|
1632
|
+
end
|
1633
|
+
|
1350
1634
|
context "verification_account_type" do
|
1351
1635
|
it "updates the credit card with account_type credit" do
|
1352
1636
|
customer = Braintree::Customer.create!
|
@@ -1362,7 +1646,7 @@ describe Braintree::Customer do
|
|
1362
1646
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
1363
1647
|
:verification_account_type => "credit",
|
1364
1648
|
},
|
1365
|
-
}
|
1649
|
+
},
|
1366
1650
|
)
|
1367
1651
|
expect(update_result).to be_success
|
1368
1652
|
end
|
@@ -1381,7 +1665,7 @@ describe Braintree::Customer do
|
|
1381
1665
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
1382
1666
|
:verification_account_type => "debit",
|
1383
1667
|
},
|
1384
|
-
}
|
1668
|
+
},
|
1385
1669
|
)
|
1386
1670
|
expect(update_result).to be_success
|
1387
1671
|
end
|
@@ -1392,12 +1676,12 @@ describe Braintree::Customer do
|
|
1392
1676
|
it "returns the updated customer if successful" do
|
1393
1677
|
customer = Braintree::Customer.create!(
|
1394
1678
|
:first_name => "Joe",
|
1395
|
-
:last_name => "Cool"
|
1679
|
+
:last_name => "Cool",
|
1396
1680
|
)
|
1397
1681
|
updated_customer = Braintree::Customer.update!(
|
1398
1682
|
customer.id,
|
1399
1683
|
:first_name => "Mr. Joe",
|
1400
|
-
:last_name => "Super Cool"
|
1684
|
+
:last_name => "Super Cool",
|
1401
1685
|
)
|
1402
1686
|
updated_customer.first_name.should == "Mr. Joe"
|
1403
1687
|
updated_customer.last_name.should == "Super Cool"
|
@@ -1421,7 +1705,7 @@ describe Braintree::Customer do
|
|
1421
1705
|
:options => {
|
1422
1706
|
:make_default => false
|
1423
1707
|
}
|
1424
|
-
}
|
1708
|
+
},
|
1425
1709
|
)
|
1426
1710
|
|
1427
1711
|
default_payment_method = Braintree::CreditCard.create!(
|
@@ -1430,7 +1714,7 @@ describe Braintree::Customer do
|
|
1430
1714
|
:expiration_date => "11/2015",
|
1431
1715
|
:options => {
|
1432
1716
|
:make_default => true
|
1433
|
-
}
|
1717
|
+
},
|
1434
1718
|
)
|
1435
1719
|
|
1436
1720
|
customer = Braintree::Customer.find(customer.id)
|
@@ -1443,7 +1727,7 @@ describe Braintree::Customer do
|
|
1443
1727
|
context "future" do
|
1444
1728
|
it "creates a customer with a future paypal account" do
|
1445
1729
|
result = Braintree::Customer.create(
|
1446
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
|
1730
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
1447
1731
|
)
|
1448
1732
|
|
1449
1733
|
result.should be_success
|
@@ -1457,7 +1741,7 @@ describe Braintree::Customer do
|
|
1457
1741
|
:options => {
|
1458
1742
|
:make_default => true
|
1459
1743
|
}
|
1460
|
-
}
|
1744
|
+
},
|
1461
1745
|
)
|
1462
1746
|
|
1463
1747
|
paypal_account_token = "PAYPAL_ACCOUNT_TOKEN_#{rand(36**3).to_s(36)}"
|
@@ -1466,12 +1750,12 @@ describe Braintree::Customer do
|
|
1466
1750
|
:token => paypal_account_token,
|
1467
1751
|
:options => {
|
1468
1752
|
:make_default => true
|
1469
|
-
}
|
1753
|
+
},
|
1470
1754
|
)
|
1471
1755
|
|
1472
1756
|
result = Braintree::Customer.update(
|
1473
1757
|
customer.id,
|
1474
|
-
:payment_method_nonce => nonce
|
1758
|
+
:payment_method_nonce => nonce,
|
1475
1759
|
)
|
1476
1760
|
|
1477
1761
|
result.should be_success
|
@@ -1487,7 +1771,7 @@ describe Braintree::Customer do
|
|
1487
1771
|
:token => paypal_account_token,
|
1488
1772
|
:options => {
|
1489
1773
|
:make_default => true
|
1490
|
-
}
|
1774
|
+
},
|
1491
1775
|
)
|
1492
1776
|
|
1493
1777
|
result = Braintree::Customer.create(
|
@@ -1523,7 +1807,7 @@ describe Braintree::Customer do
|
|
1523
1807
|
:options => {
|
1524
1808
|
:make_default => true
|
1525
1809
|
}
|
1526
|
-
}
|
1810
|
+
},
|
1527
1811
|
)
|
1528
1812
|
|
1529
1813
|
paypal_account_token = "PAYPAL_ACCOUNT_TOKEN_#{rand(36**3).to_s(36)}"
|
@@ -1532,7 +1816,7 @@ describe Braintree::Customer do
|
|
1532
1816
|
:token => paypal_account_token,
|
1533
1817
|
:options => {
|
1534
1818
|
:make_default => true
|
1535
|
-
}
|
1819
|
+
},
|
1536
1820
|
)
|
1537
1821
|
|
1538
1822
|
result = Braintree::Customer.update(
|
@@ -1566,7 +1850,7 @@ describe Braintree::Customer do
|
|
1566
1850
|
context "onetime" do
|
1567
1851
|
it "does not create a customer with a onetime paypal account" do
|
1568
1852
|
result = Braintree::Customer.create(
|
1569
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
|
1853
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
1570
1854
|
)
|
1571
1855
|
|
1572
1856
|
result.should_not be_success
|
@@ -1582,7 +1866,7 @@ describe Braintree::Customer do
|
|
1582
1866
|
:options => {
|
1583
1867
|
:make_default => true
|
1584
1868
|
}
|
1585
|
-
}
|
1869
|
+
},
|
1586
1870
|
)
|
1587
1871
|
|
1588
1872
|
paypal_account_token = "PAYPAL_ACCOUNT_TOKEN_#{rand(36**3).to_s(36)}"
|
@@ -1591,12 +1875,12 @@ describe Braintree::Customer do
|
|
1591
1875
|
:token => paypal_account_token,
|
1592
1876
|
:options => {
|
1593
1877
|
:make_default => true
|
1594
|
-
}
|
1878
|
+
},
|
1595
1879
|
)
|
1596
1880
|
|
1597
1881
|
result = Braintree::Customer.update(
|
1598
1882
|
customer.id,
|
1599
|
-
:payment_method_nonce => nonce
|
1883
|
+
:payment_method_nonce => nonce,
|
1600
1884
|
)
|
1601
1885
|
|
1602
1886
|
result.should_not be_success
|