braintree 3.0.1 → 4.0.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 +2 -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/bin_data.rb +9 -2
- 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 +4 -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 +10 -2
- 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 +4 -6
- 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 +43 -26
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction/paypal_details.rb +1 -0
- data/lib/braintree/transaction_gateway.rb +26 -5
- 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 +2 -2
- data/lib/braintree/visa_checkout_card.rb +2 -2
- data/lib/braintree/webhook_notification.rb +28 -19
- data/lib/braintree/webhook_notification_gateway.rb +5 -5
- data/lib/braintree/webhook_testing_gateway.rb +10 -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 +124 -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 +343 -149
- data/spec/integration/braintree/dispute_search_spec.rb +29 -4
- 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 +326 -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 +736 -380
- 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 +9 -9
- 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 +14 -4
- 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 +3 -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 +72 -56
- data/spec/unit/braintree/xml/rexml_spec.rb +51 -0
- data/spec/unit/braintree/xml_spec.rb +31 -31
- metadata +15 -19
- 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,18 @@ 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 "supports creation with tax_identifiers" do
|
119
|
+
result = Braintree::Customer.create(
|
120
|
+
:tax_identifiers => [
|
121
|
+
{:country_code => "US", :identifier => "987654321"},
|
122
|
+
{:country_code => "CL", :identifier => "123456789"}
|
123
|
+
],
|
112
124
|
)
|
113
125
|
|
114
126
|
result.should be_success
|
@@ -134,21 +146,21 @@ describe Braintree::Customer do
|
|
134
146
|
found_customer.last_name.should == last_name
|
135
147
|
else
|
136
148
|
result.customer.first_name.should == "José"
|
137
|
-
result.customer.first_name.bytes.map {|b| b.to_s(8)}.should == ["112", "157", "163", "303", "251"]
|
149
|
+
result.customer.first_name.bytes.map { |b| b.to_s(8) }.should == ["112", "157", "163", "303", "251"]
|
138
150
|
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"]
|
151
|
+
result.customer.last_name.bytes.map { |b| b.to_s(8) }.should == ["115", "165", "303", "261", "157", "172"]
|
140
152
|
|
141
153
|
found_customer = Braintree::Customer.find(result.customer.id)
|
142
154
|
found_customer.first_name.should == "José"
|
143
|
-
found_customer.first_name.bytes.map {|b| b.to_s(8)}.should == ["112", "157", "163", "303", "251"]
|
155
|
+
found_customer.first_name.bytes.map { |b| b.to_s(8) }.should == ["112", "157", "163", "303", "251"]
|
144
156
|
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"]
|
157
|
+
found_customer.last_name.bytes.map { |b| b.to_s(8) }.should == ["115", "165", "303", "261", "157", "172"]
|
146
158
|
end
|
147
159
|
end
|
148
160
|
|
149
161
|
it "returns an error response if invalid" do
|
150
162
|
result = Braintree::Customer.create(
|
151
|
-
:email => "@invalid.com"
|
163
|
+
:email => "@invalid.com",
|
152
164
|
)
|
153
165
|
result.success?.should == false
|
154
166
|
result.errors.for(:customer).on(:email)[0].message.should == "Email is an invalid format."
|
@@ -162,7 +174,7 @@ describe Braintree::Customer do
|
|
162
174
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
163
175
|
:expiration_date => "05/2010",
|
164
176
|
:cvv => "100"
|
165
|
-
}
|
177
|
+
},
|
166
178
|
)
|
167
179
|
|
168
180
|
result.success?.should == true
|
@@ -182,7 +194,7 @@ describe Braintree::Customer do
|
|
182
194
|
:email => "other@example.com",
|
183
195
|
:billing_agreement_id => "B-123456",
|
184
196
|
:options => {:make_default => true}
|
185
|
-
}
|
197
|
+
},
|
186
198
|
)
|
187
199
|
|
188
200
|
result.success?.should == true
|
@@ -200,7 +212,7 @@ describe Braintree::Customer do
|
|
200
212
|
:number => Braintree::Test::CreditCardNumbers::FailsSandboxVerification::MasterCard,
|
201
213
|
:expiration_date => "05/2010",
|
202
214
|
:options => {:verify_card => true}
|
203
|
-
}
|
215
|
+
},
|
204
216
|
)
|
205
217
|
result.success?.should == false
|
206
218
|
result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
@@ -214,7 +226,7 @@ describe Braintree::Customer do
|
|
214
226
|
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
215
227
|
:expiration_date => "05/2019",
|
216
228
|
:options => {:verify_card => true, :verification_amount => "2.00"}
|
217
|
-
}
|
229
|
+
},
|
218
230
|
)
|
219
231
|
result.success?.should == true
|
220
232
|
end
|
@@ -224,7 +236,7 @@ describe Braintree::Customer do
|
|
224
236
|
Braintree::CreditCard.create(
|
225
237
|
:customer_id => customer.id,
|
226
238
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
227
|
-
:expiration_date => "05/2015"
|
239
|
+
:expiration_date => "05/2015",
|
228
240
|
)
|
229
241
|
|
230
242
|
result = Braintree::Customer.create(
|
@@ -234,7 +246,7 @@ describe Braintree::Customer do
|
|
234
246
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
235
247
|
:expiration_date => "05/2015",
|
236
248
|
:options => {:fail_on_duplicate_payment_method => true}
|
237
|
-
}
|
249
|
+
},
|
238
250
|
)
|
239
251
|
result.success?.should == false
|
240
252
|
result.errors.for(:customer).for(:credit_card).on(:number)[0].message.should == "Duplicate card exists in the vault."
|
@@ -251,12 +263,98 @@ describe Braintree::Customer do
|
|
251
263
|
:verify_card => true,
|
252
264
|
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
|
253
265
|
}
|
254
|
-
}
|
266
|
+
},
|
255
267
|
)
|
256
268
|
result.success?.should == false
|
257
269
|
result.credit_card_verification.status.should == Braintree::Transaction::Status::ProcessorDeclined
|
258
270
|
end
|
259
271
|
|
272
|
+
it "can create a customer and a payment method at the same time after validating verification_currency_iso_code" do
|
273
|
+
result = Braintree::Customer.create(
|
274
|
+
:first_name => "Mike",
|
275
|
+
:last_name => "Jones",
|
276
|
+
:credit_card => {
|
277
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
278
|
+
:expiration_date => "05/2010",
|
279
|
+
:cvv => "100",
|
280
|
+
:options => {
|
281
|
+
:verify_card => true,
|
282
|
+
:verification_currency_iso_code => "USD"
|
283
|
+
}
|
284
|
+
},
|
285
|
+
)
|
286
|
+
|
287
|
+
result.success?.should == true
|
288
|
+
result.customer.first_name.should == "Mike"
|
289
|
+
result.customer.last_name.should == "Jones"
|
290
|
+
result.customer.credit_cards[0].bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
|
291
|
+
result.customer.credit_cards[0].last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
|
292
|
+
result.customer.credit_cards[0].expiration_date.should == "05/2010"
|
293
|
+
result.customer.credit_cards[0].unique_number_identifier.should =~ /\A\w{32}\z/
|
294
|
+
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
295
|
+
end
|
296
|
+
|
297
|
+
it "errors when verification_currency_iso_code is not supported by merchant account" do
|
298
|
+
result = Braintree::Customer.create(
|
299
|
+
:first_name => "Mike",
|
300
|
+
:last_name => "Jones",
|
301
|
+
:credit_card => {
|
302
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
303
|
+
:expiration_date => "05/2010",
|
304
|
+
:cvv => "100",
|
305
|
+
:options => {
|
306
|
+
:verify_card => true,
|
307
|
+
:verification_currency_iso_code => "GBP"
|
308
|
+
}
|
309
|
+
},
|
310
|
+
)
|
311
|
+
expect(result).to_not be_success
|
312
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
313
|
+
end
|
314
|
+
|
315
|
+
it "validates verification_currency_iso_code of the given verification_merchant_account_id and creates customer" do
|
316
|
+
result = Braintree::Customer.create(
|
317
|
+
:first_name => "Mike",
|
318
|
+
:last_name => "Jones",
|
319
|
+
:credit_card => {
|
320
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
321
|
+
:expiration_date => "05/2010",
|
322
|
+
:options => {
|
323
|
+
:verify_card => true,
|
324
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
325
|
+
:verification_currency_iso_code => "USD"
|
326
|
+
}
|
327
|
+
},
|
328
|
+
)
|
329
|
+
result.success?.should == true
|
330
|
+
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
331
|
+
result.customer.first_name.should == "Mike"
|
332
|
+
result.customer.last_name.should == "Jones"
|
333
|
+
result.customer.credit_cards[0].bin.should == Braintree::Test::CreditCardNumbers::MasterCard[0, 6]
|
334
|
+
result.customer.credit_cards[0].last_4.should == Braintree::Test::CreditCardNumbers::MasterCard[-4..-1]
|
335
|
+
result.customer.credit_cards[0].expiration_date.should == "05/2010"
|
336
|
+
result.customer.credit_cards[0].unique_number_identifier.should =~ /\A\w{32}\z/
|
337
|
+
end
|
338
|
+
|
339
|
+
it "validates verification_currency_iso_code of the given verification_merchant_account_id and returns error" do
|
340
|
+
result = Braintree::Customer.create(
|
341
|
+
:first_name => "Mike",
|
342
|
+
:last_name => "Jones",
|
343
|
+
:credit_card => {
|
344
|
+
:number => Braintree::Test::CreditCardNumbers::MasterCard,
|
345
|
+
:expiration_date => "05/2010",
|
346
|
+
:options => {
|
347
|
+
:verify_card => true,
|
348
|
+
:verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
|
349
|
+
:verification_currency_iso_code => "GBP"
|
350
|
+
}
|
351
|
+
},
|
352
|
+
)
|
353
|
+
expect(result).to_not be_success
|
354
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
355
|
+
end
|
356
|
+
|
357
|
+
|
260
358
|
it "can create a customer, payment method, and billing address at the same time" do
|
261
359
|
result = Braintree::Customer.create(
|
262
360
|
:first_name => "Mike",
|
@@ -272,7 +370,7 @@ describe Braintree::Customer do
|
|
272
370
|
:postal_code => "60622",
|
273
371
|
:country_name => "United States of America"
|
274
372
|
}
|
275
|
-
}
|
373
|
+
},
|
276
374
|
)
|
277
375
|
result.success?.should == true
|
278
376
|
result.customer.first_name.should == "Mike"
|
@@ -303,7 +401,7 @@ describe Braintree::Customer do
|
|
303
401
|
:country_code_alpha3 => "COM",
|
304
402
|
:country_code_numeric => "174"
|
305
403
|
}
|
306
|
-
}
|
404
|
+
},
|
307
405
|
)
|
308
406
|
result.success?.should == true
|
309
407
|
result.customer.addresses[0].country_name.should == "Comoros"
|
@@ -318,7 +416,7 @@ describe Braintree::Customer do
|
|
318
416
|
:last_name => "Gates",
|
319
417
|
:custom_fields => {
|
320
418
|
:store_me => "custom value"
|
321
|
-
}
|
419
|
+
},
|
322
420
|
)
|
323
421
|
result.success?.should == true
|
324
422
|
result.customer.custom_fields[:store_me].should == "custom value"
|
@@ -328,7 +426,7 @@ describe Braintree::Customer do
|
|
328
426
|
result = Braintree::Customer.create(
|
329
427
|
:first_name => "Bill",
|
330
428
|
:last_name => "Gates",
|
331
|
-
:custom_fields => {
|
429
|
+
:custom_fields => {:store_me => ""},
|
332
430
|
)
|
333
431
|
result.success?.should == true
|
334
432
|
result.customer.custom_fields.should == {}
|
@@ -342,7 +440,7 @@ describe Braintree::Customer do
|
|
342
440
|
:billing_address => {
|
343
441
|
:country_name => "invalid"
|
344
442
|
}
|
345
|
-
}
|
443
|
+
},
|
346
444
|
)
|
347
445
|
result.success?.should == false
|
348
446
|
result.errors.for(:customer).on(:email)[0].message.should == "Email is an invalid format."
|
@@ -362,10 +460,10 @@ describe Braintree::Customer do
|
|
362
460
|
:country_code_alpha2 => "US",
|
363
461
|
:country_code_alpha3 => "COM",
|
364
462
|
}
|
365
|
-
}
|
463
|
+
},
|
366
464
|
)
|
367
465
|
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)
|
466
|
+
result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:base).map { |e| e.code }.should include(Braintree::ErrorCodes::Address::InconsistentCountry)
|
369
467
|
end
|
370
468
|
|
371
469
|
it "returns an error if country code alpha2 is invalid" do
|
@@ -378,10 +476,10 @@ describe Braintree::Customer do
|
|
378
476
|
:billing_address => {
|
379
477
|
:country_code_alpha2 => "zz",
|
380
478
|
}
|
381
|
-
}
|
479
|
+
},
|
382
480
|
)
|
383
481
|
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)
|
482
|
+
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
483
|
end
|
386
484
|
|
387
485
|
it "returns an error if country code alpha3 is invalid" do
|
@@ -394,10 +492,10 @@ describe Braintree::Customer do
|
|
394
492
|
:billing_address => {
|
395
493
|
:country_code_alpha3 => "zzz",
|
396
494
|
}
|
397
|
-
}
|
495
|
+
},
|
398
496
|
)
|
399
497
|
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)
|
498
|
+
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
499
|
end
|
402
500
|
|
403
501
|
it "returns an error if country code numeric is invalid" do
|
@@ -410,10 +508,10 @@ describe Braintree::Customer do
|
|
410
508
|
:billing_address => {
|
411
509
|
:country_code_numeric => "zzz",
|
412
510
|
}
|
413
|
-
}
|
511
|
+
},
|
414
512
|
)
|
415
513
|
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)
|
514
|
+
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
515
|
end
|
418
516
|
|
419
517
|
it "returns errors if custom_fields are not registered" do
|
@@ -422,7 +520,7 @@ describe Braintree::Customer do
|
|
422
520
|
:last_name => "Kennedy",
|
423
521
|
:custom_fields => {
|
424
522
|
:spouse_name => "Jacqueline"
|
425
|
-
}
|
523
|
+
},
|
426
524
|
)
|
427
525
|
result.success?.should == false
|
428
526
|
result.errors.for(:customer).on(:custom_fields)[0].message.should == "Custom field is invalid: spouse_name."
|
@@ -435,7 +533,7 @@ describe Braintree::Customer do
|
|
435
533
|
:last_name => "Hamlin",
|
436
534
|
:credit_card => {
|
437
535
|
:venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::VisaPaymentMethodCode
|
438
|
-
}
|
536
|
+
},
|
439
537
|
)
|
440
538
|
result.success?.should == true
|
441
539
|
result.customer.credit_cards.first.bin.should == "400934"
|
@@ -452,7 +550,7 @@ describe Braintree::Customer do
|
|
452
550
|
:options => {
|
453
551
|
:venmo_sdk_session => Braintree::Test::VenmoSDK::Session
|
454
552
|
}
|
455
|
-
}
|
553
|
+
},
|
456
554
|
)
|
457
555
|
result.success?.should == true
|
458
556
|
result.customer.credit_cards.first.venmo_sdk?.should == false
|
@@ -467,13 +565,13 @@ describe Braintree::Customer do
|
|
467
565
|
:expiration_month => "11",
|
468
566
|
:expiration_year => "2099",
|
469
567
|
},
|
470
|
-
:share => true
|
568
|
+
:share => true,
|
471
569
|
)
|
472
570
|
|
473
571
|
result = Braintree::Customer.create(
|
474
572
|
:credit_card => {
|
475
573
|
:payment_method_nonce => nonce
|
476
|
-
}
|
574
|
+
},
|
477
575
|
)
|
478
576
|
|
479
577
|
result.success?.should == true
|
@@ -503,7 +601,7 @@ describe Braintree::Customer do
|
|
503
601
|
:number => Braintree::Test::CreditCardNumbers::Hiper,
|
504
602
|
:expiration_month => "11",
|
505
603
|
:expiration_year => "2099",
|
506
|
-
}
|
604
|
+
},
|
507
605
|
)
|
508
606
|
result = Braintree::Customer.create(
|
509
607
|
:payment_method_nonce => nonce,
|
@@ -513,7 +611,7 @@ describe Braintree::Customer do
|
|
513
611
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
514
612
|
:verification_account_type => "debit",
|
515
613
|
}
|
516
|
-
}
|
614
|
+
},
|
517
615
|
)
|
518
616
|
|
519
617
|
expect(result).to be_success
|
@@ -525,7 +623,7 @@ describe Braintree::Customer do
|
|
525
623
|
:number => Braintree::Test::CreditCardNumbers::Hiper,
|
526
624
|
:expiration_month => "11",
|
527
625
|
:expiration_year => "2099",
|
528
|
-
}
|
626
|
+
},
|
529
627
|
)
|
530
628
|
result = Braintree::Customer.create(
|
531
629
|
:payment_method_nonce => nonce,
|
@@ -535,7 +633,7 @@ describe Braintree::Customer do
|
|
535
633
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
536
634
|
:verification_account_type => "credit",
|
537
635
|
}
|
538
|
-
}
|
636
|
+
},
|
539
637
|
)
|
540
638
|
|
541
639
|
expect(result).to be_success
|
@@ -547,7 +645,7 @@ describe Braintree::Customer do
|
|
547
645
|
:number => Braintree::Test::CreditCardNumbers::Hiper,
|
548
646
|
:expiration_month => "11",
|
549
647
|
:expiration_year => "2099",
|
550
|
-
}
|
648
|
+
},
|
551
649
|
)
|
552
650
|
result = Braintree::Customer.create(
|
553
651
|
:payment_method_nonce => nonce,
|
@@ -557,7 +655,7 @@ describe Braintree::Customer do
|
|
557
655
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
558
656
|
:verification_account_type => "ach",
|
559
657
|
}
|
560
|
-
}
|
658
|
+
},
|
561
659
|
)
|
562
660
|
|
563
661
|
expect(result).to_not be_success
|
@@ -570,7 +668,7 @@ describe Braintree::Customer do
|
|
570
668
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
571
669
|
:expiration_month => "11",
|
572
670
|
:expiration_year => "2099",
|
573
|
-
}
|
671
|
+
},
|
574
672
|
)
|
575
673
|
result = Braintree::Customer.create(
|
576
674
|
:payment_method_nonce => nonce,
|
@@ -579,7 +677,7 @@ describe Braintree::Customer do
|
|
579
677
|
:verify_card => true,
|
580
678
|
:verification_account_type => "credit",
|
581
679
|
}
|
582
|
-
}
|
680
|
+
},
|
583
681
|
)
|
584
682
|
|
585
683
|
expect(result).to_not be_success
|
@@ -592,7 +690,7 @@ describe Braintree::Customer do
|
|
592
690
|
it "returns the customer if successful" do
|
593
691
|
customer = Braintree::Customer.create!(
|
594
692
|
:first_name => "Jim",
|
595
|
-
:last_name => "Smith"
|
693
|
+
:last_name => "Smith",
|
596
694
|
)
|
597
695
|
customer.id.should =~ /\d+/
|
598
696
|
customer.first_name.should == "Jim"
|
@@ -617,7 +715,7 @@ describe Braintree::Customer do
|
|
617
715
|
:credit_card => {
|
618
716
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
619
717
|
:expiration_date => "05/2010"
|
620
|
-
}
|
718
|
+
},
|
621
719
|
)
|
622
720
|
result = Braintree::Customer.credit(customer.id, :amount => "100.00")
|
623
721
|
result.success?.should == true
|
@@ -637,7 +735,7 @@ describe Braintree::Customer do
|
|
637
735
|
:credit_card => {
|
638
736
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
639
737
|
:expiration_date => "05/2010"
|
640
|
-
}
|
738
|
+
},
|
641
739
|
)
|
642
740
|
transaction = Braintree::Customer.credit!(customer.id, :amount => "100.00")
|
643
741
|
transaction.amount.should == BigDecimal("100.00")
|
@@ -656,7 +754,7 @@ describe Braintree::Customer do
|
|
656
754
|
:credit_card => {
|
657
755
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
658
756
|
:expiration_date => "05/2010"
|
659
|
-
}
|
757
|
+
},
|
660
758
|
)
|
661
759
|
result = Braintree::Customer.sale(customer.id, :amount => "100.00")
|
662
760
|
result.success?.should == true
|
@@ -676,7 +774,7 @@ describe Braintree::Customer do
|
|
676
774
|
:credit_card => {
|
677
775
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
678
776
|
:expiration_date => "05/2010"
|
679
|
-
}
|
777
|
+
},
|
680
778
|
)
|
681
779
|
transaction = Braintree::Customer.sale!(customer.id, :amount => "100.00")
|
682
780
|
transaction.amount.should == BigDecimal("100.00")
|
@@ -695,7 +793,7 @@ describe Braintree::Customer do
|
|
695
793
|
:credit_card => {
|
696
794
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
697
795
|
:expiration_date => "05/2010"
|
698
|
-
}
|
796
|
+
},
|
699
797
|
)
|
700
798
|
transaction = Braintree::Customer.sale!(customer.id, :amount => "100.00")
|
701
799
|
collection = Braintree::Customer.transactions(customer.id)
|
@@ -709,10 +807,10 @@ describe Braintree::Customer do
|
|
709
807
|
:credit_card => {
|
710
808
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
711
809
|
:expiration_date => "05/2010"
|
712
|
-
}
|
810
|
+
},
|
713
811
|
)
|
714
812
|
result = customer.credit(
|
715
|
-
:amount => "100.00"
|
813
|
+
:amount => "100.00",
|
716
814
|
)
|
717
815
|
result.success?.should == true
|
718
816
|
result.transaction.amount.should == BigDecimal("100.00")
|
@@ -731,7 +829,7 @@ describe Braintree::Customer do
|
|
731
829
|
:credit_card => {
|
732
830
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
733
831
|
:expiration_date => "05/2010"
|
734
|
-
}
|
832
|
+
},
|
735
833
|
)
|
736
834
|
transaction = customer.credit!(:amount => "100.00")
|
737
835
|
transaction.amount.should == BigDecimal("100.00")
|
@@ -748,7 +846,7 @@ describe Braintree::Customer do
|
|
748
846
|
it "deletes the customer" do
|
749
847
|
result = Braintree::Customer.create(
|
750
848
|
:first_name => "Joe",
|
751
|
-
:last_name => "Cool"
|
849
|
+
:last_name => "Cool",
|
752
850
|
)
|
753
851
|
result.success?.should == true
|
754
852
|
|
@@ -765,7 +863,7 @@ describe Braintree::Customer do
|
|
765
863
|
it "finds the customer with the given id" do
|
766
864
|
result = Braintree::Customer.create(
|
767
865
|
:first_name => "Joe",
|
768
|
-
:last_name => "Cool"
|
866
|
+
:last_name => "Cool",
|
769
867
|
)
|
770
868
|
result.success?.should == true
|
771
869
|
|
@@ -781,13 +879,13 @@ describe Braintree::Customer do
|
|
781
879
|
credit_card = Braintree::CreditCard.create(
|
782
880
|
:customer_id => customer.id,
|
783
881
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
784
|
-
:expiration_date => "05/2012"
|
882
|
+
:expiration_date => "05/2012",
|
785
883
|
).credit_card
|
786
884
|
|
787
885
|
subscription = Braintree::Subscription.create(
|
788
886
|
:payment_method_token => credit_card.token,
|
789
887
|
:plan_id => "integration_trialless_plan",
|
790
|
-
:price => "1.00"
|
888
|
+
:price => "1.00",
|
791
889
|
).subscription
|
792
890
|
|
793
891
|
found_customer = Braintree::Customer.find(customer.id)
|
@@ -802,7 +900,7 @@ describe Braintree::Customer do
|
|
802
900
|
customer = Braintree::Customer.create(
|
803
901
|
:custom_fields => {
|
804
902
|
:store_me => "custom value"
|
805
|
-
}
|
903
|
+
},
|
806
904
|
).customer
|
807
905
|
credit_card = Braintree::CreditCard.create(
|
808
906
|
:customer_id => customer.id,
|
@@ -814,13 +912,13 @@ describe Braintree::Customer do
|
|
814
912
|
:region => "Illinois",
|
815
913
|
:postal_code => "60622",
|
816
914
|
:country_name => "United States of America"
|
817
|
-
}
|
915
|
+
},
|
818
916
|
).credit_card
|
819
917
|
|
820
918
|
subscription = Braintree::Subscription.create(
|
821
919
|
:payment_method_token => credit_card.token,
|
822
920
|
:plan_id => "integration_trialless_plan",
|
823
|
-
:price => "1.00"
|
921
|
+
:price => "1.00",
|
824
922
|
).subscription
|
825
923
|
|
826
924
|
found_customer = Braintree::Customer.find(customer.id, {
|
@@ -836,7 +934,7 @@ describe Braintree::Customer do
|
|
836
934
|
customer = Braintree::Customer.create(
|
837
935
|
:custom_fields => {
|
838
936
|
:store_me => "custom value"
|
839
|
-
}
|
937
|
+
},
|
840
938
|
).customer
|
841
939
|
credit_card = Braintree::CreditCard.create(
|
842
940
|
:customer_id => customer.id,
|
@@ -848,13 +946,13 @@ describe Braintree::Customer do
|
|
848
946
|
:region => "Illinois",
|
849
947
|
:postal_code => "60622",
|
850
948
|
:country_name => "United States of America"
|
851
|
-
}
|
949
|
+
},
|
852
950
|
).credit_card
|
853
951
|
|
854
952
|
subscription = Braintree::Subscription.create(
|
855
953
|
:payment_method_token => credit_card.token,
|
856
954
|
:plan_id => "integration_trialless_plan",
|
857
|
-
:price => "1.00"
|
955
|
+
:price => "1.00",
|
858
956
|
).subscription
|
859
957
|
|
860
958
|
found_customer = Braintree::Customer.find(customer.id, {
|
@@ -872,7 +970,7 @@ describe Braintree::Customer do
|
|
872
970
|
|
873
971
|
it "returns associated ApplePayCards" do
|
874
972
|
result = Braintree::Customer.create(
|
875
|
-
:payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx
|
973
|
+
:payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx,
|
876
974
|
)
|
877
975
|
result.success?.should == true
|
878
976
|
|
@@ -887,7 +985,7 @@ describe Braintree::Customer do
|
|
887
985
|
|
888
986
|
it "returns associated google pay proxy cards" do
|
889
987
|
result = Braintree::Customer.create(
|
890
|
-
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover
|
988
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
891
989
|
)
|
892
990
|
result.success?.should == true
|
893
991
|
|
@@ -903,7 +1001,7 @@ describe Braintree::Customer do
|
|
903
1001
|
|
904
1002
|
it "returns associated google pay network tokens" do
|
905
1003
|
result = Braintree::Customer.create(
|
906
|
-
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard
|
1004
|
+
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
|
907
1005
|
)
|
908
1006
|
result.success?.should == true
|
909
1007
|
|
@@ -919,7 +1017,7 @@ describe Braintree::Customer do
|
|
919
1017
|
|
920
1018
|
it "returns associated venmo accounts" do
|
921
1019
|
result = Braintree::Customer.create(
|
922
|
-
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount
|
1020
|
+
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
|
923
1021
|
)
|
924
1022
|
result.success?.should == true
|
925
1023
|
|
@@ -939,7 +1037,7 @@ describe Braintree::Customer do
|
|
939
1037
|
:options => {
|
940
1038
|
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
|
941
1039
|
}
|
942
|
-
}
|
1040
|
+
},
|
943
1041
|
)
|
944
1042
|
result.should be_success
|
945
1043
|
|
@@ -985,7 +1083,7 @@ describe Braintree::Customer do
|
|
985
1083
|
it "updates the credit card with three_d_secure pass thru params" do
|
986
1084
|
customer = Braintree::Customer.create!(
|
987
1085
|
:first_name => "Joe",
|
988
|
-
:last_name => "Cool"
|
1086
|
+
:last_name => "Cool",
|
989
1087
|
)
|
990
1088
|
result = Braintree::Customer.update(
|
991
1089
|
customer.id,
|
@@ -998,17 +1096,17 @@ describe Braintree::Customer do
|
|
998
1096
|
:number => 4111111111111111,
|
999
1097
|
:expiration_date => "05/2060",
|
1000
1098
|
: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 =>
|
1099
|
+
:eci_flag => "02",
|
1100
|
+
:cavv => "some_cavv",
|
1101
|
+
:xid => "some_xid",
|
1102
|
+
:three_d_secure_version => "1.0.2",
|
1103
|
+
:authentication_response => "Y",
|
1104
|
+
:directory_response => "Y",
|
1105
|
+
:cavv_algorithm => "2",
|
1106
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
1009
1107
|
},
|
1010
1108
|
:options => {:verify_card => true},
|
1011
|
-
}
|
1109
|
+
},
|
1012
1110
|
)
|
1013
1111
|
result.success?.should == true
|
1014
1112
|
result.customer.id.should == customer.id
|
@@ -1020,7 +1118,7 @@ describe Braintree::Customer do
|
|
1020
1118
|
it "validates the presence of three_d_secure_version while passing three_d_secure_pass_thru in update" do
|
1021
1119
|
customer = Braintree::Customer.create!(
|
1022
1120
|
:first_name => "Joe",
|
1023
|
-
:last_name => "Cool"
|
1121
|
+
:last_name => "Cool",
|
1024
1122
|
)
|
1025
1123
|
result = Braintree::Customer.update(
|
1026
1124
|
customer.id,
|
@@ -1033,16 +1131,16 @@ describe Braintree::Customer do
|
|
1033
1131
|
:number => 4111111111111111,
|
1034
1132
|
:expiration_date => "05/2060",
|
1035
1133
|
: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 =>
|
1134
|
+
:eci_flag => "02",
|
1135
|
+
:cavv => "some_cavv",
|
1136
|
+
:xid => "some_xid",
|
1137
|
+
:authentication_response => "Y",
|
1138
|
+
:directory_response => "Y",
|
1139
|
+
:cavv_algorithm => "2",
|
1140
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
1043
1141
|
},
|
1044
1142
|
options: {:verify_card => true}
|
1045
|
-
}
|
1143
|
+
},
|
1046
1144
|
)
|
1047
1145
|
expect(result).to_not be_success
|
1048
1146
|
error = result.errors.for(:verification).first
|
@@ -1053,7 +1151,7 @@ describe Braintree::Customer do
|
|
1053
1151
|
it "updates the customer with the given id if successful" do
|
1054
1152
|
customer = Braintree::Customer.create!(
|
1055
1153
|
:first_name => "Joe",
|
1056
|
-
:last_name => "Cool"
|
1154
|
+
:last_name => "Cool",
|
1057
1155
|
)
|
1058
1156
|
result = Braintree::Customer.update(
|
1059
1157
|
customer.id,
|
@@ -1061,7 +1159,7 @@ describe Braintree::Customer do
|
|
1061
1159
|
:last_name => "Super Cool",
|
1062
1160
|
:custom_fields => {
|
1063
1161
|
:store_me => "a value"
|
1064
|
-
}
|
1162
|
+
},
|
1065
1163
|
)
|
1066
1164
|
result.success?.should == true
|
1067
1165
|
result.customer.id.should == customer.id
|
@@ -1075,7 +1173,7 @@ describe Braintree::Customer do
|
|
1075
1173
|
:credit_card => {
|
1076
1174
|
:number => 4111111111111111,
|
1077
1175
|
:expiration_date => "05/2010",
|
1078
|
-
}
|
1176
|
+
},
|
1079
1177
|
)
|
1080
1178
|
result = Braintree::Customer.update(
|
1081
1179
|
customer.id,
|
@@ -1085,7 +1183,7 @@ describe Braintree::Customer do
|
|
1085
1183
|
:options=> {
|
1086
1184
|
:fail_on_duplicate_payment_method => true
|
1087
1185
|
}
|
1088
|
-
}
|
1186
|
+
},
|
1089
1187
|
)
|
1090
1188
|
result.success?.should == false
|
1091
1189
|
result.errors.for(:customer).for(:credit_card).on(:number)[0].message.should == "Duplicate card exists in the vault."
|
@@ -1094,7 +1192,7 @@ describe Braintree::Customer do
|
|
1094
1192
|
it "updates the default payment method" do
|
1095
1193
|
customer = Braintree::Customer.create!(
|
1096
1194
|
:first_name => "Joe",
|
1097
|
-
:last_name => "Brown"
|
1195
|
+
:last_name => "Brown",
|
1098
1196
|
)
|
1099
1197
|
|
1100
1198
|
token1 = random_payment_method_token
|
@@ -1102,7 +1200,7 @@ describe Braintree::Customer do
|
|
1102
1200
|
payment_method1 = Braintree::PaymentMethod.create(
|
1103
1201
|
:customer_id => customer.id,
|
1104
1202
|
:payment_method_nonce => Braintree::Test::Nonce::TransactableVisa,
|
1105
|
-
:token => token1
|
1203
|
+
:token => token1,
|
1106
1204
|
)
|
1107
1205
|
|
1108
1206
|
payment_method1 = Braintree::PaymentMethod.find(token1)
|
@@ -1113,11 +1211,11 @@ describe Braintree::Customer do
|
|
1113
1211
|
payment_method2 = Braintree::PaymentMethod.create(
|
1114
1212
|
:customer_id => customer.id,
|
1115
1213
|
:payment_method_nonce => Braintree::Test::Nonce::TransactableMasterCard,
|
1116
|
-
:token => token2
|
1214
|
+
:token => token2,
|
1117
1215
|
)
|
1118
1216
|
|
1119
1217
|
Braintree::Customer.update(customer.id,
|
1120
|
-
:default_payment_method_token => token2
|
1218
|
+
:default_payment_method_token => token2,
|
1121
1219
|
)
|
1122
1220
|
|
1123
1221
|
payment_method2 = Braintree::PaymentMethod.find(token2)
|
@@ -1127,7 +1225,7 @@ describe Braintree::Customer do
|
|
1127
1225
|
it "updates the default payment method in the options" do
|
1128
1226
|
customer = Braintree::Customer.create!(
|
1129
1227
|
:first_name => "Joe",
|
1130
|
-
:last_name => "Brown"
|
1228
|
+
:last_name => "Brown",
|
1131
1229
|
)
|
1132
1230
|
|
1133
1231
|
token1 = random_payment_method_token
|
@@ -1135,7 +1233,7 @@ describe Braintree::Customer do
|
|
1135
1233
|
payment_method1 = Braintree::PaymentMethod.create(
|
1136
1234
|
:customer_id => customer.id,
|
1137
1235
|
:payment_method_nonce => Braintree::Test::Nonce::TransactableVisa,
|
1138
|
-
:token => token1
|
1236
|
+
:token => token1,
|
1139
1237
|
)
|
1140
1238
|
|
1141
1239
|
payment_method1 = Braintree::PaymentMethod.find(token1)
|
@@ -1146,7 +1244,7 @@ describe Braintree::Customer do
|
|
1146
1244
|
payment_method2 = Braintree::PaymentMethod.create(
|
1147
1245
|
:customer_id => customer.id,
|
1148
1246
|
:payment_method_nonce => Braintree::Test::Nonce::TransactableMasterCard,
|
1149
|
-
:token => token2
|
1247
|
+
:token => token2,
|
1150
1248
|
)
|
1151
1249
|
|
1152
1250
|
Braintree::Customer.update(customer.id,
|
@@ -1155,7 +1253,7 @@ describe Braintree::Customer do
|
|
1155
1253
|
:update_existing_token => token2,
|
1156
1254
|
:make_default => true
|
1157
1255
|
}
|
1158
|
-
}
|
1256
|
+
},
|
1159
1257
|
)
|
1160
1258
|
|
1161
1259
|
payment_method2 = Braintree::PaymentMethod.find(token2)
|
@@ -1165,7 +1263,7 @@ describe Braintree::Customer do
|
|
1165
1263
|
it "can use any country code" do
|
1166
1264
|
customer = Braintree::Customer.create!(
|
1167
1265
|
:first_name => "Alex",
|
1168
|
-
:last_name => "Matterson"
|
1266
|
+
:last_name => "Matterson",
|
1169
1267
|
)
|
1170
1268
|
result = Braintree::Customer.update(
|
1171
1269
|
customer.id,
|
@@ -1180,7 +1278,7 @@ describe Braintree::Customer do
|
|
1180
1278
|
:country_code_alpha3 => "FJI",
|
1181
1279
|
:country_code_numeric => "242"
|
1182
1280
|
}
|
1183
|
-
}
|
1281
|
+
},
|
1184
1282
|
)
|
1185
1283
|
result.success?.should == true
|
1186
1284
|
result.customer.addresses[0].country_name.should == "Fiji"
|
@@ -1199,7 +1297,7 @@ describe Braintree::Customer do
|
|
1199
1297
|
:first_name => "Joe",
|
1200
1298
|
:postal_code => "60622"
|
1201
1299
|
}
|
1202
|
-
}
|
1300
|
+
},
|
1203
1301
|
)
|
1204
1302
|
|
1205
1303
|
result = Braintree::Customer.update(
|
@@ -1207,13 +1305,13 @@ describe Braintree::Customer do
|
|
1207
1305
|
:first_name => "New Joe",
|
1208
1306
|
:credit_card => {
|
1209
1307
|
:cardholder_name => "New Joe Cardholder",
|
1210
|
-
:options => {
|
1308
|
+
:options => {:update_existing_token => customer.credit_cards.first.token},
|
1211
1309
|
:billing_address => {
|
1212
1310
|
:last_name => "Cool",
|
1213
1311
|
:postal_code => "60666",
|
1214
|
-
:options => {
|
1312
|
+
:options => {:update_existing => true}
|
1215
1313
|
}
|
1216
|
-
}
|
1314
|
+
},
|
1217
1315
|
)
|
1218
1316
|
result.success?.should == true
|
1219
1317
|
result.customer.id.should == customer.id
|
@@ -1231,7 +1329,7 @@ describe Braintree::Customer do
|
|
1231
1329
|
|
1232
1330
|
it "can update the customer and verify_card with a specific verification_amount" do
|
1233
1331
|
customer = Braintree::Customer.create!(
|
1234
|
-
:first_name => "Joe"
|
1332
|
+
:first_name => "Joe",
|
1235
1333
|
)
|
1236
1334
|
|
1237
1335
|
result = Braintree::Customer.update(
|
@@ -1241,8 +1339,23 @@ describe Braintree::Customer do
|
|
1241
1339
|
:cardholder_name => "New Joe Cardholder",
|
1242
1340
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1243
1341
|
:expiration_date => "12/2009",
|
1244
|
-
:options => {
|
1245
|
-
}
|
1342
|
+
:options => {:verify_card => true, :verification_amount => "2.00"}
|
1343
|
+
},
|
1344
|
+
)
|
1345
|
+
result.success?.should == true
|
1346
|
+
end
|
1347
|
+
|
1348
|
+
it "can update a tax_identifier" do
|
1349
|
+
customer = Braintree::Customer.create!(
|
1350
|
+
:tax_identifiers => [
|
1351
|
+
{:country_code => "US", :identifier => "987654321"},
|
1352
|
+
{:country_code => "CL", :identifier => "123456789"}
|
1353
|
+
],
|
1354
|
+
)
|
1355
|
+
|
1356
|
+
result = Braintree::Customer.update(
|
1357
|
+
customer.id,
|
1358
|
+
:tax_identifiers => [{:country_code => "US", :identifier => "567891234"}],
|
1246
1359
|
)
|
1247
1360
|
result.success?.should == true
|
1248
1361
|
end
|
@@ -1252,17 +1365,17 @@ describe Braintree::Customer do
|
|
1252
1365
|
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
1253
1366
|
:credit_card => {
|
1254
1367
|
: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 =>
|
1368
|
+
:eci_flag => "02",
|
1369
|
+
:cavv => "some_cavv",
|
1370
|
+
:xid => "some_xid",
|
1371
|
+
:three_d_secure_version => "xx",
|
1372
|
+
:authentication_response => "Y",
|
1373
|
+
:directory_response => "Y",
|
1374
|
+
:cavv_algorithm => "2",
|
1375
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
1263
1376
|
},
|
1264
1377
|
:options => {:verify_card => true}
|
1265
|
-
}
|
1378
|
+
},
|
1266
1379
|
)
|
1267
1380
|
|
1268
1381
|
expect(result).not_to be_success
|
@@ -1276,17 +1389,17 @@ describe Braintree::Customer do
|
|
1276
1389
|
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
1277
1390
|
:credit_card => {
|
1278
1391
|
: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 =>
|
1392
|
+
:eci_flag => "02",
|
1393
|
+
:cavv => "some_cavv",
|
1394
|
+
:xid => "some_xid",
|
1395
|
+
:three_d_secure_version => "2.2.1",
|
1396
|
+
:authentication_response => "Y",
|
1397
|
+
:directory_response => "Y",
|
1398
|
+
:cavv_algorithm => "2",
|
1399
|
+
:ds_transaction_id => "some_ds_transaction_id",
|
1287
1400
|
},
|
1288
1401
|
:options => {:verify_card => true}
|
1289
|
-
}
|
1402
|
+
},
|
1290
1403
|
)
|
1291
1404
|
|
1292
1405
|
expect(result).to be_success
|
@@ -1297,7 +1410,7 @@ describe Braintree::Customer do
|
|
1297
1410
|
:payment_method_nonce => Braintree::Test::Nonce::ThreeDSecureVisaFullAuthentication,
|
1298
1411
|
:credit_card => {
|
1299
1412
|
:options => {:verify_card => true}
|
1300
|
-
}
|
1413
|
+
},
|
1301
1414
|
)
|
1302
1415
|
result.success?.should == true
|
1303
1416
|
|
@@ -1319,7 +1432,7 @@ describe Braintree::Customer do
|
|
1319
1432
|
address = Braintree::Address.create!(
|
1320
1433
|
:customer_id => customer.id,
|
1321
1434
|
:first_name => "John",
|
1322
|
-
:last_name => "Doe"
|
1435
|
+
:last_name => "Doe",
|
1323
1436
|
)
|
1324
1437
|
|
1325
1438
|
customer = Braintree::Customer.update(
|
@@ -1328,7 +1441,7 @@ describe Braintree::Customer do
|
|
1328
1441
|
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1329
1442
|
:expiration_date => "12/2009",
|
1330
1443
|
:billing_address_id => address.id
|
1331
|
-
}
|
1444
|
+
},
|
1332
1445
|
).customer
|
1333
1446
|
|
1334
1447
|
billing_address = customer.credit_cards.first.billing_address
|
@@ -1341,12 +1454,93 @@ describe Braintree::Customer do
|
|
1341
1454
|
customer = Braintree::Customer.create!(:email => "valid@email.com")
|
1342
1455
|
result = Braintree::Customer.update(
|
1343
1456
|
customer.id,
|
1344
|
-
:email => "@invalid.com"
|
1457
|
+
:email => "@invalid.com",
|
1345
1458
|
)
|
1346
1459
|
result.success?.should == false
|
1347
1460
|
result.errors.for(:customer).on(:email)[0].message.should == "Email is an invalid format."
|
1348
1461
|
end
|
1349
1462
|
|
1463
|
+
context "verification_currency_iso_code" do
|
1464
|
+
it "can update the customer after validating verification_currency_iso_code" do
|
1465
|
+
customer = Braintree::Customer.create!(
|
1466
|
+
:first_name => "Joe",
|
1467
|
+
)
|
1468
|
+
|
1469
|
+
result = Braintree::Customer.update(
|
1470
|
+
customer.id,
|
1471
|
+
:first_name => "New Joe",
|
1472
|
+
:credit_card => {
|
1473
|
+
:cardholder_name => "New Joe Cardholder",
|
1474
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1475
|
+
:expiration_date => "12/2009",
|
1476
|
+
:options => {:verify_card => true, :verification_currency_iso_code => "USD"}
|
1477
|
+
},
|
1478
|
+
)
|
1479
|
+
result.success?.should == true
|
1480
|
+
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
1481
|
+
end
|
1482
|
+
|
1483
|
+
it "can update the customer after validating verification_currency_iso_code against the given verification_merchant_account_id" do
|
1484
|
+
customer = Braintree::Customer.create!(
|
1485
|
+
:first_name => "Joe",
|
1486
|
+
)
|
1487
|
+
|
1488
|
+
result = Braintree::Customer.update(
|
1489
|
+
customer.id,
|
1490
|
+
:first_name => "New Joe",
|
1491
|
+
:credit_card => {
|
1492
|
+
:cardholder_name => "New Joe Cardholder",
|
1493
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1494
|
+
:expiration_date => "12/2009",
|
1495
|
+
:options => {:verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "USD"}
|
1496
|
+
},
|
1497
|
+
)
|
1498
|
+
result.success?.should == true
|
1499
|
+
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
1500
|
+
result.customer.credit_cards[0].verification.merchant_account_id == SpecHelper::NonDefaultMerchantAccountId
|
1501
|
+
end
|
1502
|
+
|
1503
|
+
it "throws error due to verification_currency_iso_code not matching against the currency configured in default merchant account" do
|
1504
|
+
customer = Braintree::Customer.create!(
|
1505
|
+
:first_name => "Joe",
|
1506
|
+
)
|
1507
|
+
|
1508
|
+
result = Braintree::Customer.update(
|
1509
|
+
customer.id,
|
1510
|
+
:first_name => "New Joe",
|
1511
|
+
:credit_card => {
|
1512
|
+
:cardholder_name => "New Joe Cardholder",
|
1513
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1514
|
+
:expiration_date => "12/2009",
|
1515
|
+
:options => {:verify_card => true, :verification_currency_iso_code => "GBP"}
|
1516
|
+
},
|
1517
|
+
)
|
1518
|
+
result.success?.should == false
|
1519
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
1520
|
+
|
1521
|
+
end
|
1522
|
+
|
1523
|
+
it "throws error due to verification_currency_iso_code not matching against the currency configured in the given verification merchant account" do
|
1524
|
+
customer = Braintree::Customer.create!(
|
1525
|
+
:first_name => "Joe",
|
1526
|
+
)
|
1527
|
+
|
1528
|
+
result = Braintree::Customer.update(
|
1529
|
+
customer.id,
|
1530
|
+
:first_name => "New Joe",
|
1531
|
+
:credit_card => {
|
1532
|
+
:cardholder_name => "New Joe Cardholder",
|
1533
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1534
|
+
:expiration_date => "12/2009",
|
1535
|
+
:options => {:verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "GBP"}
|
1536
|
+
},
|
1537
|
+
)
|
1538
|
+
result.success?.should == false
|
1539
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
1540
|
+
|
1541
|
+
end
|
1542
|
+
end
|
1543
|
+
|
1350
1544
|
context "verification_account_type" do
|
1351
1545
|
it "updates the credit card with account_type credit" do
|
1352
1546
|
customer = Braintree::Customer.create!
|
@@ -1362,7 +1556,7 @@ describe Braintree::Customer do
|
|
1362
1556
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
1363
1557
|
:verification_account_type => "credit",
|
1364
1558
|
},
|
1365
|
-
}
|
1559
|
+
},
|
1366
1560
|
)
|
1367
1561
|
expect(update_result).to be_success
|
1368
1562
|
end
|
@@ -1381,7 +1575,7 @@ describe Braintree::Customer do
|
|
1381
1575
|
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
|
1382
1576
|
:verification_account_type => "debit",
|
1383
1577
|
},
|
1384
|
-
}
|
1578
|
+
},
|
1385
1579
|
)
|
1386
1580
|
expect(update_result).to be_success
|
1387
1581
|
end
|
@@ -1392,12 +1586,12 @@ describe Braintree::Customer do
|
|
1392
1586
|
it "returns the updated customer if successful" do
|
1393
1587
|
customer = Braintree::Customer.create!(
|
1394
1588
|
:first_name => "Joe",
|
1395
|
-
:last_name => "Cool"
|
1589
|
+
:last_name => "Cool",
|
1396
1590
|
)
|
1397
1591
|
updated_customer = Braintree::Customer.update!(
|
1398
1592
|
customer.id,
|
1399
1593
|
:first_name => "Mr. Joe",
|
1400
|
-
:last_name => "Super Cool"
|
1594
|
+
:last_name => "Super Cool",
|
1401
1595
|
)
|
1402
1596
|
updated_customer.first_name.should == "Mr. Joe"
|
1403
1597
|
updated_customer.last_name.should == "Super Cool"
|
@@ -1421,7 +1615,7 @@ describe Braintree::Customer do
|
|
1421
1615
|
:options => {
|
1422
1616
|
:make_default => false
|
1423
1617
|
}
|
1424
|
-
}
|
1618
|
+
},
|
1425
1619
|
)
|
1426
1620
|
|
1427
1621
|
default_payment_method = Braintree::CreditCard.create!(
|
@@ -1430,7 +1624,7 @@ describe Braintree::Customer do
|
|
1430
1624
|
:expiration_date => "11/2015",
|
1431
1625
|
:options => {
|
1432
1626
|
:make_default => true
|
1433
|
-
}
|
1627
|
+
},
|
1434
1628
|
)
|
1435
1629
|
|
1436
1630
|
customer = Braintree::Customer.find(customer.id)
|
@@ -1443,7 +1637,7 @@ describe Braintree::Customer do
|
|
1443
1637
|
context "future" do
|
1444
1638
|
it "creates a customer with a future paypal account" do
|
1445
1639
|
result = Braintree::Customer.create(
|
1446
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment
|
1640
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment,
|
1447
1641
|
)
|
1448
1642
|
|
1449
1643
|
result.should be_success
|
@@ -1457,7 +1651,7 @@ describe Braintree::Customer do
|
|
1457
1651
|
:options => {
|
1458
1652
|
:make_default => true
|
1459
1653
|
}
|
1460
|
-
}
|
1654
|
+
},
|
1461
1655
|
)
|
1462
1656
|
|
1463
1657
|
paypal_account_token = "PAYPAL_ACCOUNT_TOKEN_#{rand(36**3).to_s(36)}"
|
@@ -1466,12 +1660,12 @@ describe Braintree::Customer do
|
|
1466
1660
|
:token => paypal_account_token,
|
1467
1661
|
:options => {
|
1468
1662
|
:make_default => true
|
1469
|
-
}
|
1663
|
+
},
|
1470
1664
|
)
|
1471
1665
|
|
1472
1666
|
result = Braintree::Customer.update(
|
1473
1667
|
customer.id,
|
1474
|
-
:payment_method_nonce => nonce
|
1668
|
+
:payment_method_nonce => nonce,
|
1475
1669
|
)
|
1476
1670
|
|
1477
1671
|
result.should be_success
|
@@ -1487,7 +1681,7 @@ describe Braintree::Customer do
|
|
1487
1681
|
:token => paypal_account_token,
|
1488
1682
|
:options => {
|
1489
1683
|
:make_default => true
|
1490
|
-
}
|
1684
|
+
},
|
1491
1685
|
)
|
1492
1686
|
|
1493
1687
|
result = Braintree::Customer.create(
|
@@ -1523,7 +1717,7 @@ describe Braintree::Customer do
|
|
1523
1717
|
:options => {
|
1524
1718
|
:make_default => true
|
1525
1719
|
}
|
1526
|
-
}
|
1720
|
+
},
|
1527
1721
|
)
|
1528
1722
|
|
1529
1723
|
paypal_account_token = "PAYPAL_ACCOUNT_TOKEN_#{rand(36**3).to_s(36)}"
|
@@ -1532,7 +1726,7 @@ describe Braintree::Customer do
|
|
1532
1726
|
:token => paypal_account_token,
|
1533
1727
|
:options => {
|
1534
1728
|
:make_default => true
|
1535
|
-
}
|
1729
|
+
},
|
1536
1730
|
)
|
1537
1731
|
|
1538
1732
|
result = Braintree::Customer.update(
|
@@ -1566,7 +1760,7 @@ describe Braintree::Customer do
|
|
1566
1760
|
context "onetime" do
|
1567
1761
|
it "does not create a customer with a onetime paypal account" do
|
1568
1762
|
result = Braintree::Customer.create(
|
1569
|
-
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment
|
1763
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
1570
1764
|
)
|
1571
1765
|
|
1572
1766
|
result.should_not be_success
|
@@ -1582,7 +1776,7 @@ describe Braintree::Customer do
|
|
1582
1776
|
:options => {
|
1583
1777
|
:make_default => true
|
1584
1778
|
}
|
1585
|
-
}
|
1779
|
+
},
|
1586
1780
|
)
|
1587
1781
|
|
1588
1782
|
paypal_account_token = "PAYPAL_ACCOUNT_TOKEN_#{rand(36**3).to_s(36)}"
|
@@ -1591,12 +1785,12 @@ describe Braintree::Customer do
|
|
1591
1785
|
:token => paypal_account_token,
|
1592
1786
|
:options => {
|
1593
1787
|
:make_default => true
|
1594
|
-
}
|
1788
|
+
},
|
1595
1789
|
)
|
1596
1790
|
|
1597
1791
|
result = Braintree::Customer.update(
|
1598
1792
|
customer.id,
|
1599
|
-
:payment_method_nonce => nonce
|
1793
|
+
:payment_method_nonce => nonce,
|
1600
1794
|
)
|
1601
1795
|
|
1602
1796
|
result.should_not be_success
|