braintree 4.14.0 → 4.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/braintree/credit_card.rb +13 -0
- data/lib/braintree/credit_card_gateway.rb +15 -3
- data/lib/braintree/payment_method_gateway.rb +15 -3
- data/lib/braintree/test/nonce.rb +1 -0
- data/lib/braintree/test/venmo_sdk.rb +2 -0
- data/lib/braintree/transaction/credit_card_details.rb +3 -0
- data/lib/braintree/transaction/local_payment_details.rb +2 -0
- data/lib/braintree/transaction.rb +5 -4
- data/lib/braintree/transaction_gateway.rb +15 -3
- data/lib/braintree/transaction_search.rb +6 -5
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/webhook_notification.rb +1 -0
- data/lib/braintree/webhook_testing_gateway.rb +17 -0
- data/spec/integration/braintree/add_on_spec.rb +9 -9
- data/spec/integration/braintree/address_spec.rb +69 -69
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +8 -8
- data/spec/integration/braintree/client_api/client_token_spec.rb +15 -15
- data/spec/integration/braintree/credit_card_spec.rb +223 -223
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +16 -16
- data/spec/integration/braintree/credit_card_verification_spec.rb +52 -52
- data/spec/integration/braintree/customer_search_spec.rb +20 -20
- data/spec/integration/braintree/customer_spec.rb +313 -313
- data/spec/integration/braintree/disbursement_spec.rb +2 -2
- data/spec/integration/braintree/discount_spec.rb +9 -9
- data/spec/integration/braintree/dispute_spec.rb +87 -87
- data/spec/integration/braintree/document_upload_spec.rb +17 -17
- data/spec/integration/braintree/error_codes_spec.rb +2 -2
- data/spec/integration/braintree/http_spec.rb +28 -28
- data/spec/integration/braintree/merchant_account_spec.rb +127 -127
- data/spec/integration/braintree/merchant_spec.rb +103 -103
- data/spec/integration/braintree/oauth_spec.rb +61 -61
- data/spec/integration/braintree/payment_method_nonce_spec.rb +73 -73
- data/spec/integration/braintree/payment_method_spec.rb +389 -389
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +78 -78
- data/spec/integration/braintree/paypal_account_spec.rb +38 -38
- data/spec/integration/braintree/plan_spec.rb +15 -15
- data/spec/integration/braintree/samsung_pay_card_spec.rb +65 -65
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +51 -51
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +11 -11
- data/spec/integration/braintree/subscription_spec.rb +364 -364
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +19 -19
- data/spec/integration/braintree/transaction_line_item_spec.rb +6 -6
- data/spec/integration/braintree/transaction_search_spec.rb +198 -165
- data/spec/integration/braintree/transaction_spec.rb +1315 -1149
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +32 -32
- data/spec/integration/braintree/us_bank_account_spec.rb +30 -30
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +18 -18
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +33 -33
- data/spec/integration/braintree/visa_checkout_card_spec.rb +57 -57
- data/spec/spec_helper.rb +9 -8
- data/spec/unit/braintree/address_spec.rb +8 -8
- data/spec/unit/braintree/base_module_spec.rb +4 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +57 -57
- data/spec/unit/braintree/credentials_parser_spec.rb +6 -6
- data/spec/unit/braintree/credit_card_spec.rb +31 -29
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +28 -28
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +9 -9
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -17
- data/spec/unit/braintree/customer_spec.rb +41 -40
- data/spec/unit/braintree/digest_spec.rb +5 -5
- data/spec/unit/braintree/disbursement_spec.rb +11 -11
- data/spec/unit/braintree/dispute_search_spec.rb +2 -2
- data/spec/unit/braintree/dispute_spec.rb +56 -56
- data/spec/unit/braintree/document_upload_spec.rb +8 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +2 -2
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +9 -9
- data/spec/unit/braintree/http_spec.rb +8 -8
- data/spec/unit/braintree/local_payment_completed_spec.rb +11 -11
- data/spec/unit/braintree/local_payment_expired_spec.rb +2 -2
- data/spec/unit/braintree/local_payment_funded_spec.rb +6 -6
- data/spec/unit/braintree/merchant_account_spec.rb +4 -4
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +6 -6
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +7 -7
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +14 -14
- data/spec/unit/braintree/payment_method_spec.rb +19 -19
- data/spec/unit/braintree/paypal_account_spec.rb +4 -4
- data/spec/unit/braintree/resource_collection_spec.rb +7 -7
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +1 -1
- data/spec/unit/braintree/sha256_digest_spec.rb +1 -1
- data/spec/unit/braintree/signature_service_spec.rb +2 -2
- data/spec/unit/braintree/subscription_search_spec.rb +17 -17
- data/spec/unit/braintree/subscription_spec.rb +8 -8
- data/spec/unit/braintree/successful_result_spec.rb +5 -5
- data/spec/unit/braintree/three_d_secure_info_spec.rb +20 -20
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -5
- 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/local_payment_details_spec.rb +30 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +9 -6
- data/spec/unit/braintree/transaction_search_spec.rb +2 -2
- data/spec/unit/braintree/transaction_spec.rb +101 -93
- data/spec/unit/braintree/unknown_payment_method_spec.rb +4 -4
- data/spec/unit/braintree/us_bank_account_spec.rb +2 -2
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +7 -7
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +7 -7
- data/spec/unit/braintree/util_spec.rb +27 -27
- data/spec/unit/braintree/validation_error_collection_spec.rb +34 -34
- data/spec/unit/braintree/validation_error_spec.rb +4 -4
- data/spec/unit/braintree/venmo_profile_data_spec.rb +5 -5
- data/spec/unit/braintree/webhook_notification_spec.rb +206 -191
- data/spec/unit/braintree/xml/libxml_spec.rb +5 -5
- data/spec/unit/braintree/xml/parser_spec.rb +8 -8
- data/spec/unit/braintree/xml/rexml_spec.rb +5 -5
- data/spec/unit/braintree/xml_spec.rb +17 -17
- data/spec/unit/braintree_spec.rb +2 -2
- metadata +3 -2
@@ -6,10 +6,10 @@ describe Braintree::Customer do
|
|
6
6
|
describe "self.all" do
|
7
7
|
it "gets more than a page of customers" do
|
8
8
|
customers = Braintree::Customer.all
|
9
|
-
customers.maximum_size.
|
9
|
+
expect(customers.maximum_size).to be > 100
|
10
10
|
|
11
11
|
customer_ids = customers.map { |c| c.id }.uniq.compact
|
12
|
-
customer_ids.size.
|
12
|
+
expect(customer_ids.size).to eq(customers.maximum_size)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -19,11 +19,11 @@ describe Braintree::Customer do
|
|
19
19
|
:first_name => "Joe",
|
20
20
|
:last_name => "Cool",
|
21
21
|
)
|
22
|
-
create_result.success
|
22
|
+
expect(create_result.success?).to eq(true)
|
23
23
|
customer = create_result.customer
|
24
24
|
|
25
25
|
delete_result = Braintree::Customer.delete(customer.id)
|
26
|
-
delete_result.success
|
26
|
+
expect(delete_result.success?).to eq(true)
|
27
27
|
expect do
|
28
28
|
Braintree::Customer.find(customer.id)
|
29
29
|
end.to raise_error(Braintree::NotFoundError)
|
@@ -42,17 +42,17 @@ describe Braintree::Customer do
|
|
42
42
|
:website => "www.microsoft.com",
|
43
43
|
:tax_identifiers => [{:country_code => "US", :identifier => "987654321"}],
|
44
44
|
)
|
45
|
-
result.success
|
46
|
-
result.customer.id.
|
47
|
-
result.customer.first_name.
|
48
|
-
result.customer.last_name.
|
49
|
-
result.customer.company.
|
50
|
-
result.customer.email.
|
51
|
-
result.customer.phone.
|
52
|
-
result.customer.fax.
|
53
|
-
result.customer.website.
|
54
|
-
result.customer.created_at.between?(Time.now - 10, Time.now).
|
55
|
-
result.customer.updated_at.between?(Time.now - 10, Time.now).
|
45
|
+
expect(result.success?).to eq(true)
|
46
|
+
expect(result.customer.id).to match(/^\d{6,}$/)
|
47
|
+
expect(result.customer.first_name).to eq("Bill")
|
48
|
+
expect(result.customer.last_name).to eq("Gates")
|
49
|
+
expect(result.customer.company).to eq("Microsoft")
|
50
|
+
expect(result.customer.email).to eq("bill@microsoft.com")
|
51
|
+
expect(result.customer.phone).to eq("312.555.1234")
|
52
|
+
expect(result.customer.fax).to eq("614.555.5678")
|
53
|
+
expect(result.customer.website).to eq("www.microsoft.com")
|
54
|
+
expect(result.customer.created_at.between?(Time.now - 10, Time.now)).to eq(true)
|
55
|
+
expect(result.customer.updated_at.between?(Time.now - 10, Time.now)).to eq(true)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "returns a successful result if successful using an access token" do
|
@@ -80,10 +80,10 @@ describe Braintree::Customer do
|
|
80
80
|
:fax => "614.555.5678",
|
81
81
|
:website => "www.example.com",
|
82
82
|
)
|
83
|
-
result.success
|
84
|
-
result.customer.id.
|
85
|
-
result.customer.first_name.
|
86
|
-
result.customer.last_name.
|
83
|
+
expect(result.success?).to eq(true)
|
84
|
+
expect(result.customer.id).to match(/^\d{6,}$/)
|
85
|
+
expect(result.customer.first_name).to eq("Joe")
|
86
|
+
expect(result.customer.last_name).to eq("Brown")
|
87
87
|
end
|
88
88
|
|
89
89
|
it "supports creation with device_data" do
|
@@ -96,7 +96,7 @@ describe Braintree::Customer do
|
|
96
96
|
},
|
97
97
|
)
|
98
98
|
|
99
|
-
result.
|
99
|
+
expect(result).to be_success
|
100
100
|
end
|
101
101
|
|
102
102
|
it "supports creation including risk data with customer_browser and customer_ip" do
|
@@ -112,7 +112,7 @@ describe Braintree::Customer do
|
|
112
112
|
},
|
113
113
|
)
|
114
114
|
|
115
|
-
result.
|
115
|
+
expect(result).to be_success
|
116
116
|
end
|
117
117
|
|
118
118
|
it "includes risk data when skip_advanced_fraud_checking is false" do
|
@@ -163,38 +163,38 @@ describe Braintree::Customer do
|
|
163
163
|
],
|
164
164
|
)
|
165
165
|
|
166
|
-
result.
|
166
|
+
expect(result).to be_success
|
167
167
|
end
|
168
168
|
|
169
169
|
it "can create without any attributes" do
|
170
170
|
result = Braintree::Customer.create
|
171
|
-
result.success
|
171
|
+
expect(result.success?).to eq(true)
|
172
172
|
end
|
173
173
|
|
174
174
|
it "supports utf-8" do
|
175
175
|
first_name = "Jos\303\251"
|
176
176
|
last_name = "Mu\303\261oz"
|
177
177
|
result = Braintree::Customer.create(:first_name => first_name, :last_name => last_name)
|
178
|
-
result.success
|
178
|
+
expect(result.success?).to eq(true)
|
179
179
|
|
180
180
|
if RUBY_VERSION =~ /^1.8/
|
181
|
-
result.customer.first_name.
|
182
|
-
result.customer.last_name.
|
181
|
+
expect(result.customer.first_name).to eq(first_name)
|
182
|
+
expect(result.customer.last_name).to eq(last_name)
|
183
183
|
|
184
184
|
found_customer = Braintree::Customer.find(result.customer.id)
|
185
|
-
found_customer.first_name.
|
186
|
-
found_customer.last_name.
|
185
|
+
expect(found_customer.first_name).to eq(first_name)
|
186
|
+
expect(found_customer.last_name).to eq(last_name)
|
187
187
|
else
|
188
|
-
result.customer.first_name.
|
189
|
-
result.customer.first_name.bytes.map { |b| b.to_s(8) }.
|
190
|
-
result.customer.last_name.
|
191
|
-
result.customer.last_name.bytes.map { |b| b.to_s(8) }.
|
188
|
+
expect(result.customer.first_name).to eq("José")
|
189
|
+
expect(result.customer.first_name.bytes.map { |b| b.to_s(8) }).to eq(["112", "157", "163", "303", "251"])
|
190
|
+
expect(result.customer.last_name).to eq("Muñoz")
|
191
|
+
expect(result.customer.last_name.bytes.map { |b| b.to_s(8) }).to eq(["115", "165", "303", "261", "157", "172"])
|
192
192
|
|
193
193
|
found_customer = Braintree::Customer.find(result.customer.id)
|
194
|
-
found_customer.first_name.
|
195
|
-
found_customer.first_name.bytes.map { |b| b.to_s(8) }.
|
196
|
-
found_customer.last_name.
|
197
|
-
found_customer.last_name.bytes.map { |b| b.to_s(8) }.
|
194
|
+
expect(found_customer.first_name).to eq("José")
|
195
|
+
expect(found_customer.first_name.bytes.map { |b| b.to_s(8) }).to eq(["112", "157", "163", "303", "251"])
|
196
|
+
expect(found_customer.last_name).to eq("Muñoz")
|
197
|
+
expect(found_customer.last_name.bytes.map { |b| b.to_s(8) }).to eq(["115", "165", "303", "261", "157", "172"])
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
@@ -202,8 +202,8 @@ describe Braintree::Customer do
|
|
202
202
|
result = Braintree::Customer.create(
|
203
203
|
:email => "@invalid.com",
|
204
204
|
)
|
205
|
-
result.success
|
206
|
-
result.errors.for(:customer).on(:email)[0].message.
|
205
|
+
expect(result.success?).to eq(false)
|
206
|
+
expect(result.errors.for(:customer).on(:email)[0].message).to eq("Email is an invalid format.")
|
207
207
|
end
|
208
208
|
|
209
209
|
it "can create a customer and a payment method at the same time" do
|
@@ -217,13 +217,13 @@ describe Braintree::Customer do
|
|
217
217
|
},
|
218
218
|
)
|
219
219
|
|
220
|
-
result.success
|
221
|
-
result.customer.first_name.
|
222
|
-
result.customer.last_name.
|
223
|
-
result.customer.credit_cards[0].bin.
|
224
|
-
result.customer.credit_cards[0].last_4.
|
225
|
-
result.customer.credit_cards[0].expiration_date.
|
226
|
-
result.customer.credit_cards[0].unique_number_identifier.
|
220
|
+
expect(result.success?).to eq(true)
|
221
|
+
expect(result.customer.first_name).to eq("Mike")
|
222
|
+
expect(result.customer.last_name).to eq("Jones")
|
223
|
+
expect(result.customer.credit_cards[0].bin).to eq(Braintree::Test::CreditCardNumbers::MasterCard[0, 6])
|
224
|
+
expect(result.customer.credit_cards[0].last_4).to eq(Braintree::Test::CreditCardNumbers::MasterCard[-4..-1])
|
225
|
+
expect(result.customer.credit_cards[0].expiration_date).to eq("05/2010")
|
226
|
+
expect(result.customer.credit_cards[0].unique_number_identifier).to match(/\A\w{32}\z/)
|
227
227
|
end
|
228
228
|
|
229
229
|
it "can create a customer and a paypal account at the same time" do
|
@@ -237,11 +237,11 @@ describe Braintree::Customer do
|
|
237
237
|
},
|
238
238
|
)
|
239
239
|
|
240
|
-
result.success
|
241
|
-
result.customer.first_name.
|
242
|
-
result.customer.last_name.
|
243
|
-
result.customer.paypal_accounts[0].billing_agreement_id.
|
244
|
-
result.customer.paypal_accounts[0].email.
|
240
|
+
expect(result.success?).to eq(true)
|
241
|
+
expect(result.customer.first_name).to eq("Mike")
|
242
|
+
expect(result.customer.last_name).to eq("Jones")
|
243
|
+
expect(result.customer.paypal_accounts[0].billing_agreement_id).to eq("B-123456")
|
244
|
+
expect(result.customer.paypal_accounts[0].email).to eq("other@example.com")
|
245
245
|
end
|
246
246
|
|
247
247
|
it "verifies the card if credit_card[options][verify_card]=true" do
|
@@ -254,8 +254,8 @@ describe Braintree::Customer do
|
|
254
254
|
:options => {:verify_card => true}
|
255
255
|
},
|
256
256
|
)
|
257
|
-
result.success
|
258
|
-
result.credit_card_verification.status.
|
257
|
+
expect(result.success?).to eq(false)
|
258
|
+
expect(result.credit_card_verification.status).to eq(Braintree::Transaction::Status::ProcessorDeclined)
|
259
259
|
end
|
260
260
|
|
261
261
|
it "allows a verification_amount" do
|
@@ -268,7 +268,7 @@ describe Braintree::Customer do
|
|
268
268
|
:options => {:verify_card => true, :verification_amount => "2.00"}
|
269
269
|
},
|
270
270
|
)
|
271
|
-
result.success
|
271
|
+
expect(result.success?).to eq(true)
|
272
272
|
end
|
273
273
|
|
274
274
|
it "fails on create if credit_card[options][fail_on_duplicate_payment_method]=true and there is a duplicated payment method" do
|
@@ -288,8 +288,8 @@ describe Braintree::Customer do
|
|
288
288
|
:options => {:fail_on_duplicate_payment_method => true}
|
289
289
|
},
|
290
290
|
)
|
291
|
-
result.success
|
292
|
-
result.errors.for(:customer).for(:credit_card).on(:number)[0].message.
|
291
|
+
expect(result.success?).to eq(false)
|
292
|
+
expect(result.errors.for(:customer).for(:credit_card).on(:number)[0].message).to eq("Duplicate card exists in the vault.")
|
293
293
|
end
|
294
294
|
|
295
295
|
it "allows the user to specify the merchant account for verification" do
|
@@ -305,8 +305,8 @@ describe Braintree::Customer do
|
|
305
305
|
}
|
306
306
|
},
|
307
307
|
)
|
308
|
-
result.success
|
309
|
-
result.credit_card_verification.status.
|
308
|
+
expect(result.success?).to eq(false)
|
309
|
+
expect(result.credit_card_verification.status).to eq(Braintree::Transaction::Status::ProcessorDeclined)
|
310
310
|
end
|
311
311
|
|
312
312
|
it "can create a customer and a payment method at the same time after validating verification_currency_iso_code" do
|
@@ -324,13 +324,13 @@ describe Braintree::Customer do
|
|
324
324
|
},
|
325
325
|
)
|
326
326
|
|
327
|
-
result.success
|
328
|
-
result.customer.first_name.
|
329
|
-
result.customer.last_name.
|
330
|
-
result.customer.credit_cards[0].bin.
|
331
|
-
result.customer.credit_cards[0].last_4.
|
332
|
-
result.customer.credit_cards[0].expiration_date.
|
333
|
-
result.customer.credit_cards[0].unique_number_identifier.
|
327
|
+
expect(result.success?).to eq(true)
|
328
|
+
expect(result.customer.first_name).to eq("Mike")
|
329
|
+
expect(result.customer.last_name).to eq("Jones")
|
330
|
+
expect(result.customer.credit_cards[0].bin).to eq(Braintree::Test::CreditCardNumbers::MasterCard[0, 6])
|
331
|
+
expect(result.customer.credit_cards[0].last_4).to eq(Braintree::Test::CreditCardNumbers::MasterCard[-4..-1])
|
332
|
+
expect(result.customer.credit_cards[0].expiration_date).to eq("05/2010")
|
333
|
+
expect(result.customer.credit_cards[0].unique_number_identifier).to match(/\A\w{32}\z/)
|
334
334
|
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
335
335
|
end
|
336
336
|
|
@@ -366,14 +366,14 @@ describe Braintree::Customer do
|
|
366
366
|
}
|
367
367
|
},
|
368
368
|
)
|
369
|
-
result.success
|
369
|
+
expect(result.success?).to eq(true)
|
370
370
|
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
371
|
-
result.customer.first_name.
|
372
|
-
result.customer.last_name.
|
373
|
-
result.customer.credit_cards[0].bin.
|
374
|
-
result.customer.credit_cards[0].last_4.
|
375
|
-
result.customer.credit_cards[0].expiration_date.
|
376
|
-
result.customer.credit_cards[0].unique_number_identifier.
|
371
|
+
expect(result.customer.first_name).to eq("Mike")
|
372
|
+
expect(result.customer.last_name).to eq("Jones")
|
373
|
+
expect(result.customer.credit_cards[0].bin).to eq(Braintree::Test::CreditCardNumbers::MasterCard[0, 6])
|
374
|
+
expect(result.customer.credit_cards[0].last_4).to eq(Braintree::Test::CreditCardNumbers::MasterCard[-4..-1])
|
375
|
+
expect(result.customer.credit_cards[0].expiration_date).to eq("05/2010")
|
376
|
+
expect(result.customer.credit_cards[0].unique_number_identifier).to match(/\A\w{32}\z/)
|
377
377
|
end
|
378
378
|
|
379
379
|
it "validates verification_currency_iso_code of the given verification_merchant_account_id and returns error" do
|
@@ -412,20 +412,20 @@ describe Braintree::Customer do
|
|
412
412
|
}
|
413
413
|
},
|
414
414
|
)
|
415
|
-
result.success
|
416
|
-
result.customer.first_name.
|
417
|
-
result.customer.last_name.
|
418
|
-
result.customer.credit_cards[0].bin.
|
419
|
-
result.customer.credit_cards[0].last_4.
|
420
|
-
result.customer.credit_cards[0].expiration_date.
|
421
|
-
result.customer.credit_cards[0].billing_address.id.
|
422
|
-
result.customer.addresses[0].id.
|
423
|
-
result.customer.addresses[0].street_address.
|
424
|
-
result.customer.addresses[0].extended_address.
|
425
|
-
result.customer.addresses[0].locality.
|
426
|
-
result.customer.addresses[0].region.
|
427
|
-
result.customer.addresses[0].postal_code.
|
428
|
-
result.customer.addresses[0].country_name.
|
415
|
+
expect(result.success?).to eq(true)
|
416
|
+
expect(result.customer.first_name).to eq("Mike")
|
417
|
+
expect(result.customer.last_name).to eq("Jones")
|
418
|
+
expect(result.customer.credit_cards[0].bin).to eq(Braintree::Test::CreditCardNumbers::MasterCard[0, 6])
|
419
|
+
expect(result.customer.credit_cards[0].last_4).to eq(Braintree::Test::CreditCardNumbers::MasterCard[-4..-1])
|
420
|
+
expect(result.customer.credit_cards[0].expiration_date).to eq("05/2010")
|
421
|
+
expect(result.customer.credit_cards[0].billing_address.id).to eq(result.customer.addresses[0].id)
|
422
|
+
expect(result.customer.addresses[0].id).to match(/\w+/)
|
423
|
+
expect(result.customer.addresses[0].street_address).to eq("1 E Main St")
|
424
|
+
expect(result.customer.addresses[0].extended_address).to eq("Suite 3")
|
425
|
+
expect(result.customer.addresses[0].locality).to eq("Chicago")
|
426
|
+
expect(result.customer.addresses[0].region).to eq("Illinois")
|
427
|
+
expect(result.customer.addresses[0].postal_code).to eq("60622")
|
428
|
+
expect(result.customer.addresses[0].country_name).to eq("United States of America")
|
429
429
|
end
|
430
430
|
|
431
431
|
it "can use any country code" do
|
@@ -443,11 +443,11 @@ describe Braintree::Customer do
|
|
443
443
|
}
|
444
444
|
},
|
445
445
|
)
|
446
|
-
result.success
|
447
|
-
result.customer.addresses[0].country_name.
|
448
|
-
result.customer.addresses[0].country_code_alpha2.
|
449
|
-
result.customer.addresses[0].country_code_alpha3.
|
450
|
-
result.customer.addresses[0].country_code_numeric.
|
446
|
+
expect(result.success?).to eq(true)
|
447
|
+
expect(result.customer.addresses[0].country_name).to eq("Comoros")
|
448
|
+
expect(result.customer.addresses[0].country_code_alpha2).to eq("KM")
|
449
|
+
expect(result.customer.addresses[0].country_code_alpha3).to eq("COM")
|
450
|
+
expect(result.customer.addresses[0].country_code_numeric).to eq("174")
|
451
451
|
end
|
452
452
|
|
453
453
|
it "stores custom fields when valid" do
|
@@ -458,8 +458,8 @@ describe Braintree::Customer do
|
|
458
458
|
:store_me => "custom value"
|
459
459
|
},
|
460
460
|
)
|
461
|
-
result.success
|
462
|
-
result.customer.custom_fields[:store_me].
|
461
|
+
expect(result.success?).to eq(true)
|
462
|
+
expect(result.customer.custom_fields[:store_me]).to eq("custom value")
|
463
463
|
end
|
464
464
|
|
465
465
|
it "returns empty hash for custom fields when blank" do
|
@@ -468,8 +468,8 @@ describe Braintree::Customer do
|
|
468
468
|
:last_name => "Gates",
|
469
469
|
:custom_fields => {:store_me => ""},
|
470
470
|
)
|
471
|
-
result.success
|
472
|
-
result.customer.custom_fields.
|
471
|
+
expect(result.success?).to eq(true)
|
472
|
+
expect(result.customer.custom_fields).to eq({})
|
473
473
|
end
|
474
474
|
|
475
475
|
it "returns nested errors if credit card and/or billing address are invalid" do
|
@@ -482,10 +482,10 @@ describe Braintree::Customer do
|
|
482
482
|
}
|
483
483
|
},
|
484
484
|
)
|
485
|
-
result.success
|
486
|
-
result.errors.for(:customer).on(:email)[0].message.
|
487
|
-
result.errors.for(:customer).for(:credit_card).on(:number)[0].message.
|
488
|
-
result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_name)[0].message.
|
485
|
+
expect(result.success?).to eq(false)
|
486
|
+
expect(result.errors.for(:customer).on(:email)[0].message).to eq("Email is an invalid format.")
|
487
|
+
expect(result.errors.for(:customer).for(:credit_card).on(:number)[0].message).to eq("Credit card number is invalid.")
|
488
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_name)[0].message).to eq("Country name is not an accepted country.")
|
489
489
|
end
|
490
490
|
|
491
491
|
it "returns errors if country codes are inconsistent" do
|
@@ -502,8 +502,8 @@ describe Braintree::Customer do
|
|
502
502
|
}
|
503
503
|
},
|
504
504
|
)
|
505
|
-
result.success
|
506
|
-
result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:base).map { |e| e.code }.
|
505
|
+
expect(result.success?).to eq(false)
|
506
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:base).map { |e| e.code }).to include(Braintree::ErrorCodes::Address::InconsistentCountry)
|
507
507
|
end
|
508
508
|
|
509
509
|
it "returns an error if country code alpha2 is invalid" do
|
@@ -518,8 +518,8 @@ describe Braintree::Customer do
|
|
518
518
|
}
|
519
519
|
},
|
520
520
|
)
|
521
|
-
result.success
|
522
|
-
result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_alpha2).map { |e| e.code }.
|
521
|
+
expect(result.success?).to eq(false)
|
522
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_alpha2).map { |e| e.code }).to include(Braintree::ErrorCodes::Address::CountryCodeAlpha2IsNotAccepted)
|
523
523
|
end
|
524
524
|
|
525
525
|
it "returns an error if country code alpha3 is invalid" do
|
@@ -534,8 +534,8 @@ describe Braintree::Customer do
|
|
534
534
|
}
|
535
535
|
},
|
536
536
|
)
|
537
|
-
result.success
|
538
|
-
result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_alpha3).map { |e| e.code }.
|
537
|
+
expect(result.success?).to eq(false)
|
538
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_alpha3).map { |e| e.code }).to include(Braintree::ErrorCodes::Address::CountryCodeAlpha3IsNotAccepted)
|
539
539
|
end
|
540
540
|
|
541
541
|
it "returns an error if country code numeric is invalid" do
|
@@ -550,8 +550,8 @@ describe Braintree::Customer do
|
|
550
550
|
}
|
551
551
|
},
|
552
552
|
)
|
553
|
-
result.success
|
554
|
-
result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_numeric).map { |e| e.code }.
|
553
|
+
expect(result.success?).to eq(false)
|
554
|
+
expect(result.errors.for(:customer).for(:credit_card).for(:billing_address).on(:country_code_numeric).map { |e| e.code }).to include(Braintree::ErrorCodes::Address::CountryCodeNumericIsNotAccepted)
|
555
555
|
end
|
556
556
|
|
557
557
|
it "returns errors if custom_fields are not registered" do
|
@@ -562,8 +562,8 @@ describe Braintree::Customer do
|
|
562
562
|
:spouse_name => "Jacqueline"
|
563
563
|
},
|
564
564
|
)
|
565
|
-
result.success
|
566
|
-
result.errors.for(:customer).on(:custom_fields)[0].message.
|
565
|
+
expect(result.success?).to eq(false)
|
566
|
+
expect(result.errors.for(:customer).on(:custom_fields)[0].message).to eq("Custom field is invalid: spouse_name.")
|
567
567
|
end
|
568
568
|
|
569
569
|
context "client API" do
|
@@ -583,24 +583,24 @@ describe Braintree::Customer do
|
|
583
583
|
},
|
584
584
|
)
|
585
585
|
|
586
|
-
result.success
|
587
|
-
result.customer.credit_cards.first.bin.
|
588
|
-
result.customer.credit_cards.first.last_4.
|
586
|
+
expect(result.success?).to eq(true)
|
587
|
+
expect(result.customer.credit_cards.first.bin).to eq("411111")
|
588
|
+
expect(result.customer.credit_cards.first.last_4).to eq("1111")
|
589
589
|
end
|
590
590
|
end
|
591
591
|
|
592
592
|
it "can create a customer with an apple pay payment method" do
|
593
593
|
result = Braintree::Customer.create(:payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa)
|
594
594
|
|
595
|
-
result.success
|
596
|
-
result.customer.payment_methods.
|
597
|
-
result.customer.payment_methods.first.token.
|
595
|
+
expect(result.success?).to eq(true)
|
596
|
+
expect(result.customer.payment_methods).not_to be_empty
|
597
|
+
expect(result.customer.payment_methods.first.token).not_to be_nil
|
598
598
|
end
|
599
599
|
|
600
600
|
it "can create a customer with an unknown payment method" do
|
601
601
|
result = Braintree::Customer.create(:payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable)
|
602
602
|
|
603
|
-
result.success
|
603
|
+
expect(result.success?).to eq(true)
|
604
604
|
end
|
605
605
|
|
606
606
|
context "verification_account_type" do
|
@@ -701,14 +701,14 @@ describe Braintree::Customer do
|
|
701
701
|
:first_name => "Jim",
|
702
702
|
:last_name => "Smith",
|
703
703
|
)
|
704
|
-
customer.id.
|
705
|
-
customer.first_name.
|
706
|
-
customer.last_name.
|
704
|
+
expect(customer.id).to match(/\d+/)
|
705
|
+
expect(customer.first_name).to eq("Jim")
|
706
|
+
expect(customer.last_name).to eq("Smith")
|
707
707
|
end
|
708
708
|
|
709
709
|
it "can create without any attributes" do
|
710
710
|
customer = Braintree::Customer.create!
|
711
|
-
customer.id.
|
711
|
+
expect(customer.id).to match(/\d+/)
|
712
712
|
end
|
713
713
|
|
714
714
|
it "raises an exception if not successful" do
|
@@ -727,14 +727,14 @@ describe Braintree::Customer do
|
|
727
727
|
},
|
728
728
|
)
|
729
729
|
result = Braintree::Customer.credit(customer.id, :amount => "100.00")
|
730
|
-
result.success
|
731
|
-
result.transaction.amount.
|
732
|
-
result.transaction.type.
|
733
|
-
result.transaction.customer_details.id.
|
734
|
-
result.transaction.credit_card_details.token.
|
735
|
-
result.transaction.credit_card_details.bin.
|
736
|
-
result.transaction.credit_card_details.last_4.
|
737
|
-
result.transaction.credit_card_details.expiration_date.
|
730
|
+
expect(result.success?).to eq(true)
|
731
|
+
expect(result.transaction.amount).to eq(BigDecimal("100.00"))
|
732
|
+
expect(result.transaction.type).to eq("credit")
|
733
|
+
expect(result.transaction.customer_details.id).to eq(customer.id)
|
734
|
+
expect(result.transaction.credit_card_details.token).to eq(customer.credit_cards[0].token)
|
735
|
+
expect(result.transaction.credit_card_details.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
736
|
+
expect(result.transaction.credit_card_details.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
737
|
+
expect(result.transaction.credit_card_details.expiration_date).to eq("05/2010")
|
738
738
|
end
|
739
739
|
end
|
740
740
|
|
@@ -747,13 +747,13 @@ describe Braintree::Customer do
|
|
747
747
|
},
|
748
748
|
)
|
749
749
|
transaction = Braintree::Customer.credit!(customer.id, :amount => "100.00")
|
750
|
-
transaction.amount.
|
751
|
-
transaction.type.
|
752
|
-
transaction.customer_details.id.
|
753
|
-
transaction.credit_card_details.token.
|
754
|
-
transaction.credit_card_details.bin.
|
755
|
-
transaction.credit_card_details.last_4.
|
756
|
-
transaction.credit_card_details.expiration_date.
|
750
|
+
expect(transaction.amount).to eq(BigDecimal("100.00"))
|
751
|
+
expect(transaction.type).to eq("credit")
|
752
|
+
expect(transaction.customer_details.id).to eq(customer.id)
|
753
|
+
expect(transaction.credit_card_details.token).to eq(customer.credit_cards[0].token)
|
754
|
+
expect(transaction.credit_card_details.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
755
|
+
expect(transaction.credit_card_details.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
756
|
+
expect(transaction.credit_card_details.expiration_date).to eq("05/2010")
|
757
757
|
end
|
758
758
|
end
|
759
759
|
|
@@ -766,14 +766,14 @@ describe Braintree::Customer do
|
|
766
766
|
},
|
767
767
|
)
|
768
768
|
result = Braintree::Customer.sale(customer.id, :amount => "100.00")
|
769
|
-
result.success
|
770
|
-
result.transaction.amount.
|
771
|
-
result.transaction.type.
|
772
|
-
result.transaction.customer_details.id.
|
773
|
-
result.transaction.credit_card_details.token.
|
774
|
-
result.transaction.credit_card_details.bin.
|
775
|
-
result.transaction.credit_card_details.last_4.
|
776
|
-
result.transaction.credit_card_details.expiration_date.
|
769
|
+
expect(result.success?).to eq(true)
|
770
|
+
expect(result.transaction.amount).to eq(BigDecimal("100.00"))
|
771
|
+
expect(result.transaction.type).to eq("sale")
|
772
|
+
expect(result.transaction.customer_details.id).to eq(customer.id)
|
773
|
+
expect(result.transaction.credit_card_details.token).to eq(customer.credit_cards[0].token)
|
774
|
+
expect(result.transaction.credit_card_details.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
775
|
+
expect(result.transaction.credit_card_details.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
776
|
+
expect(result.transaction.credit_card_details.expiration_date).to eq("05/2010")
|
777
777
|
end
|
778
778
|
end
|
779
779
|
|
@@ -786,13 +786,13 @@ describe Braintree::Customer do
|
|
786
786
|
},
|
787
787
|
)
|
788
788
|
transaction = Braintree::Customer.sale!(customer.id, :amount => "100.00")
|
789
|
-
transaction.amount.
|
790
|
-
transaction.type.
|
791
|
-
transaction.customer_details.id.
|
792
|
-
transaction.credit_card_details.token.
|
793
|
-
transaction.credit_card_details.bin.
|
794
|
-
transaction.credit_card_details.last_4.
|
795
|
-
transaction.credit_card_details.expiration_date.
|
789
|
+
expect(transaction.amount).to eq(BigDecimal("100.00"))
|
790
|
+
expect(transaction.type).to eq("sale")
|
791
|
+
expect(transaction.customer_details.id).to eq(customer.id)
|
792
|
+
expect(transaction.credit_card_details.token).to eq(customer.credit_cards[0].token)
|
793
|
+
expect(transaction.credit_card_details.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
794
|
+
expect(transaction.credit_card_details.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
795
|
+
expect(transaction.credit_card_details.expiration_date).to eq("05/2010")
|
796
796
|
end
|
797
797
|
end
|
798
798
|
|
@@ -806,7 +806,7 @@ describe Braintree::Customer do
|
|
806
806
|
)
|
807
807
|
transaction = Braintree::Customer.sale!(customer.id, :amount => "100.00")
|
808
808
|
collection = Braintree::Customer.transactions(customer.id)
|
809
|
-
collection.first.
|
809
|
+
expect(collection.first).to eq(transaction)
|
810
810
|
end
|
811
811
|
end
|
812
812
|
|
@@ -821,14 +821,14 @@ describe Braintree::Customer do
|
|
821
821
|
result = customer.credit(
|
822
822
|
:amount => "100.00",
|
823
823
|
)
|
824
|
-
result.success
|
825
|
-
result.transaction.amount.
|
826
|
-
result.transaction.type.
|
827
|
-
result.transaction.customer_details.id.
|
828
|
-
result.transaction.credit_card_details.token.
|
829
|
-
result.transaction.credit_card_details.bin.
|
830
|
-
result.transaction.credit_card_details.last_4.
|
831
|
-
result.transaction.credit_card_details.expiration_date.
|
824
|
+
expect(result.success?).to eq(true)
|
825
|
+
expect(result.transaction.amount).to eq(BigDecimal("100.00"))
|
826
|
+
expect(result.transaction.type).to eq("credit")
|
827
|
+
expect(result.transaction.customer_details.id).to eq(customer.id)
|
828
|
+
expect(result.transaction.credit_card_details.token).to eq(customer.credit_cards[0].token)
|
829
|
+
expect(result.transaction.credit_card_details.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
830
|
+
expect(result.transaction.credit_card_details.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
831
|
+
expect(result.transaction.credit_card_details.expiration_date).to eq("05/2010")
|
832
832
|
end
|
833
833
|
end
|
834
834
|
|
@@ -841,13 +841,13 @@ describe Braintree::Customer do
|
|
841
841
|
},
|
842
842
|
)
|
843
843
|
transaction = customer.credit!(:amount => "100.00")
|
844
|
-
transaction.amount.
|
845
|
-
transaction.type.
|
846
|
-
transaction.customer_details.id.
|
847
|
-
transaction.credit_card_details.token.
|
848
|
-
transaction.credit_card_details.bin.
|
849
|
-
transaction.credit_card_details.last_4.
|
850
|
-
transaction.credit_card_details.expiration_date.
|
844
|
+
expect(transaction.amount).to eq(BigDecimal("100.00"))
|
845
|
+
expect(transaction.type).to eq("credit")
|
846
|
+
expect(transaction.customer_details.id).to eq(customer.id)
|
847
|
+
expect(transaction.credit_card_details.token).to eq(customer.credit_cards[0].token)
|
848
|
+
expect(transaction.credit_card_details.bin).to eq(Braintree::Test::CreditCardNumbers::Visa[0, 6])
|
849
|
+
expect(transaction.credit_card_details.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
|
850
|
+
expect(transaction.credit_card_details.expiration_date).to eq("05/2010")
|
851
851
|
end
|
852
852
|
end
|
853
853
|
|
@@ -857,10 +857,10 @@ describe Braintree::Customer do
|
|
857
857
|
:first_name => "Joe",
|
858
858
|
:last_name => "Cool",
|
859
859
|
)
|
860
|
-
result.success
|
860
|
+
expect(result.success?).to eq(true)
|
861
861
|
|
862
862
|
customer = result.customer
|
863
|
-
customer.delete.success
|
863
|
+
expect(customer.delete.success?).to eq(true)
|
864
864
|
expect do
|
865
865
|
Braintree::Customer.find(customer.id)
|
866
866
|
end.to raise_error(Braintree::NotFoundError)
|
@@ -874,13 +874,13 @@ describe Braintree::Customer do
|
|
874
874
|
:first_name => "Joe",
|
875
875
|
:last_name => "Cool",
|
876
876
|
)
|
877
|
-
result.success
|
877
|
+
expect(result.success?).to eq(true)
|
878
878
|
|
879
879
|
customer = Braintree::Customer.find(result.customer.id)
|
880
|
-
customer.id.
|
881
|
-
customer.graphql_id.
|
882
|
-
customer.first_name.
|
883
|
-
customer.last_name.
|
880
|
+
expect(customer.id).to eq(result.customer.id)
|
881
|
+
expect(customer.graphql_id).not_to be_nil
|
882
|
+
expect(customer.first_name).to eq("Joe")
|
883
|
+
expect(customer.last_name).to eq("Cool")
|
884
884
|
end
|
885
885
|
|
886
886
|
it "returns associated subscriptions" do
|
@@ -898,10 +898,10 @@ describe Braintree::Customer do
|
|
898
898
|
).subscription
|
899
899
|
|
900
900
|
found_customer = Braintree::Customer.find(customer.id)
|
901
|
-
found_customer.credit_cards.first.subscriptions.first.id.
|
902
|
-
found_customer.credit_cards.first.subscriptions.first.plan_id.
|
903
|
-
found_customer.credit_cards.first.subscriptions.first.payment_method_token.
|
904
|
-
found_customer.credit_cards.first.subscriptions.first.price.
|
901
|
+
expect(found_customer.credit_cards.first.subscriptions.first.id).to eq(subscription.id)
|
902
|
+
expect(found_customer.credit_cards.first.subscriptions.first.plan_id).to eq("integration_trialless_plan")
|
903
|
+
expect(found_customer.credit_cards.first.subscriptions.first.payment_method_token).to eq(credit_card.token)
|
904
|
+
expect(found_customer.credit_cards.first.subscriptions.first.price).to eq(BigDecimal("1.00"))
|
905
905
|
end
|
906
906
|
|
907
907
|
context "when given an association filter id" do
|
@@ -933,10 +933,10 @@ describe Braintree::Customer do
|
|
933
933
|
found_customer = Braintree::Customer.find(customer.id, {
|
934
934
|
:association_filter_id => "customernoassociations"
|
935
935
|
})
|
936
|
-
found_customer.credit_cards.length.
|
937
|
-
found_customer.payment_methods.length.
|
938
|
-
found_customer.addresses.length.
|
939
|
-
found_customer.custom_fields.
|
936
|
+
expect(found_customer.credit_cards.length).to eq(0)
|
937
|
+
expect(found_customer.payment_methods.length).to eq(0)
|
938
|
+
expect(found_customer.addresses.length).to eq(0)
|
939
|
+
expect(found_customer.custom_fields).to eq({})
|
940
940
|
end
|
941
941
|
|
942
942
|
it "filters out nested filterable associations" do
|
@@ -968,12 +968,12 @@ describe Braintree::Customer do
|
|
968
968
|
:association_filter_id => "customertoplevelassociations"
|
969
969
|
})
|
970
970
|
|
971
|
-
found_customer.credit_cards.length.
|
972
|
-
found_customer.credit_cards.first.subscriptions.length.
|
973
|
-
found_customer.payment_methods.length.
|
974
|
-
found_customer.payment_methods.first.subscriptions.length.
|
975
|
-
found_customer.addresses.length.
|
976
|
-
found_customer.custom_fields.length.
|
971
|
+
expect(found_customer.credit_cards.length).to eq(1)
|
972
|
+
expect(found_customer.credit_cards.first.subscriptions.length).to eq(0)
|
973
|
+
expect(found_customer.payment_methods.length).to eq(1)
|
974
|
+
expect(found_customer.payment_methods.first.subscriptions.length).to eq(0)
|
975
|
+
expect(found_customer.addresses.length).to eq(1)
|
976
|
+
expect(found_customer.custom_fields.length).to eq(1)
|
977
977
|
end
|
978
978
|
end
|
979
979
|
|
@@ -981,89 +981,89 @@ describe Braintree::Customer do
|
|
981
981
|
result = Braintree::Customer.create(
|
982
982
|
:payment_method_nonce => Braintree::Test::Nonce::ApplePayAmEx,
|
983
983
|
)
|
984
|
-
result.success
|
984
|
+
expect(result.success?).to eq(true)
|
985
985
|
|
986
986
|
found_customer = Braintree::Customer.find(result.customer.id)
|
987
|
-
found_customer.apple_pay_cards.
|
987
|
+
expect(found_customer.apple_pay_cards).not_to be_nil
|
988
988
|
apple_pay_card = found_customer.apple_pay_cards.first
|
989
|
-
apple_pay_card.
|
990
|
-
apple_pay_card.token.
|
991
|
-
apple_pay_card.expiration_year.
|
992
|
-
apple_pay_card.payment_instrument_name.
|
993
|
-
apple_pay_card.commercial.
|
994
|
-
apple_pay_card.country_of_issuance.
|
995
|
-
apple_pay_card.debit.
|
996
|
-
apple_pay_card.durbin_regulated.
|
997
|
-
apple_pay_card.healthcare.
|
998
|
-
apple_pay_card.issuing_bank.
|
999
|
-
apple_pay_card.payroll.
|
1000
|
-
apple_pay_card.prepaid.
|
1001
|
-
apple_pay_card.product_id.
|
989
|
+
expect(apple_pay_card).to be_a Braintree::ApplePayCard
|
990
|
+
expect(apple_pay_card.token).not_to be_nil
|
991
|
+
expect(apple_pay_card.expiration_year).not_to be_nil
|
992
|
+
expect(apple_pay_card.payment_instrument_name).to eq("AmEx 41002")
|
993
|
+
expect(apple_pay_card.commercial).not_to be_nil
|
994
|
+
expect(apple_pay_card.country_of_issuance).not_to be_nil
|
995
|
+
expect(apple_pay_card.debit).not_to be_nil
|
996
|
+
expect(apple_pay_card.durbin_regulated).not_to be_nil
|
997
|
+
expect(apple_pay_card.healthcare).not_to be_nil
|
998
|
+
expect(apple_pay_card.issuing_bank).not_to be_nil
|
999
|
+
expect(apple_pay_card.payroll).not_to be_nil
|
1000
|
+
expect(apple_pay_card.prepaid).not_to be_nil
|
1001
|
+
expect(apple_pay_card.product_id).not_to be_nil
|
1002
1002
|
end
|
1003
1003
|
|
1004
1004
|
it "returns associated google pay proxy cards" do
|
1005
1005
|
result = Braintree::Customer.create(
|
1006
1006
|
:payment_method_nonce => Braintree::Test::Nonce::GooglePayDiscover,
|
1007
1007
|
)
|
1008
|
-
result.success
|
1008
|
+
expect(result.success?).to eq(true)
|
1009
1009
|
|
1010
1010
|
found_customer = Braintree::Customer.find(result.customer.id)
|
1011
|
-
found_customer.google_pay_cards.size.
|
1012
|
-
found_customer.payment_methods.size.
|
1011
|
+
expect(found_customer.google_pay_cards.size).to eq(1)
|
1012
|
+
expect(found_customer.payment_methods.size).to eq(1)
|
1013
1013
|
google_pay_card = found_customer.google_pay_cards.first
|
1014
|
-
google_pay_card.
|
1015
|
-
google_pay_card.token.
|
1016
|
-
google_pay_card.expiration_year.
|
1017
|
-
google_pay_card.is_network_tokenized
|
1018
|
-
google_pay_card.commercial.
|
1019
|
-
google_pay_card.country_of_issuance.
|
1020
|
-
google_pay_card.debit.
|
1021
|
-
google_pay_card.durbin_regulated.
|
1022
|
-
google_pay_card.healthcare.
|
1023
|
-
google_pay_card.issuing_bank.
|
1024
|
-
google_pay_card.payroll.
|
1025
|
-
google_pay_card.prepaid.
|
1026
|
-
google_pay_card.product_id.
|
1014
|
+
expect(google_pay_card).to be_a Braintree::GooglePayCard
|
1015
|
+
expect(google_pay_card.token).not_to be_nil
|
1016
|
+
expect(google_pay_card.expiration_year).not_to be_nil
|
1017
|
+
expect(google_pay_card.is_network_tokenized?).to eq(false)
|
1018
|
+
expect(google_pay_card.commercial).not_to be_nil
|
1019
|
+
expect(google_pay_card.country_of_issuance).not_to be_nil
|
1020
|
+
expect(google_pay_card.debit).not_to be_nil
|
1021
|
+
expect(google_pay_card.durbin_regulated).not_to be_nil
|
1022
|
+
expect(google_pay_card.healthcare).not_to be_nil
|
1023
|
+
expect(google_pay_card.issuing_bank).not_to be_nil
|
1024
|
+
expect(google_pay_card.payroll).not_to be_nil
|
1025
|
+
expect(google_pay_card.prepaid).not_to be_nil
|
1026
|
+
expect(google_pay_card.product_id).not_to be_nil
|
1027
1027
|
end
|
1028
1028
|
|
1029
1029
|
it "returns associated google pay network tokens" do
|
1030
1030
|
result = Braintree::Customer.create(
|
1031
1031
|
:payment_method_nonce => Braintree::Test::Nonce::GooglePayMasterCard,
|
1032
1032
|
)
|
1033
|
-
result.success
|
1033
|
+
expect(result.success?).to eq(true)
|
1034
1034
|
|
1035
1035
|
found_customer = Braintree::Customer.find(result.customer.id)
|
1036
|
-
found_customer.google_pay_cards.size.
|
1037
|
-
found_customer.payment_methods.size.
|
1036
|
+
expect(found_customer.google_pay_cards.size).to eq(1)
|
1037
|
+
expect(found_customer.payment_methods.size).to eq(1)
|
1038
1038
|
google_pay_card = found_customer.google_pay_cards.first
|
1039
|
-
google_pay_card.
|
1040
|
-
google_pay_card.token.
|
1041
|
-
google_pay_card.expiration_year.
|
1042
|
-
google_pay_card.is_network_tokenized
|
1043
|
-
google_pay_card.commercial.
|
1044
|
-
google_pay_card.country_of_issuance.
|
1045
|
-
google_pay_card.debit.
|
1046
|
-
google_pay_card.durbin_regulated.
|
1047
|
-
google_pay_card.healthcare.
|
1048
|
-
google_pay_card.issuing_bank.
|
1049
|
-
google_pay_card.payroll.
|
1050
|
-
google_pay_card.prepaid.
|
1051
|
-
google_pay_card.product_id.
|
1039
|
+
expect(google_pay_card).to be_a Braintree::GooglePayCard
|
1040
|
+
expect(google_pay_card.token).not_to be_nil
|
1041
|
+
expect(google_pay_card.expiration_year).not_to be_nil
|
1042
|
+
expect(google_pay_card.is_network_tokenized?).to eq(true)
|
1043
|
+
expect(google_pay_card.commercial).not_to be_nil
|
1044
|
+
expect(google_pay_card.country_of_issuance).not_to be_nil
|
1045
|
+
expect(google_pay_card.debit).not_to be_nil
|
1046
|
+
expect(google_pay_card.durbin_regulated).not_to be_nil
|
1047
|
+
expect(google_pay_card.healthcare).not_to be_nil
|
1048
|
+
expect(google_pay_card.issuing_bank).not_to be_nil
|
1049
|
+
expect(google_pay_card.payroll).not_to be_nil
|
1050
|
+
expect(google_pay_card.prepaid).not_to be_nil
|
1051
|
+
expect(google_pay_card.product_id).not_to be_nil
|
1052
1052
|
end
|
1053
1053
|
|
1054
1054
|
it "returns associated venmo accounts" do
|
1055
1055
|
result = Braintree::Customer.create(
|
1056
1056
|
:payment_method_nonce => Braintree::Test::Nonce::VenmoAccount,
|
1057
1057
|
)
|
1058
|
-
result.success
|
1058
|
+
expect(result.success?).to eq(true)
|
1059
1059
|
|
1060
1060
|
found_customer = Braintree::Customer.find(result.customer.id)
|
1061
|
-
found_customer.venmo_accounts.size.
|
1062
|
-
found_customer.payment_methods.size.
|
1061
|
+
expect(found_customer.venmo_accounts.size).to eq(1)
|
1062
|
+
expect(found_customer.payment_methods.size).to eq(1)
|
1063
1063
|
venmo_account = found_customer.venmo_accounts.first
|
1064
|
-
venmo_account.
|
1065
|
-
venmo_account.token.
|
1066
|
-
venmo_account.username.
|
1064
|
+
expect(venmo_account).to be_a Braintree::VenmoAccount
|
1065
|
+
expect(venmo_account.token).not_to be_nil
|
1066
|
+
expect(venmo_account.username).not_to be_nil
|
1067
1067
|
end
|
1068
1068
|
|
1069
1069
|
xit "returns associated us bank accounts" do
|
@@ -1075,25 +1075,25 @@ describe Braintree::Customer do
|
|
1075
1075
|
}
|
1076
1076
|
},
|
1077
1077
|
)
|
1078
|
-
result.
|
1078
|
+
expect(result).to be_success
|
1079
1079
|
|
1080
1080
|
found_customer = Braintree::Customer.find(result.customer.id)
|
1081
|
-
found_customer.us_bank_accounts.size.
|
1082
|
-
found_customer.payment_methods.size.
|
1081
|
+
expect(found_customer.us_bank_accounts.size).to eq(1)
|
1082
|
+
expect(found_customer.payment_methods.size).to eq(1)
|
1083
1083
|
|
1084
1084
|
us_bank_account = found_customer.us_bank_accounts.first
|
1085
|
-
us_bank_account.
|
1086
|
-
us_bank_account.routing_number.
|
1087
|
-
us_bank_account.last_4.
|
1088
|
-
us_bank_account.account_type.
|
1089
|
-
us_bank_account.account_holder_name.
|
1090
|
-
us_bank_account.bank_name.
|
1085
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
1086
|
+
expect(us_bank_account.routing_number).to eq("021000021")
|
1087
|
+
expect(us_bank_account.last_4).to eq("0000")
|
1088
|
+
expect(us_bank_account.account_type).to eq("checking")
|
1089
|
+
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
1090
|
+
expect(us_bank_account.bank_name).to match(/CHASE/)
|
1091
1091
|
end
|
1092
1092
|
|
1093
1093
|
it "works for a blank customer" do
|
1094
1094
|
created_customer = Braintree::Customer.create!
|
1095
1095
|
found_customer = Braintree::Customer.find(created_customer.id)
|
1096
|
-
found_customer.id.
|
1096
|
+
expect(found_customer.id).to eq(created_customer.id)
|
1097
1097
|
end
|
1098
1098
|
|
1099
1099
|
it "raises an ArgumentError if customer_id is not a string" do
|
@@ -1144,11 +1144,11 @@ describe Braintree::Customer do
|
|
1144
1144
|
:options => {:verify_card => true},
|
1145
1145
|
},
|
1146
1146
|
)
|
1147
|
-
result.success
|
1148
|
-
result.customer.id.
|
1149
|
-
result.customer.first_name.
|
1150
|
-
result.customer.last_name.
|
1151
|
-
result.customer.custom_fields[:store_me].
|
1147
|
+
expect(result.success?).to eq(true)
|
1148
|
+
expect(result.customer.id).to eq(customer.id)
|
1149
|
+
expect(result.customer.first_name).to eq("Mr. Joe")
|
1150
|
+
expect(result.customer.last_name).to eq("Super Cool")
|
1151
|
+
expect(result.customer.custom_fields[:store_me]).to eq("a value")
|
1152
1152
|
end
|
1153
1153
|
|
1154
1154
|
it "validates the presence of three_d_secure_version while passing three_d_secure_pass_thru in update" do
|
@@ -1197,11 +1197,11 @@ describe Braintree::Customer do
|
|
1197
1197
|
:store_me => "a value"
|
1198
1198
|
},
|
1199
1199
|
)
|
1200
|
-
result.success
|
1201
|
-
result.customer.id.
|
1202
|
-
result.customer.first_name.
|
1203
|
-
result.customer.last_name.
|
1204
|
-
result.customer.custom_fields[:store_me].
|
1200
|
+
expect(result.success?).to eq(true)
|
1201
|
+
expect(result.customer.id).to eq(customer.id)
|
1202
|
+
expect(result.customer.first_name).to eq("Mr. Joe")
|
1203
|
+
expect(result.customer.last_name).to eq("Super Cool")
|
1204
|
+
expect(result.customer.custom_fields[:store_me]).to eq("a value")
|
1205
1205
|
end
|
1206
1206
|
|
1207
1207
|
it "does not update customer with duplicate payment method if fail_on_payment_method option set" do
|
@@ -1221,8 +1221,8 @@ describe Braintree::Customer do
|
|
1221
1221
|
}
|
1222
1222
|
},
|
1223
1223
|
)
|
1224
|
-
result.success
|
1225
|
-
result.errors.for(:customer).for(:credit_card).on(:number)[0].message.
|
1224
|
+
expect(result.success?).to eq(false)
|
1225
|
+
expect(result.errors.for(:customer).for(:credit_card).on(:number)[0].message).to eq("Duplicate card exists in the vault.")
|
1226
1226
|
end
|
1227
1227
|
|
1228
1228
|
it "updates the default payment method" do
|
@@ -1240,7 +1240,7 @@ describe Braintree::Customer do
|
|
1240
1240
|
)
|
1241
1241
|
|
1242
1242
|
payment_method1 = Braintree::PaymentMethod.find(token1)
|
1243
|
-
payment_method1.
|
1243
|
+
expect(payment_method1).to be_default
|
1244
1244
|
|
1245
1245
|
token2 = random_payment_method_token
|
1246
1246
|
|
@@ -1255,7 +1255,7 @@ describe Braintree::Customer do
|
|
1255
1255
|
)
|
1256
1256
|
|
1257
1257
|
payment_method2 = Braintree::PaymentMethod.find(token2)
|
1258
|
-
payment_method2.
|
1258
|
+
expect(payment_method2).to be_default
|
1259
1259
|
end
|
1260
1260
|
|
1261
1261
|
it "updates the default payment method in the options" do
|
@@ -1273,7 +1273,7 @@ describe Braintree::Customer do
|
|
1273
1273
|
)
|
1274
1274
|
|
1275
1275
|
payment_method1 = Braintree::PaymentMethod.find(token1)
|
1276
|
-
payment_method1.
|
1276
|
+
expect(payment_method1).to be_default
|
1277
1277
|
|
1278
1278
|
token2 = random_payment_method_token
|
1279
1279
|
|
@@ -1293,7 +1293,7 @@ describe Braintree::Customer do
|
|
1293
1293
|
)
|
1294
1294
|
|
1295
1295
|
payment_method2 = Braintree::PaymentMethod.find(token2)
|
1296
|
-
payment_method2.
|
1296
|
+
expect(payment_method2).to be_default
|
1297
1297
|
end
|
1298
1298
|
|
1299
1299
|
it "can use any country code" do
|
@@ -1316,11 +1316,11 @@ describe Braintree::Customer do
|
|
1316
1316
|
}
|
1317
1317
|
},
|
1318
1318
|
)
|
1319
|
-
result.success
|
1320
|
-
result.customer.addresses[0].country_name.
|
1321
|
-
result.customer.addresses[0].country_code_alpha2.
|
1322
|
-
result.customer.addresses[0].country_code_alpha3.
|
1323
|
-
result.customer.addresses[0].country_code_numeric.
|
1319
|
+
expect(result.success?).to eq(true)
|
1320
|
+
expect(result.customer.addresses[0].country_name).to eq("Fiji")
|
1321
|
+
expect(result.customer.addresses[0].country_code_alpha2).to eq("FJ")
|
1322
|
+
expect(result.customer.addresses[0].country_code_alpha3).to eq("FJI")
|
1323
|
+
expect(result.customer.addresses[0].country_code_numeric).to eq("242")
|
1324
1324
|
end
|
1325
1325
|
|
1326
1326
|
it "can update the customer, credit card, and billing address in one request" do
|
@@ -1349,18 +1349,18 @@ describe Braintree::Customer do
|
|
1349
1349
|
}
|
1350
1350
|
},
|
1351
1351
|
)
|
1352
|
-
result.success
|
1353
|
-
result.customer.id.
|
1354
|
-
result.customer.first_name.
|
1352
|
+
expect(result.success?).to eq(true)
|
1353
|
+
expect(result.customer.id).to eq(customer.id)
|
1354
|
+
expect(result.customer.first_name).to eq("New Joe")
|
1355
1355
|
|
1356
|
-
result.customer.credit_cards.size.
|
1356
|
+
expect(result.customer.credit_cards.size).to eq(1)
|
1357
1357
|
credit_card = result.customer.credit_cards.first
|
1358
|
-
credit_card.bin.
|
1359
|
-
credit_card.cardholder_name.
|
1358
|
+
expect(credit_card.bin).to eq(Braintree::Test::CreditCardNumbers::Visa.slice(0, 6))
|
1359
|
+
expect(credit_card.cardholder_name).to eq("New Joe Cardholder")
|
1360
1360
|
|
1361
|
-
credit_card.billing_address.first_name.
|
1362
|
-
credit_card.billing_address.last_name.
|
1363
|
-
credit_card.billing_address.postal_code.
|
1361
|
+
expect(credit_card.billing_address.first_name).to eq("Joe")
|
1362
|
+
expect(credit_card.billing_address.last_name).to eq("Cool")
|
1363
|
+
expect(credit_card.billing_address.postal_code).to eq("60666")
|
1364
1364
|
end
|
1365
1365
|
|
1366
1366
|
it "can update the customer and verify_card with a specific verification_amount" do
|
@@ -1378,7 +1378,7 @@ describe Braintree::Customer do
|
|
1378
1378
|
:options => {:verify_card => true, :verification_amount => "2.00"}
|
1379
1379
|
},
|
1380
1380
|
)
|
1381
|
-
result.success
|
1381
|
+
expect(result.success?).to eq(true)
|
1382
1382
|
end
|
1383
1383
|
|
1384
1384
|
it "includes risk data when skip_advanced_fraud_checking is false" do
|
@@ -1443,7 +1443,7 @@ describe Braintree::Customer do
|
|
1443
1443
|
customer.id,
|
1444
1444
|
:tax_identifiers => [{:country_code => "US", :identifier => "567891234"}],
|
1445
1445
|
)
|
1446
|
-
result.success
|
1446
|
+
expect(result.success?).to eq(true)
|
1447
1447
|
end
|
1448
1448
|
|
1449
1449
|
it "validates presence of three_d_secure_version in 3ds pass thru params" do
|
@@ -1498,18 +1498,18 @@ describe Braintree::Customer do
|
|
1498
1498
|
:options => {:verify_card => true}
|
1499
1499
|
},
|
1500
1500
|
)
|
1501
|
-
result.success
|
1501
|
+
expect(result.success?).to eq(true)
|
1502
1502
|
|
1503
1503
|
three_d_secure_info = result.customer.payment_methods.first.verification.three_d_secure_info
|
1504
|
-
three_d_secure_info.enrolled.
|
1505
|
-
three_d_secure_info.
|
1506
|
-
three_d_secure_info.
|
1507
|
-
three_d_secure_info.status.
|
1508
|
-
three_d_secure_info.cavv.
|
1509
|
-
three_d_secure_info.xid.
|
1510
|
-
three_d_secure_info.eci_flag.
|
1511
|
-
three_d_secure_info.three_d_secure_version.
|
1512
|
-
three_d_secure_info.ds_transaction_id.
|
1504
|
+
expect(three_d_secure_info.enrolled).to eq("Y")
|
1505
|
+
expect(three_d_secure_info).to be_liability_shifted
|
1506
|
+
expect(three_d_secure_info).to be_liability_shift_possible
|
1507
|
+
expect(three_d_secure_info.status).to eq("authenticate_successful")
|
1508
|
+
expect(three_d_secure_info.cavv).to eq("cavv_value")
|
1509
|
+
expect(three_d_secure_info.xid).to eq("xid_value")
|
1510
|
+
expect(three_d_secure_info.eci_flag).to eq("05")
|
1511
|
+
expect(three_d_secure_info.three_d_secure_version).to eq("1.0.2")
|
1512
|
+
expect(three_d_secure_info.ds_transaction_id).to eq(nil)
|
1513
1513
|
end
|
1514
1514
|
|
1515
1515
|
it "can update the nested billing address with billing_address_id" do
|
@@ -1531,9 +1531,9 @@ describe Braintree::Customer do
|
|
1531
1531
|
).customer
|
1532
1532
|
|
1533
1533
|
billing_address = customer.credit_cards.first.billing_address
|
1534
|
-
billing_address.id.
|
1535
|
-
billing_address.first_name.
|
1536
|
-
billing_address.last_name.
|
1534
|
+
expect(billing_address.id).to eq(address.id)
|
1535
|
+
expect(billing_address.first_name).to eq("John")
|
1536
|
+
expect(billing_address.last_name).to eq("Doe")
|
1537
1537
|
end
|
1538
1538
|
|
1539
1539
|
it "returns an error response if invalid" do
|
@@ -1542,8 +1542,8 @@ describe Braintree::Customer do
|
|
1542
1542
|
customer.id,
|
1543
1543
|
:email => "@invalid.com",
|
1544
1544
|
)
|
1545
|
-
result.success
|
1546
|
-
result.errors.for(:customer).on(:email)[0].message.
|
1545
|
+
expect(result.success?).to eq(false)
|
1546
|
+
expect(result.errors.for(:customer).on(:email)[0].message).to eq("Email is an invalid format.")
|
1547
1547
|
end
|
1548
1548
|
|
1549
1549
|
context "verification_currency_iso_code" do
|
@@ -1562,7 +1562,7 @@ describe Braintree::Customer do
|
|
1562
1562
|
:options => {:verify_card => true, :verification_currency_iso_code => "USD"}
|
1563
1563
|
},
|
1564
1564
|
)
|
1565
|
-
result.success
|
1565
|
+
expect(result.success?).to eq(true)
|
1566
1566
|
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
1567
1567
|
end
|
1568
1568
|
|
@@ -1581,7 +1581,7 @@ describe Braintree::Customer do
|
|
1581
1581
|
:options => {:verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "USD"}
|
1582
1582
|
},
|
1583
1583
|
)
|
1584
|
-
result.success
|
1584
|
+
expect(result.success?).to eq(true)
|
1585
1585
|
result.customer.credit_cards[0].verification.currency_iso_code == "USD"
|
1586
1586
|
result.customer.credit_cards[0].verification.merchant_account_id == SpecHelper::NonDefaultMerchantAccountId
|
1587
1587
|
end
|
@@ -1601,7 +1601,7 @@ describe Braintree::Customer do
|
|
1601
1601
|
:options => {:verify_card => true, :verification_currency_iso_code => "GBP"}
|
1602
1602
|
},
|
1603
1603
|
)
|
1604
|
-
result.success
|
1604
|
+
expect(result.success?).to eq(false)
|
1605
1605
|
expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
1606
1606
|
|
1607
1607
|
end
|
@@ -1621,7 +1621,7 @@ describe Braintree::Customer do
|
|
1621
1621
|
:options => {:verify_card => true, :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId, :verification_currency_iso_code => "GBP"}
|
1622
1622
|
},
|
1623
1623
|
)
|
1624
|
-
result.success
|
1624
|
+
expect(result.success?).to eq(false)
|
1625
1625
|
expect(result.errors.for(:customer).for(:credit_card).for(:options).on(:verification_currency_iso_code)[0].code).to eq Braintree::ErrorCodes::CreditCard::CurrencyCodeNotSupportedByMerchantAccount
|
1626
1626
|
|
1627
1627
|
end
|
@@ -1679,9 +1679,9 @@ describe Braintree::Customer do
|
|
1679
1679
|
:first_name => "Mr. Joe",
|
1680
1680
|
:last_name => "Super Cool",
|
1681
1681
|
)
|
1682
|
-
updated_customer.first_name.
|
1683
|
-
updated_customer.last_name.
|
1684
|
-
updated_customer.updated_at.between?(Time.now - 60, Time.now).
|
1682
|
+
expect(updated_customer.first_name).to eq("Mr. Joe")
|
1683
|
+
expect(updated_customer.last_name).to eq("Super Cool")
|
1684
|
+
expect(updated_customer.updated_at.between?(Time.now - 60, Time.now)).to eq(true)
|
1685
1685
|
end
|
1686
1686
|
|
1687
1687
|
it "raises an error if unsuccessful" do
|
@@ -1715,7 +1715,7 @@ describe Braintree::Customer do
|
|
1715
1715
|
|
1716
1716
|
customer = Braintree::Customer.find(customer.id)
|
1717
1717
|
|
1718
|
-
customer.default_payment_method.
|
1718
|
+
expect(customer.default_payment_method).to eq(default_payment_method)
|
1719
1719
|
end
|
1720
1720
|
end
|
1721
1721
|
|
@@ -1726,7 +1726,7 @@ describe Braintree::Customer do
|
|
1726
1726
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalBillingAgreement,
|
1727
1727
|
)
|
1728
1728
|
|
1729
|
-
result.
|
1729
|
+
expect(result).to be_success
|
1730
1730
|
end
|
1731
1731
|
|
1732
1732
|
it "updates a customer with a future paypal account" do
|
@@ -1754,8 +1754,8 @@ describe Braintree::Customer do
|
|
1754
1754
|
:payment_method_nonce => nonce,
|
1755
1755
|
)
|
1756
1756
|
|
1757
|
-
result.
|
1758
|
-
result.customer.default_payment_method.token.
|
1757
|
+
expect(result).to be_success
|
1758
|
+
expect(result.customer.default_payment_method.token).to eq(paypal_account_token)
|
1759
1759
|
end
|
1760
1760
|
end
|
1761
1761
|
|
@@ -1792,7 +1792,7 @@ describe Braintree::Customer do
|
|
1792
1792
|
},
|
1793
1793
|
)
|
1794
1794
|
|
1795
|
-
result.
|
1795
|
+
expect(result).to be_success
|
1796
1796
|
end
|
1797
1797
|
|
1798
1798
|
it "updates a customer with payment_method_nonce and paypal options" do
|
@@ -1838,8 +1838,8 @@ describe Braintree::Customer do
|
|
1838
1838
|
},
|
1839
1839
|
)
|
1840
1840
|
|
1841
|
-
result.
|
1842
|
-
result.customer.default_payment_method.token.
|
1841
|
+
expect(result).to be_success
|
1842
|
+
expect(result.customer.default_payment_method.token).to eq(paypal_account_token)
|
1843
1843
|
end
|
1844
1844
|
end
|
1845
1845
|
|
@@ -1849,7 +1849,7 @@ describe Braintree::Customer do
|
|
1849
1849
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
1850
1850
|
)
|
1851
1851
|
|
1852
|
-
result.
|
1852
|
+
expect(result).not_to be_success
|
1853
1853
|
end
|
1854
1854
|
|
1855
1855
|
it "does not update a customer with a onetime paypal account" do
|
@@ -1879,8 +1879,8 @@ describe Braintree::Customer do
|
|
1879
1879
|
:payment_method_nonce => nonce,
|
1880
1880
|
)
|
1881
1881
|
|
1882
|
-
result.
|
1883
|
-
customer.default_payment_method.token.
|
1882
|
+
expect(result).not_to be_success
|
1883
|
+
expect(customer.default_payment_method.token).to eq(credit_card_token)
|
1884
1884
|
end
|
1885
1885
|
end
|
1886
1886
|
end
|