braintree 4.23.0 → 4.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/braintree/address_gateway.rb +5 -0
- data/lib/braintree/apple_pay_card.rb +6 -0
- data/lib/braintree/bank_account_instant_verification_gateway.rb +38 -0
- data/lib/braintree/bank_account_instant_verification_jwt.rb +23 -0
- data/lib/braintree/bank_account_instant_verification_jwt_request.rb +21 -0
- data/lib/braintree/bin_data.rb +8 -2
- data/lib/braintree/configuration.rb +1 -1
- data/lib/braintree/credit_card.rb +12 -5
- data/lib/braintree/credit_card_gateway.rb +1 -0
- data/lib/braintree/credit_card_verification_gateway.rb +5 -2
- data/lib/braintree/customer_session_gateway.rb +195 -0
- data/lib/braintree/dispute.rb +1 -0
- data/lib/braintree/error_codes.rb +58 -104
- data/lib/braintree/error_result.rb +1 -1
- data/lib/braintree/errors.rb +2 -1
- data/lib/braintree/gateway.rb +12 -0
- data/lib/braintree/google_pay_card.rb +5 -0
- data/lib/braintree/graphql/enums/recommendations.rb +9 -0
- data/lib/braintree/graphql/enums/recommended_payment_option.rb +10 -0
- data/lib/braintree/graphql/inputs/create_customer_session_input.rb +44 -0
- data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +40 -0
- data/lib/braintree/graphql/inputs/customer_session_input.rb +45 -0
- data/lib/braintree/graphql/inputs/monetary_amount_input.rb +28 -0
- data/lib/braintree/graphql/inputs/paypal_payee_input.rb +28 -0
- data/lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb +31 -0
- data/lib/braintree/graphql/inputs/phone_input.rb +34 -0
- data/lib/braintree/graphql/inputs/update_customer_session_input.rb +42 -0
- data/lib/braintree/graphql/types/customer_recommendations_payload.rb +129 -0
- data/lib/braintree/graphql/types/payment_options.rb +35 -0
- data/lib/braintree/graphql/types/payment_recommendations.rb +35 -0
- data/lib/braintree/graphql/unions/customer_recommendations.rb +47 -0
- data/lib/braintree/graphql_client.rb +16 -0
- data/lib/braintree/merchant_account.rb +1 -25
- data/lib/braintree/merchant_account_gateway.rb +0 -81
- data/lib/braintree/meta_checkout_card.rb +11 -6
- data/lib/braintree/meta_checkout_token.rb +11 -6
- data/lib/braintree/payment_method_gateway.rb +9 -0
- data/lib/braintree/paypal_payment_resource.rb +22 -0
- data/lib/braintree/paypal_payment_resource_gateway.rb +36 -0
- data/lib/braintree/successful_result.rb +3 -0
- data/lib/braintree/test/credit_card.rb +5 -0
- data/lib/braintree/transaction/apple_pay_details.rb +7 -0
- data/lib/braintree/transaction/credit_card_details.rb +22 -10
- data/lib/braintree/transaction/google_pay_details.rb +16 -10
- data/lib/braintree/transaction/meta_checkout_card_details.rb +11 -2
- data/lib/braintree/transaction/meta_checkout_token_details.rb +13 -3
- data/lib/braintree/transaction/paypal_details.rb +2 -0
- data/lib/braintree/transaction/visa_checkout_card_details.rb +10 -2
- data/lib/braintree/transaction.rb +3 -26
- data/lib/braintree/transaction_gateway.rb +52 -31
- data/lib/braintree/us_bank_account_verification.rb +3 -1
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +10 -5
- data/lib/braintree/webhook_notification.rb +1 -4
- data/lib/braintree/webhook_testing_gateway.rb +16 -33
- data/lib/braintree/xml/{libxml.rb → nokogiri.rb} +18 -16
- data/lib/braintree/xml/parser.rb +4 -4
- data/lib/braintree.rb +21 -4
- data/spec/integration/braintree/advanced_search_spec.rb +7 -4
- data/spec/integration/braintree/apple_pay_spec.rb +6 -7
- data/spec/integration/braintree/bank_account_instant_verification_spec.rb +191 -0
- data/spec/integration/braintree/client_api/spec_helper.rb +81 -0
- data/spec/integration/braintree/credit_card_spec.rb +115 -1
- data/spec/integration/braintree/credit_card_verification_spec.rb +149 -0
- data/spec/integration/braintree/customer_session_spec.rb +154 -0
- data/spec/integration/braintree/customer_spec.rb +94 -10
- data/spec/integration/braintree/disbursement_spec.rb +1 -1
- data/spec/integration/braintree/dispute_spec.rb +13 -2
- data/spec/integration/braintree/merchant_account_spec.rb +19 -359
- data/spec/integration/braintree/merchant_spec.rb +4 -4
- data/spec/integration/braintree/payment_method_nonce_spec.rb +55 -0
- data/spec/integration/braintree/payment_method_spec.rb +57 -7
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +0 -3
- data/spec/integration/braintree/paypal_payment_resource_spec.rb +141 -0
- data/spec/integration/braintree/transaction_payment_facilitator_spec.rb +119 -0
- data/spec/integration/braintree/transaction_search_spec.rb +38 -33
- data/spec/integration/braintree/transaction_spec.rb +266 -350
- data/spec/integration/braintree/transaction_transfer_type_spec.rb +325 -0
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +0 -1
- data/spec/integration/braintree/us_bank_account_spec.rb +0 -3
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +1 -1
- data/spec/spec_helper.rb +46 -12
- data/spec/unit/braintree/apple_pay_card_spec.rb +7 -0
- data/spec/unit/braintree/bank_account_instant_verification_gateway_spec.rb +98 -0
- data/spec/unit/braintree/bank_account_instant_verification_jwt_request_spec.rb +71 -0
- data/spec/unit/braintree/client_token_spec.rb +11 -0
- data/spec/unit/braintree/configuration_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_spec.rb +27 -2
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +1 -0
- data/spec/unit/braintree/credit_card_verification_spec.rb +17 -0
- data/spec/unit/braintree/customer_session_gateway_spec.rb +122 -0
- data/spec/unit/braintree/customer_spec.rb +2 -1
- data/spec/unit/braintree/dispute_spec.rb +6 -0
- data/spec/unit/braintree/error_result_spec.rb +28 -0
- data/spec/unit/braintree/google_pay_card_spec.rb +28 -0
- data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +102 -0
- data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +80 -0
- data/spec/unit/braintree/graphql/customer_recommendations_spec.rb +40 -0
- data/spec/unit/braintree/graphql/customer_session_input_spec.rb +81 -0
- data/spec/unit/braintree/graphql/phone_input_spec.rb +51 -0
- data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +107 -0
- data/spec/unit/braintree/graphql_client_spec.rb +37 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +61 -51
- data/spec/unit/braintree/meta_checkout_token_spec.rb +7 -1
- data/spec/unit/braintree/payment_method_nonce_spec.rb +11 -1
- data/spec/unit/braintree/payment_method_spec.rb +12 -0
- data/spec/unit/braintree/paypal_payment_resource_spec.rb +125 -0
- data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +37 -0
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +15 -1
- data/spec/unit/braintree/transaction/google_pay_details_spec.rb +37 -0
- data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +28 -0
- data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +28 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +5 -0
- data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +28 -0
- data/spec/unit/braintree/transaction_ach_mandate_spec.rb +82 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +58 -11
- data/spec/unit/braintree/transaction_spec.rb +66 -0
- data/spec/unit/braintree/visa_checkout_card_spec.rb +28 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +15 -51
- data/spec/unit/braintree/xml/{libxml_spec.rb → nokogiri_spec.rb} +7 -7
- data/spec/unit/braintree/xml/parser_spec.rb +57 -0
- data/spec/unit/credit_card_details_spec.rb +28 -0
- metadata +49 -10
- data/lib/braintree/merchant_account/business_details.rb +0 -17
- data/lib/braintree/merchant_account/funding_details.rb +0 -18
- data/lib/braintree/merchant_account/individual_details.rb +0 -20
- data/lib/ssl/securetrust_ca.crt +0 -44
- data/spec/unit/braintree/disbursement_spec.rb +0 -131
- data/spec/unit/braintree/merchant_account_spec.rb +0 -33
|
@@ -67,6 +67,28 @@ describe Braintree::CreditCardVerification, "search" do
|
|
|
67
67
|
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
it "creates a new verification for Visa ANI when account information inquiry is passed" do
|
|
71
|
+
verification_params = {
|
|
72
|
+
:credit_card => {
|
|
73
|
+
:expiration_date => "05/2032",
|
|
74
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
75
|
+
},
|
|
76
|
+
:options => {
|
|
77
|
+
:account_information_inquiry => "send_data",
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
|
82
|
+
|
|
83
|
+
expect(result).to be_success
|
|
84
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
|
85
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
|
86
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
|
87
|
+
expect(result.credit_card_verification.ani_first_name_response_code).to eq("I")
|
|
88
|
+
expect(result.credit_card_verification.ani_last_name_response_code).to eq("I")
|
|
89
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
|
90
|
+
end
|
|
91
|
+
|
|
70
92
|
it "creates a new verification from external vault param" do
|
|
71
93
|
verification_params = {
|
|
72
94
|
:credit_card => {
|
|
@@ -235,6 +257,13 @@ describe Braintree::CreditCardVerification, "search" do
|
|
|
235
257
|
Braintree::CreditCardVerification.find("invalid-id")
|
|
236
258
|
end.to raise_error(Braintree::NotFoundError, 'verification with id "invalid-id" not found')
|
|
237
259
|
end
|
|
260
|
+
|
|
261
|
+
it "finds a verification and returns a payment_account_reference if the verification has one" do
|
|
262
|
+
verification = Braintree::CreditCardVerification.find("threedsecuredverification")
|
|
263
|
+
|
|
264
|
+
expect(verification.credit_card).not_to be_nil
|
|
265
|
+
expect(verification.credit_card).to have_key(:payment_account_reference)
|
|
266
|
+
end
|
|
238
267
|
end
|
|
239
268
|
|
|
240
269
|
describe "self.search" do
|
|
@@ -322,6 +351,126 @@ describe Braintree::CreditCardVerification, "search" do
|
|
|
322
351
|
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
|
323
352
|
expect(found_verification.credit_card[:prepaid]).to eq(Braintree::CreditCard::Prepaid::Yes)
|
|
324
353
|
end
|
|
354
|
+
|
|
355
|
+
it "returns prepaid_reloadable on a prepaid card" do
|
|
356
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
|
357
|
+
|
|
358
|
+
Braintree::Customer.create(
|
|
359
|
+
:credit_card => {
|
|
360
|
+
:cardholder_name => cardholder_name,
|
|
361
|
+
:expiration_date => "05/2012",
|
|
362
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::PrepaidReloadable,
|
|
363
|
+
:cvv => "200",
|
|
364
|
+
:options => {
|
|
365
|
+
:verify_card => true
|
|
366
|
+
}
|
|
367
|
+
})
|
|
368
|
+
|
|
369
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
|
370
|
+
search.credit_card_cardholder_name.is cardholder_name
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
verification_id = search_results.first.id
|
|
374
|
+
|
|
375
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
|
376
|
+
expect(found_verification.credit_card[:prepaid_reloadable]).to eq(Braintree::CreditCard::PrepaidReloadable::Yes)
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
it "returns business on a business card" do
|
|
380
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
|
381
|
+
|
|
382
|
+
Braintree::Customer.create(
|
|
383
|
+
:credit_card => {
|
|
384
|
+
:cardholder_name => cardholder_name,
|
|
385
|
+
:expiration_date => "05/2012",
|
|
386
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Business,
|
|
387
|
+
:cvv => "200",
|
|
388
|
+
:options => {
|
|
389
|
+
:verify_card => true
|
|
390
|
+
}
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
|
394
|
+
search.credit_card_cardholder_name.is cardholder_name
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
verification_id = search_results.first.id
|
|
398
|
+
|
|
399
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
|
400
|
+
expect(found_verification.credit_card[:business]).to eq(Braintree::CreditCard::Business::Yes)
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
it "returns consumer on a consumer card" do
|
|
404
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
|
405
|
+
|
|
406
|
+
Braintree::Customer.create(
|
|
407
|
+
:credit_card => {
|
|
408
|
+
:cardholder_name => cardholder_name,
|
|
409
|
+
:expiration_date => "05/2012",
|
|
410
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Consumer,
|
|
411
|
+
:cvv => "200",
|
|
412
|
+
:options => {
|
|
413
|
+
:verify_card => true
|
|
414
|
+
}
|
|
415
|
+
})
|
|
416
|
+
|
|
417
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
|
418
|
+
search.credit_card_cardholder_name.is cardholder_name
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
verification_id = search_results.first.id
|
|
422
|
+
|
|
423
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
|
424
|
+
expect(found_verification.credit_card[:consumer]).to eq(Braintree::CreditCard::Consumer::Yes)
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
it "returns corporate on a corporate card" do
|
|
428
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
|
429
|
+
|
|
430
|
+
Braintree::Customer.create(
|
|
431
|
+
:credit_card => {
|
|
432
|
+
:cardholder_name => cardholder_name,
|
|
433
|
+
:expiration_date => "05/2012",
|
|
434
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Corporate,
|
|
435
|
+
:cvv => "200",
|
|
436
|
+
:options => {
|
|
437
|
+
:verify_card => true
|
|
438
|
+
}
|
|
439
|
+
})
|
|
440
|
+
|
|
441
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
|
442
|
+
search.credit_card_cardholder_name.is cardholder_name
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
verification_id = search_results.first.id
|
|
446
|
+
|
|
447
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
|
448
|
+
expect(found_verification.credit_card[:corporate]).to eq(Braintree::CreditCard::Corporate::Yes)
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
it "returns purchase on a purchase card" do
|
|
452
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
|
453
|
+
|
|
454
|
+
Braintree::Customer.create(
|
|
455
|
+
:credit_card => {
|
|
456
|
+
:cardholder_name => cardholder_name,
|
|
457
|
+
:expiration_date => "05/2012",
|
|
458
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Purchase,
|
|
459
|
+
:cvv => "200",
|
|
460
|
+
:options => {
|
|
461
|
+
:verify_card => true
|
|
462
|
+
}
|
|
463
|
+
})
|
|
464
|
+
|
|
465
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
|
466
|
+
search.credit_card_cardholder_name.is cardholder_name
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
verification_id = search_results.first.id
|
|
470
|
+
|
|
471
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
|
472
|
+
expect(found_verification.credit_card[:purchase]).to eq(Braintree::CreditCard::Purchase::Yes)
|
|
473
|
+
end
|
|
325
474
|
end
|
|
326
475
|
end
|
|
327
476
|
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
|
3
|
+
|
|
4
|
+
describe Braintree::CustomerSessionGateway do
|
|
5
|
+
let(:pwpp_gateway) do
|
|
6
|
+
Braintree::Gateway.new(
|
|
7
|
+
:environment => :development,
|
|
8
|
+
:merchant_id => "pwpp_multi_account_merchant",
|
|
9
|
+
:public_key => "pwpp_multi_account_merchant_public_key",
|
|
10
|
+
:private_key => "pwpp_multi_account_merchant_private_key",
|
|
11
|
+
)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "create" do
|
|
15
|
+
it "can create customer session without email and phone" do
|
|
16
|
+
input = Braintree::CreateCustomerSessionInput.new(
|
|
17
|
+
merchant_account_id: "usd_pwpp_multi_account_merchant_account",
|
|
18
|
+
)
|
|
19
|
+
result = pwpp_gateway.customer_session.create_customer_session(input)
|
|
20
|
+
expect(result.success?).to eq(true)
|
|
21
|
+
expect(result.session_id).not_to be_nil
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "can create customer session with merchant provided session id" do
|
|
25
|
+
merchant_session_id = "11EF-A1E7-A5F5EE5C-A2E5-AFD2801469FC"
|
|
26
|
+
input = Braintree::CreateCustomerSessionInput.new(
|
|
27
|
+
session_id: merchant_session_id,
|
|
28
|
+
)
|
|
29
|
+
result = pwpp_gateway.customer_session.create_customer_session(input)
|
|
30
|
+
expect(result.success?).to eq(true)
|
|
31
|
+
expect(result.session_id).to eq(merchant_session_id)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "can create customer session with API-derived session id" do
|
|
35
|
+
result = build_customer_session(nil)
|
|
36
|
+
expect(result.session_id).not_to be_nil
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "can create customer session with purchase units" do
|
|
40
|
+
input = Braintree::CreateCustomerSessionInput.new(
|
|
41
|
+
purchase_units: build_purchase_units,
|
|
42
|
+
)
|
|
43
|
+
result = pwpp_gateway.customer_session.create_customer_session(input)
|
|
44
|
+
expect(result.success?).to eq(true)
|
|
45
|
+
expect(result.session_id).not_to be_nil
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "cannot create duplicate customer session" do
|
|
49
|
+
existing_session_id = "11EF-34BC-2702904B-9026-C3ECF4BAC765"
|
|
50
|
+
result = build_customer_session(existing_session_id)
|
|
51
|
+
expect(result.success?).to eq(false)
|
|
52
|
+
expect(result.errors.first.message).to include("Session IDs must be unique per merchant")
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe "update" do
|
|
57
|
+
it "can update a customer session" do
|
|
58
|
+
session_id = "11EF-A1E7-A5F5EE5C-A2E5-AFD2801469FC"
|
|
59
|
+
create_input = Braintree::CreateCustomerSessionInput.new(
|
|
60
|
+
merchant_account_id: "usd_pwpp_multi_account_merchant_account",
|
|
61
|
+
session_id: session_id,
|
|
62
|
+
purchase_units: build_purchase_units,
|
|
63
|
+
)
|
|
64
|
+
pwpp_gateway.customer_session.create_customer_session(create_input)
|
|
65
|
+
|
|
66
|
+
customer = build_customer_session_input
|
|
67
|
+
update_input = Braintree::UpdateCustomerSessionInput.new(
|
|
68
|
+
session_id: session_id,
|
|
69
|
+
customer: customer,
|
|
70
|
+
)
|
|
71
|
+
result = pwpp_gateway.customer_session.update_customer_session(update_input)
|
|
72
|
+
|
|
73
|
+
expect(result.success?).to eq(true)
|
|
74
|
+
expect(result.session_id).to eq(session_id)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "cannot update a non-existent customer session" do
|
|
78
|
+
session_id = "11EF-34BC-2702904B-9026-C3ECF4BAC765"
|
|
79
|
+
customer = build_customer_session_input
|
|
80
|
+
update_input = Braintree::UpdateCustomerSessionInput.new(
|
|
81
|
+
session_id: session_id,
|
|
82
|
+
customer: customer,
|
|
83
|
+
)
|
|
84
|
+
result = pwpp_gateway.customer_session.update_customer_session(update_input)
|
|
85
|
+
|
|
86
|
+
expect(result.success?).to eq(false)
|
|
87
|
+
expect(result.errors.first.message).to include("does not exist")
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
describe "customer recommendations" do
|
|
92
|
+
it "can get customer recommendations" do
|
|
93
|
+
customer = build_customer_session_input
|
|
94
|
+
customer_recommendations_input = Braintree::CustomerRecommendationsInput.new(
|
|
95
|
+
session_id: "94f0b2db-5323-4d86-add3-paypal000000",
|
|
96
|
+
customer: customer,
|
|
97
|
+
purchase_units: build_purchase_units,
|
|
98
|
+
domain: "domain.com",
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
result = pwpp_gateway.customer_session.get_customer_recommendations(customer_recommendations_input)
|
|
102
|
+
|
|
103
|
+
expect(result.success?).to eq(true)
|
|
104
|
+
payload = result.customer_recommendations
|
|
105
|
+
expect(payload.session_id).to eq("94f0b2db-5323-4d86-add3-paypal000000")
|
|
106
|
+
expect(payload.is_in_paypal_network).to eq(true)
|
|
107
|
+
|
|
108
|
+
recommendation = payload.recommendations.payment_recommendations[0]
|
|
109
|
+
expect(recommendation.payment_option).to eq(Braintree::RecommendedPaymentOption::PAYPAL)
|
|
110
|
+
expect(recommendation.recommended_priority).to eq(1)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "raises an error when not authorized" do
|
|
114
|
+
customer = build_customer_session_input
|
|
115
|
+
customer_recommendations_input = Braintree::CustomerRecommendationsInput.new(
|
|
116
|
+
session_id: "6B29FC40-CA47-1067-B31D-00DD010662DA",
|
|
117
|
+
customer: customer,
|
|
118
|
+
purchase_units: build_purchase_units,
|
|
119
|
+
domain: "domain.com",
|
|
120
|
+
merchant_account_id: "gbp_pwpp_multi_account_merchant_account",
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
expect {
|
|
124
|
+
pwpp_gateway.customer_session.get_customer_recommendations(customer_recommendations_input)
|
|
125
|
+
}.to raise_error(Braintree::AuthorizationError)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
private
|
|
130
|
+
|
|
131
|
+
def build_customer_session(session_id = nil)
|
|
132
|
+
customer = build_customer_session_input
|
|
133
|
+
input_attributes = {customer: customer}
|
|
134
|
+
input_attributes[:session_id] = session_id if session_id
|
|
135
|
+
|
|
136
|
+
input = Braintree::CreateCustomerSessionInput.new(input_attributes)
|
|
137
|
+
pwpp_gateway.customer_session.create_customer_session(input)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def build_customer_session_input
|
|
141
|
+
{
|
|
142
|
+
hashed_email: "48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08",
|
|
143
|
+
hashed_phone_number: "a2df2987b2a3384210d3aa1c9fb8b627ebdae1f5a9097766c19ca30ec4360176",
|
|
144
|
+
device_fingerprint_id: "00DD010662DE",
|
|
145
|
+
user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/x.x.x.x Safari/537.36",
|
|
146
|
+
}
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def build_purchase_units
|
|
150
|
+
amount = {currency_code: "USD", value: "10.00"}
|
|
151
|
+
purchase_unit = {amount: amount}
|
|
152
|
+
[purchase_unit]
|
|
153
|
+
end
|
|
154
|
+
end
|
|
@@ -4,7 +4,8 @@ require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
|
|
4
4
|
|
|
5
5
|
describe Braintree::Customer do
|
|
6
6
|
describe "self.all" do
|
|
7
|
-
|
|
7
|
+
#Disabling test until we have a more stable CI
|
|
8
|
+
xit "gets more than a page of customers" do
|
|
8
9
|
customers = Braintree::Customer.all
|
|
9
10
|
expect(customers.maximum_size).to be > 100
|
|
10
11
|
|
|
@@ -990,18 +991,23 @@ describe Braintree::Customer do
|
|
|
990
991
|
expect(found_customer.apple_pay_cards).not_to be_nil
|
|
991
992
|
apple_pay_card = found_customer.apple_pay_cards.first
|
|
992
993
|
expect(apple_pay_card).to be_a Braintree::ApplePayCard
|
|
993
|
-
expect(apple_pay_card.
|
|
994
|
-
expect(apple_pay_card.expiration_year).not_to be_nil
|
|
995
|
-
expect(apple_pay_card.payment_instrument_name).to eq("AmEx 41002")
|
|
994
|
+
expect(apple_pay_card.business).not_to be_nil
|
|
996
995
|
expect(apple_pay_card.commercial).not_to be_nil
|
|
996
|
+
expect(apple_pay_card.consumer).not_to be_nil
|
|
997
|
+
expect(apple_pay_card.corporate).not_to be_nil
|
|
997
998
|
expect(apple_pay_card.country_of_issuance).not_to be_nil
|
|
998
999
|
expect(apple_pay_card.debit).not_to be_nil
|
|
999
1000
|
expect(apple_pay_card.durbin_regulated).not_to be_nil
|
|
1001
|
+
expect(apple_pay_card.expiration_year).not_to be_nil
|
|
1000
1002
|
expect(apple_pay_card.healthcare).not_to be_nil
|
|
1001
1003
|
expect(apple_pay_card.issuing_bank).not_to be_nil
|
|
1004
|
+
expect(apple_pay_card.payment_instrument_name).to eq("AmEx 41002")
|
|
1002
1005
|
expect(apple_pay_card.payroll).not_to be_nil
|
|
1003
1006
|
expect(apple_pay_card.prepaid).not_to be_nil
|
|
1007
|
+
expect(apple_pay_card.prepaid_reloadable).not_to be_nil
|
|
1004
1008
|
expect(apple_pay_card.product_id).not_to be_nil
|
|
1009
|
+
expect(apple_pay_card.purchase).not_to be_nil
|
|
1010
|
+
expect(apple_pay_card.token).not_to be_nil
|
|
1005
1011
|
end
|
|
1006
1012
|
|
|
1007
1013
|
it "returns associated google pay proxy cards" do
|
|
@@ -1015,18 +1021,23 @@ describe Braintree::Customer do
|
|
|
1015
1021
|
expect(found_customer.payment_methods.size).to eq(1)
|
|
1016
1022
|
google_pay_card = found_customer.google_pay_cards.first
|
|
1017
1023
|
expect(google_pay_card).to be_a Braintree::GooglePayCard
|
|
1018
|
-
expect(google_pay_card.
|
|
1019
|
-
expect(google_pay_card.expiration_year).not_to be_nil
|
|
1020
|
-
expect(google_pay_card.is_network_tokenized?).to eq(false)
|
|
1024
|
+
expect(google_pay_card.business).not_to be_nil
|
|
1021
1025
|
expect(google_pay_card.commercial).not_to be_nil
|
|
1026
|
+
expect(google_pay_card.consumer).not_to be_nil
|
|
1027
|
+
expect(google_pay_card.corporate).not_to be_nil
|
|
1022
1028
|
expect(google_pay_card.country_of_issuance).not_to be_nil
|
|
1023
1029
|
expect(google_pay_card.debit).not_to be_nil
|
|
1024
1030
|
expect(google_pay_card.durbin_regulated).not_to be_nil
|
|
1031
|
+
expect(google_pay_card.expiration_year).not_to be_nil
|
|
1025
1032
|
expect(google_pay_card.healthcare).not_to be_nil
|
|
1033
|
+
expect(google_pay_card.is_network_tokenized?).to eq(false)
|
|
1026
1034
|
expect(google_pay_card.issuing_bank).not_to be_nil
|
|
1027
1035
|
expect(google_pay_card.payroll).not_to be_nil
|
|
1028
1036
|
expect(google_pay_card.prepaid).not_to be_nil
|
|
1037
|
+
expect(google_pay_card.prepaid_reloadable).not_to be_nil
|
|
1029
1038
|
expect(google_pay_card.product_id).not_to be_nil
|
|
1039
|
+
expect(google_pay_card.purchase).not_to be_nil
|
|
1040
|
+
expect(google_pay_card.token).not_to be_nil
|
|
1030
1041
|
end
|
|
1031
1042
|
|
|
1032
1043
|
it "returns associated google pay network tokens" do
|
|
@@ -1040,18 +1051,23 @@ describe Braintree::Customer do
|
|
|
1040
1051
|
expect(found_customer.payment_methods.size).to eq(1)
|
|
1041
1052
|
google_pay_card = found_customer.google_pay_cards.first
|
|
1042
1053
|
expect(google_pay_card).to be_a Braintree::GooglePayCard
|
|
1043
|
-
expect(google_pay_card.
|
|
1044
|
-
expect(google_pay_card.expiration_year).not_to be_nil
|
|
1045
|
-
expect(google_pay_card.is_network_tokenized?).to eq(true)
|
|
1054
|
+
expect(google_pay_card.business).not_to be_nil
|
|
1046
1055
|
expect(google_pay_card.commercial).not_to be_nil
|
|
1056
|
+
expect(google_pay_card.consumer).not_to be_nil
|
|
1057
|
+
expect(google_pay_card.corporate).not_to be_nil
|
|
1047
1058
|
expect(google_pay_card.country_of_issuance).not_to be_nil
|
|
1048
1059
|
expect(google_pay_card.debit).not_to be_nil
|
|
1049
1060
|
expect(google_pay_card.durbin_regulated).not_to be_nil
|
|
1061
|
+
expect(google_pay_card.expiration_year).not_to be_nil
|
|
1050
1062
|
expect(google_pay_card.healthcare).not_to be_nil
|
|
1063
|
+
expect(google_pay_card.is_network_tokenized?).to eq(true)
|
|
1051
1064
|
expect(google_pay_card.issuing_bank).not_to be_nil
|
|
1052
1065
|
expect(google_pay_card.payroll).not_to be_nil
|
|
1053
1066
|
expect(google_pay_card.prepaid).not_to be_nil
|
|
1067
|
+
expect(google_pay_card.prepaid_reloadable).not_to be_nil
|
|
1054
1068
|
expect(google_pay_card.product_id).not_to be_nil
|
|
1069
|
+
expect(google_pay_card.purchase).not_to be_nil
|
|
1070
|
+
expect(google_pay_card.token).not_to be_nil
|
|
1055
1071
|
end
|
|
1056
1072
|
|
|
1057
1073
|
it "returns associated venmo accounts" do
|
|
@@ -1746,6 +1762,57 @@ describe Braintree::Customer do
|
|
|
1746
1762
|
end
|
|
1747
1763
|
end
|
|
1748
1764
|
|
|
1765
|
+
describe "account information inquiry" do
|
|
1766
|
+
it "includes ani response when account information inquiry is sent in options" do
|
|
1767
|
+
result = Braintree::Customer.create(
|
|
1768
|
+
:credit_card => {
|
|
1769
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
1770
|
+
:expiration_date => "05/2027",
|
|
1771
|
+
:cvv => "100",
|
|
1772
|
+
:billing_address => {
|
|
1773
|
+
:first_name => "John",
|
|
1774
|
+
:last_name => "Doe",
|
|
1775
|
+
},
|
|
1776
|
+
:options => {
|
|
1777
|
+
:account_information_inquiry => "send_data",
|
|
1778
|
+
:verify_card => true,
|
|
1779
|
+
},
|
|
1780
|
+
},
|
|
1781
|
+
)
|
|
1782
|
+
|
|
1783
|
+
expect(result).to be_success
|
|
1784
|
+
verification = result.customer.credit_cards.first.verification
|
|
1785
|
+
expect(verification.ani_first_name_response_code).not_to be_nil
|
|
1786
|
+
expect(verification.ani_last_name_response_code).not_to be_nil
|
|
1787
|
+
end
|
|
1788
|
+
|
|
1789
|
+
it "includes ani response after updating the options with account information inquiry" do
|
|
1790
|
+
customer = Braintree::Customer.create!(
|
|
1791
|
+
:first_name => "Joe",
|
|
1792
|
+
)
|
|
1793
|
+
updated_result = Braintree::Customer.update(
|
|
1794
|
+
customer.id,
|
|
1795
|
+
:credit_card => {
|
|
1796
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
|
1797
|
+
:expiration_date => "12/2029",
|
|
1798
|
+
:billing_address => {
|
|
1799
|
+
:first_name => "John",
|
|
1800
|
+
:last_name => "Doe",
|
|
1801
|
+
},
|
|
1802
|
+
:options => {
|
|
1803
|
+
:account_information_inquiry => "send_data",
|
|
1804
|
+
:verify_card => true,
|
|
1805
|
+
},
|
|
1806
|
+
},
|
|
1807
|
+
)
|
|
1808
|
+
|
|
1809
|
+
expect(updated_result).to be_success
|
|
1810
|
+
verification = updated_result.customer.credit_cards.first.verification
|
|
1811
|
+
expect(verification.ani_first_name_response_code).not_to be_nil
|
|
1812
|
+
expect(verification.ani_last_name_response_code).not_to be_nil
|
|
1813
|
+
end
|
|
1814
|
+
end
|
|
1815
|
+
|
|
1749
1816
|
describe "paypal" do
|
|
1750
1817
|
context "future" do
|
|
1751
1818
|
it "creates a customer with a future paypal account" do
|
|
@@ -1911,4 +1978,21 @@ describe Braintree::Customer do
|
|
|
1911
1978
|
end
|
|
1912
1979
|
end
|
|
1913
1980
|
end
|
|
1981
|
+
|
|
1982
|
+
it "returns bin fields from VisaCheckoutCard" do
|
|
1983
|
+
result = Braintree::Customer.create(
|
|
1984
|
+
:payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutVisa,
|
|
1985
|
+
)
|
|
1986
|
+
expect(result.success?).to eq(true)
|
|
1987
|
+
|
|
1988
|
+
found_customer = Braintree::Customer.find(result.customer.id)
|
|
1989
|
+
expect(found_customer.visa_checkout_cards).not_to be_nil
|
|
1990
|
+
visa_checkout_card = found_customer.visa_checkout_cards.first
|
|
1991
|
+
expect(visa_checkout_card).to be_a Braintree::VisaCheckoutCard
|
|
1992
|
+
expect(visa_checkout_card.business).not_to be_nil
|
|
1993
|
+
expect(visa_checkout_card.consumer).not_to be_nil
|
|
1994
|
+
expect(visa_checkout_card.corporate).not_to be_nil
|
|
1995
|
+
expect(visa_checkout_card.prepaid_reloadable).not_to be_nil
|
|
1996
|
+
expect(visa_checkout_card.purchase).not_to be_nil
|
|
1997
|
+
end
|
|
1914
1998
|
end
|
|
@@ -32,8 +32,8 @@ describe Braintree::Dispute do
|
|
|
32
32
|
|
|
33
33
|
expect(result.success?).to eq(true)
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
expect(
|
|
35
|
+
updated_dispute = Braintree::Dispute.find(dispute.id)
|
|
36
|
+
expect(updated_dispute.status).to eq(Braintree::Dispute::Status::Accepted)
|
|
37
37
|
|
|
38
38
|
dispute_from_transaction = Braintree::Transaction.find(dispute.transaction.id).disputes[0]
|
|
39
39
|
expect(dispute_from_transaction.status).to eq(Braintree::Dispute::Status::Accepted)
|
|
@@ -99,6 +99,17 @@ describe Braintree::Dispute do
|
|
|
99
99
|
expect(result.evidence.category).to eq("GENERAL")
|
|
100
100
|
expect(result.evidence.url).to include("bt_logo.png")
|
|
101
101
|
end
|
|
102
|
+
|
|
103
|
+
it "reflects the updated remaining_file_evidence_storage" do
|
|
104
|
+
initial_storage = dispute.remaining_file_evidence_storage
|
|
105
|
+
expect(initial_storage).not_to be_nil
|
|
106
|
+
|
|
107
|
+
Braintree::Dispute.add_file_evidence(dispute.id, document_upload.id)
|
|
108
|
+
|
|
109
|
+
refreshed_dispute = Braintree::Dispute.find(dispute.id)
|
|
110
|
+
updated_storage = refreshed_dispute.remaining_file_evidence_storage
|
|
111
|
+
expect(updated_storage).to be < initial_storage
|
|
112
|
+
end
|
|
102
113
|
end
|
|
103
114
|
|
|
104
115
|
describe "self.add_text_evidence" do
|