braintree 4.27.0 → 4.28.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/apple_pay_card.rb +4 -0
- data/lib/braintree/bin_data.rb +7 -2
- data/lib/braintree/credit_card.rb +11 -5
- data/lib/braintree/credit_card_gateway.rb +1 -0
- data/lib/braintree/credit_card_verification_gateway.rb +1 -0
- data/lib/braintree/customer_session_gateway.rb +11 -10
- data/lib/braintree/google_pay_card.rb +4 -0
- data/lib/braintree/graphql/enums/recommendations.rb +2 -0
- data/lib/braintree/graphql/enums/recommended_payment_option.rb +2 -0
- data/lib/braintree/graphql/inputs/create_customer_session_input.rb +10 -1
- data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +7 -8
- data/lib/braintree/graphql/inputs/customer_session_input.rb +6 -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 +2 -0
- data/lib/braintree/graphql/inputs/update_customer_session_input.rb +5 -0
- data/lib/braintree/graphql/types/customer_recommendations_payload.rb +112 -18
- data/lib/braintree/graphql/types/payment_options.rb +2 -0
- data/lib/braintree/graphql/types/payment_recommendations.rb +35 -0
- data/lib/braintree/graphql/unions/customer_recommendations.rb +38 -25
- data/lib/braintree/meta_checkout_card.rb +8 -4
- data/lib/braintree/meta_checkout_token.rb +10 -6
- data/lib/braintree/payment_method_gateway.rb +3 -0
- data/lib/braintree/test/credit_card.rb +4 -0
- data/lib/braintree/transaction/apple_pay_details.rb +4 -0
- data/lib/braintree/transaction/credit_card_details.rb +8 -0
- data/lib/braintree/transaction/google_pay_details.rb +4 -0
- data/lib/braintree/transaction/meta_checkout_card_details.rb +9 -3
- data/lib/braintree/transaction/meta_checkout_token_details.rb +11 -5
- data/lib/braintree/transaction/visa_checkout_card_details.rb +8 -3
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +9 -4
- data/lib/braintree.rb +4 -0
- data/spec/integration/braintree/credit_card_spec.rb +101 -0
- data/spec/integration/braintree/credit_card_verification_spec.rb +118 -0
- data/spec/integration/braintree/customer_session_spec.rb +59 -49
- data/spec/integration/braintree/customer_spec.rb +71 -4
- data/spec/integration/braintree/payment_method_nonce_spec.rb +44 -0
- data/spec/integration/braintree/payment_method_spec.rb +47 -0
- data/spec/integration/braintree/transaction_spec.rb +61 -25
- data/spec/unit/braintree/apple_pay_card_spec.rb +4 -0
- data/spec/unit/braintree/credit_card_spec.rb +22 -2
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +1 -0
- data/spec/unit/braintree/customer_session_gateway_spec.rb +10 -9
- data/spec/unit/braintree/customer_spec.rb +2 -1
- data/spec/unit/braintree/google_pay_card_spec.rb +20 -0
- data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +25 -4
- data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +21 -51
- data/spec/unit/braintree/graphql/customer_recommendations_spec.rb +40 -0
- data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +21 -7
- data/spec/unit/braintree/meta_checkout_card_spec.rb +8 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +4 -0
- data/spec/unit/braintree/payment_method_nonce_spec.rb +9 -2
- data/spec/unit/braintree/payment_method_spec.rb +12 -0
- data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -1
- data/spec/unit/braintree/transaction/google_pay_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction_spec.rb +8 -0
- data/spec/unit/braintree/visa_checkout_card_spec.rb +20 -0
- data/spec/unit/credit_card_details_spec.rb +20 -0
- metadata +7 -2
@@ -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 => {
|
@@ -346,6 +368,102 @@ describe Braintree::CreditCardVerification, "search" do
|
|
346
368
|
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
347
369
|
expect(found_verification.credit_card[:prepaid_reloadable]).to eq(Braintree::CreditCard::PrepaidReloadable::Yes)
|
348
370
|
end
|
371
|
+
|
372
|
+
it "returns business on a business card" do
|
373
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
374
|
+
|
375
|
+
Braintree::Customer.create(
|
376
|
+
:credit_card => {
|
377
|
+
:cardholder_name => cardholder_name,
|
378
|
+
:expiration_date => "05/2012",
|
379
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Business,
|
380
|
+
:cvv => "200",
|
381
|
+
:options => {
|
382
|
+
:verify_card => true
|
383
|
+
}
|
384
|
+
})
|
385
|
+
|
386
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
387
|
+
search.credit_card_cardholder_name.is cardholder_name
|
388
|
+
end
|
389
|
+
|
390
|
+
verification_id = search_results.first.id
|
391
|
+
|
392
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
393
|
+
expect(found_verification.credit_card[:business]).to eq(Braintree::CreditCard::Business::Yes)
|
394
|
+
end
|
395
|
+
|
396
|
+
it "returns consumer on a consumer card" do
|
397
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
398
|
+
|
399
|
+
Braintree::Customer.create(
|
400
|
+
:credit_card => {
|
401
|
+
:cardholder_name => cardholder_name,
|
402
|
+
:expiration_date => "05/2012",
|
403
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Consumer,
|
404
|
+
:cvv => "200",
|
405
|
+
:options => {
|
406
|
+
:verify_card => true
|
407
|
+
}
|
408
|
+
})
|
409
|
+
|
410
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
411
|
+
search.credit_card_cardholder_name.is cardholder_name
|
412
|
+
end
|
413
|
+
|
414
|
+
verification_id = search_results.first.id
|
415
|
+
|
416
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
417
|
+
expect(found_verification.credit_card[:consumer]).to eq(Braintree::CreditCard::Consumer::Yes)
|
418
|
+
end
|
419
|
+
|
420
|
+
it "returns corporate on a corporate card" do
|
421
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
422
|
+
|
423
|
+
Braintree::Customer.create(
|
424
|
+
:credit_card => {
|
425
|
+
:cardholder_name => cardholder_name,
|
426
|
+
:expiration_date => "05/2012",
|
427
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Corporate,
|
428
|
+
:cvv => "200",
|
429
|
+
:options => {
|
430
|
+
:verify_card => true
|
431
|
+
}
|
432
|
+
})
|
433
|
+
|
434
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
435
|
+
search.credit_card_cardholder_name.is cardholder_name
|
436
|
+
end
|
437
|
+
|
438
|
+
verification_id = search_results.first.id
|
439
|
+
|
440
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
441
|
+
expect(found_verification.credit_card[:corporate]).to eq(Braintree::CreditCard::Corporate::Yes)
|
442
|
+
end
|
443
|
+
|
444
|
+
it "returns purchase on a purchase card" do
|
445
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
446
|
+
|
447
|
+
Braintree::Customer.create(
|
448
|
+
:credit_card => {
|
449
|
+
:cardholder_name => cardholder_name,
|
450
|
+
:expiration_date => "05/2012",
|
451
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Purchase,
|
452
|
+
:cvv => "200",
|
453
|
+
:options => {
|
454
|
+
:verify_card => true
|
455
|
+
}
|
456
|
+
})
|
457
|
+
|
458
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
459
|
+
search.credit_card_cardholder_name.is cardholder_name
|
460
|
+
end
|
461
|
+
|
462
|
+
verification_id = search_results.first.id
|
463
|
+
|
464
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
465
|
+
expect(found_verification.credit_card[:purchase]).to eq(Braintree::CreditCard::Purchase::Yes)
|
466
|
+
end
|
349
467
|
end
|
350
468
|
end
|
351
469
|
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
3
3
|
|
4
4
|
describe Braintree::CustomerSessionGateway do
|
5
|
-
let(:
|
5
|
+
let(:pwpp_gateway) do
|
6
6
|
Braintree::Gateway.new(
|
7
7
|
:environment => :development,
|
8
8
|
:merchant_id => "pwpp_multi_account_merchant",
|
@@ -13,37 +13,43 @@ describe Braintree::CustomerSessionGateway do
|
|
13
13
|
|
14
14
|
describe "create" do
|
15
15
|
it "can create customer session without email and phone" do
|
16
|
-
input = Braintree::CreateCustomerSessionInput.new(
|
17
|
-
|
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)
|
18
20
|
expect(result.success?).to eq(true)
|
19
21
|
expect(result.session_id).not_to be_nil
|
20
22
|
end
|
21
23
|
|
22
|
-
it "can
|
24
|
+
it "can create customer session with merchant provided session id" do
|
23
25
|
merchant_session_id = "11EF-A1E7-A5F5EE5C-A2E5-AFD2801469FC"
|
24
26
|
input = Braintree::CreateCustomerSessionInput.new(
|
25
27
|
session_id: merchant_session_id,
|
26
28
|
)
|
27
|
-
result =
|
29
|
+
result = pwpp_gateway.customer_session.create_customer_session(input)
|
28
30
|
expect(result.success?).to eq(true)
|
29
31
|
expect(result.session_id).to eq(merchant_session_id)
|
30
32
|
end
|
31
33
|
|
32
34
|
it "can create customer session with API-derived session id" do
|
33
|
-
|
34
|
-
result
|
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)
|
35
44
|
expect(result.success?).to eq(true)
|
36
45
|
expect(result.session_id).not_to be_nil
|
37
46
|
end
|
38
47
|
|
39
48
|
it "cannot create duplicate customer session" do
|
40
49
|
existing_session_id = "11EF-34BC-2702904B-9026-C3ECF4BAC765"
|
41
|
-
|
42
|
-
session_id: existing_session_id,
|
43
|
-
)
|
44
|
-
result = gateway.customer_session.create_customer_session(input)
|
50
|
+
result = build_customer_session(existing_session_id)
|
45
51
|
expect(result.success?).to eq(false)
|
46
|
-
expect(result.errors.first.message).to include("Session IDs must be unique per merchant
|
52
|
+
expect(result.errors.first.message).to include("Session IDs must be unique per merchant")
|
47
53
|
end
|
48
54
|
end
|
49
55
|
|
@@ -53,33 +59,29 @@ describe Braintree::CustomerSessionGateway do
|
|
53
59
|
create_input = Braintree::CreateCustomerSessionInput.new(
|
54
60
|
merchant_account_id: "usd_pwpp_multi_account_merchant_account",
|
55
61
|
session_id: session_id,
|
62
|
+
purchase_units: build_purchase_units,
|
56
63
|
)
|
64
|
+
pwpp_gateway.customer_session.create_customer_session(create_input)
|
57
65
|
|
58
|
-
|
59
|
-
|
60
|
-
customer = build_customer_session_input("PR5_test@example.com", "4085005005")
|
61
|
-
|
66
|
+
customer = build_customer_session_input
|
62
67
|
update_input = Braintree::UpdateCustomerSessionInput.new(
|
63
68
|
session_id: session_id,
|
64
69
|
customer: customer,
|
65
70
|
)
|
66
|
-
|
67
|
-
result = gateway.customer_session.update_customer_session(update_input)
|
71
|
+
result = pwpp_gateway.customer_session.update_customer_session(update_input)
|
68
72
|
|
69
73
|
expect(result.success?).to eq(true)
|
70
74
|
expect(result.session_id).to eq(session_id)
|
71
|
-
|
72
75
|
end
|
73
76
|
|
74
77
|
it "cannot update a non-existent customer session" do
|
75
78
|
session_id = "11EF-34BC-2702904B-9026-C3ECF4BAC765"
|
76
|
-
customer = build_customer_session_input
|
79
|
+
customer = build_customer_session_input
|
77
80
|
update_input = Braintree::UpdateCustomerSessionInput.new(
|
78
81
|
session_id: session_id,
|
79
82
|
customer: customer,
|
80
83
|
)
|
81
|
-
|
82
|
-
result = gateway.customer_session.update_customer_session(update_input)
|
84
|
+
result = pwpp_gateway.customer_session.update_customer_session(update_input)
|
83
85
|
|
84
86
|
expect(result.success?).to eq(false)
|
85
87
|
expect(result.errors.first.message).to include("does not exist")
|
@@ -88,56 +90,64 @@ describe Braintree::CustomerSessionGateway do
|
|
88
90
|
|
89
91
|
describe "customer recommendations" do
|
90
92
|
it "can get customer recommendations" do
|
91
|
-
customer = build_customer_session_input
|
92
|
-
recommendations = [Braintree::Recommendations::PAYMENT_RECOMMENDATIONS]
|
93
|
+
customer = build_customer_session_input
|
93
94
|
customer_recommendations_input = Braintree::CustomerRecommendationsInput.new(
|
94
|
-
session_id: "
|
95
|
-
recommendations: recommendations,
|
95
|
+
session_id: "94f0b2db-5323-4d86-add3-paypal000000",
|
96
96
|
customer: customer,
|
97
|
+
purchase_units: build_purchase_units,
|
98
|
+
domain: "domain.com",
|
97
99
|
)
|
98
|
-
|
100
|
+
|
101
|
+
result = pwpp_gateway.customer_session.get_customer_recommendations(customer_recommendations_input)
|
99
102
|
|
100
103
|
expect(result.success?).to eq(true)
|
101
104
|
payload = result.customer_recommendations
|
102
105
|
expect(payload.is_in_paypal_network).to eq(true)
|
103
|
-
|
104
|
-
|
105
|
-
expect(
|
106
|
+
|
107
|
+
recommendation = payload.recommendations.payment_recommendations[0]
|
108
|
+
expect(recommendation.payment_option).to eq(Braintree::RecommendedPaymentOption::PAYPAL)
|
109
|
+
expect(recommendation.recommended_priority).to eq(1)
|
106
110
|
end
|
107
111
|
|
108
|
-
it "
|
109
|
-
customer = build_customer_session_input
|
110
|
-
recommendations = [Braintree::Recommendations::PAYMENT_RECOMMENDATIONS]
|
112
|
+
it "raises an error when not authorized" do
|
113
|
+
customer = build_customer_session_input
|
111
114
|
customer_recommendations_input = Braintree::CustomerRecommendationsInput.new(
|
112
|
-
session_id: "
|
113
|
-
recommendations: recommendations,
|
115
|
+
session_id: "6B29FC40-CA47-1067-B31D-00DD010662DA",
|
114
116
|
customer: customer,
|
117
|
+
purchase_units: build_purchase_units,
|
118
|
+
domain: "domain.com",
|
119
|
+
merchant_account_id: "gbp_pwpp_multi_account_merchant_account",
|
115
120
|
)
|
116
|
-
result = gateway.customer_session.get_customer_recommendations(customer_recommendations_input)
|
117
121
|
|
118
|
-
expect
|
119
|
-
|
122
|
+
expect {
|
123
|
+
pwpp_gateway.customer_session.get_customer_recommendations(customer_recommendations_input)
|
124
|
+
}.to raise_error(Braintree::AuthorizationError)
|
120
125
|
end
|
121
126
|
end
|
122
127
|
|
123
128
|
private
|
124
129
|
|
125
130
|
def build_customer_session(session_id = nil)
|
126
|
-
customer = build_customer_session_input
|
131
|
+
customer = build_customer_session_input
|
132
|
+
input_attributes = {customer: customer}
|
133
|
+
input_attributes[:session_id] = session_id if session_id
|
127
134
|
|
128
|
-
input =
|
129
|
-
|
135
|
+
input = Braintree::CreateCustomerSessionInput.new(input_attributes)
|
136
|
+
pwpp_gateway.customer_session.create_customer_session(input)
|
130
137
|
end
|
131
138
|
|
132
|
-
def build_customer_session_input
|
139
|
+
def build_customer_session_input
|
133
140
|
{
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
venmo_app_installed: true,
|
139
|
-
user_agent: "Mozilla"
|
141
|
+
hashed_email: "48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08",
|
142
|
+
hashed_phone_number: "a2df2987b2a3384210d3aa1c9fb8b627ebdae1f5a9097766c19ca30ec4360176",
|
143
|
+
device_fingerprint_id: "00DD010662DE",
|
144
|
+
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",
|
140
145
|
}
|
141
146
|
end
|
142
147
|
|
143
|
-
|
148
|
+
def build_purchase_units
|
149
|
+
amount = {currency_code: "USD", value: "10.00"}
|
150
|
+
purchase_unit = {amount: amount}
|
151
|
+
[purchase_unit]
|
152
|
+
end
|
153
|
+
end
|
@@ -991,7 +991,10 @@ describe Braintree::Customer do
|
|
991
991
|
expect(found_customer.apple_pay_cards).not_to be_nil
|
992
992
|
apple_pay_card = found_customer.apple_pay_cards.first
|
993
993
|
expect(apple_pay_card).to be_a Braintree::ApplePayCard
|
994
|
+
expect(apple_pay_card.business).not_to be_nil
|
994
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
|
995
998
|
expect(apple_pay_card.country_of_issuance).not_to be_nil
|
996
999
|
expect(apple_pay_card.debit).not_to be_nil
|
997
1000
|
expect(apple_pay_card.durbin_regulated).not_to be_nil
|
@@ -1003,6 +1006,7 @@ describe Braintree::Customer do
|
|
1003
1006
|
expect(apple_pay_card.prepaid).not_to be_nil
|
1004
1007
|
expect(apple_pay_card.prepaid_reloadable).not_to be_nil
|
1005
1008
|
expect(apple_pay_card.product_id).not_to be_nil
|
1009
|
+
expect(apple_pay_card.purchase).not_to be_nil
|
1006
1010
|
expect(apple_pay_card.token).not_to be_nil
|
1007
1011
|
end
|
1008
1012
|
|
@@ -1017,7 +1021,10 @@ describe Braintree::Customer do
|
|
1017
1021
|
expect(found_customer.payment_methods.size).to eq(1)
|
1018
1022
|
google_pay_card = found_customer.google_pay_cards.first
|
1019
1023
|
expect(google_pay_card).to be_a Braintree::GooglePayCard
|
1024
|
+
expect(google_pay_card.business).not_to be_nil
|
1020
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
|
1021
1028
|
expect(google_pay_card.country_of_issuance).not_to be_nil
|
1022
1029
|
expect(google_pay_card.debit).not_to be_nil
|
1023
1030
|
expect(google_pay_card.durbin_regulated).not_to be_nil
|
@@ -1029,6 +1036,7 @@ describe Braintree::Customer do
|
|
1029
1036
|
expect(google_pay_card.prepaid).not_to be_nil
|
1030
1037
|
expect(google_pay_card.prepaid_reloadable).not_to be_nil
|
1031
1038
|
expect(google_pay_card.product_id).not_to be_nil
|
1039
|
+
expect(google_pay_card.purchase).not_to be_nil
|
1032
1040
|
expect(google_pay_card.token).not_to be_nil
|
1033
1041
|
end
|
1034
1042
|
|
@@ -1043,19 +1051,23 @@ describe Braintree::Customer do
|
|
1043
1051
|
expect(found_customer.payment_methods.size).to eq(1)
|
1044
1052
|
google_pay_card = found_customer.google_pay_cards.first
|
1045
1053
|
expect(google_pay_card).to be_a Braintree::GooglePayCard
|
1046
|
-
expect(google_pay_card.
|
1047
|
-
expect(google_pay_card.expiration_year).not_to be_nil
|
1048
|
-
expect(google_pay_card.is_network_tokenized?).to eq(true)
|
1054
|
+
expect(google_pay_card.business).not_to be_nil
|
1049
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
|
1050
1058
|
expect(google_pay_card.country_of_issuance).not_to be_nil
|
1051
1059
|
expect(google_pay_card.debit).not_to be_nil
|
1052
1060
|
expect(google_pay_card.durbin_regulated).not_to be_nil
|
1061
|
+
expect(google_pay_card.expiration_year).not_to be_nil
|
1053
1062
|
expect(google_pay_card.healthcare).not_to be_nil
|
1063
|
+
expect(google_pay_card.is_network_tokenized?).to eq(true)
|
1054
1064
|
expect(google_pay_card.issuing_bank).not_to be_nil
|
1055
1065
|
expect(google_pay_card.payroll).not_to be_nil
|
1056
1066
|
expect(google_pay_card.prepaid).not_to be_nil
|
1057
1067
|
expect(google_pay_card.prepaid_reloadable).not_to be_nil
|
1058
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
|
1059
1071
|
end
|
1060
1072
|
|
1061
1073
|
it "returns associated venmo accounts" do
|
@@ -1750,6 +1762,57 @@ describe Braintree::Customer do
|
|
1750
1762
|
end
|
1751
1763
|
end
|
1752
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
|
+
|
1753
1816
|
describe "paypal" do
|
1754
1817
|
context "future" do
|
1755
1818
|
it "creates a customer with a future paypal account" do
|
@@ -1916,7 +1979,7 @@ describe Braintree::Customer do
|
|
1916
1979
|
end
|
1917
1980
|
end
|
1918
1981
|
|
1919
|
-
it "returns
|
1982
|
+
it "returns bin fields from VisaCheckoutCard" do
|
1920
1983
|
result = Braintree::Customer.create(
|
1921
1984
|
:payment_method_nonce => Braintree::Test::Nonce::VisaCheckoutVisa,
|
1922
1985
|
)
|
@@ -1926,6 +1989,10 @@ describe Braintree::Customer do
|
|
1926
1989
|
expect(found_customer.visa_checkout_cards).not_to be_nil
|
1927
1990
|
visa_checkout_card = found_customer.visa_checkout_cards.first
|
1928
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
|
1929
1995
|
expect(visa_checkout_card.prepaid_reloadable).not_to be_nil
|
1996
|
+
expect(visa_checkout_card.purchase).not_to be_nil
|
1930
1997
|
end
|
1931
1998
|
end
|
@@ -148,6 +148,16 @@ describe Braintree::PaymentMethodNonce do
|
|
148
148
|
expect(nonce.details.bin).to eq("401288")
|
149
149
|
end
|
150
150
|
|
151
|
+
it "returns bin_data with business set to Yes" do
|
152
|
+
result = Braintree::PaymentMethodNonce.find("fake-valid-business-nonce")
|
153
|
+
|
154
|
+
nonce = result.payment_method_nonce
|
155
|
+
|
156
|
+
expect(result).to be_success
|
157
|
+
expect(nonce.bin_data).not_to be_nil
|
158
|
+
expect(nonce.bin_data.business).to eq(Braintree::CreditCard::Business::Yes)
|
159
|
+
end
|
160
|
+
|
151
161
|
it "returns bin_data with commercial set to Yes" do
|
152
162
|
result = Braintree::PaymentMethodNonce.find("fake-valid-commercial-nonce")
|
153
163
|
|
@@ -158,6 +168,26 @@ describe Braintree::PaymentMethodNonce do
|
|
158
168
|
expect(nonce.bin_data.commercial).to eq(Braintree::CreditCard::Commercial::Yes)
|
159
169
|
end
|
160
170
|
|
171
|
+
it "returns bin_data with consumer set to Yes" do
|
172
|
+
result = Braintree::PaymentMethodNonce.find("fake-valid-consumer-nonce")
|
173
|
+
|
174
|
+
nonce = result.payment_method_nonce
|
175
|
+
|
176
|
+
expect(result).to be_success
|
177
|
+
expect(nonce.bin_data).not_to be_nil
|
178
|
+
expect(nonce.bin_data.consumer).to eq(Braintree::CreditCard::Consumer::Yes)
|
179
|
+
end
|
180
|
+
|
181
|
+
it "returns bin_data with corporate set to Yes" do
|
182
|
+
result = Braintree::PaymentMethodNonce.find("fake-valid-corporate-nonce")
|
183
|
+
|
184
|
+
nonce = result.payment_method_nonce
|
185
|
+
|
186
|
+
expect(result).to be_success
|
187
|
+
expect(nonce.bin_data).not_to be_nil
|
188
|
+
expect(nonce.bin_data.corporate).to eq(Braintree::CreditCard::Corporate::Yes)
|
189
|
+
end
|
190
|
+
|
161
191
|
it "returns bin_data with country_of_issuance set to CAN" do
|
162
192
|
result = Braintree::PaymentMethodNonce.find("fake-valid-country-of-issuance-cad-nonce")
|
163
193
|
|
@@ -240,6 +270,16 @@ describe Braintree::PaymentMethodNonce do
|
|
240
270
|
expect(nonce.bin_data.prepaid_reloadable).to eq(Braintree::CreditCard::PrepaidReloadable::Yes)
|
241
271
|
end
|
242
272
|
|
273
|
+
it "returns bin_data with purchase set to Yes" do
|
274
|
+
result = Braintree::PaymentMethodNonce.find("fake-valid-purchase-nonce")
|
275
|
+
|
276
|
+
nonce = result.payment_method_nonce
|
277
|
+
|
278
|
+
expect(result).to be_success
|
279
|
+
expect(nonce.bin_data).not_to be_nil
|
280
|
+
expect(nonce.bin_data.purchase).to eq(Braintree::CreditCard::Purchase::Yes)
|
281
|
+
end
|
282
|
+
|
243
283
|
it "returns bin_data with unknown indicators" do
|
244
284
|
result = Braintree::PaymentMethodNonce.find("fake-valid-unknown-indicators-nonce")
|
245
285
|
|
@@ -247,7 +287,10 @@ describe Braintree::PaymentMethodNonce do
|
|
247
287
|
|
248
288
|
expect(result).to be_success
|
249
289
|
expect(nonce.bin_data).not_to be_nil
|
290
|
+
expect(nonce.bin_data.business).to eq(Braintree::CreditCard::Business::Unknown)
|
250
291
|
expect(nonce.bin_data.commercial).to eq(Braintree::CreditCard::Commercial::Unknown)
|
292
|
+
expect(nonce.bin_data.consumer).to eq(Braintree::CreditCard::Consumer::Unknown)
|
293
|
+
expect(nonce.bin_data.corporate).to eq(Braintree::CreditCard::Corporate::Unknown)
|
251
294
|
expect(nonce.bin_data.country_of_issuance).to eq(Braintree::CreditCard::CountryOfIssuance::Unknown)
|
252
295
|
expect(nonce.bin_data.debit).to eq(Braintree::CreditCard::Debit::Unknown)
|
253
296
|
expect(nonce.bin_data.durbin_regulated).to eq(Braintree::CreditCard::DurbinRegulated::Unknown)
|
@@ -257,6 +300,7 @@ describe Braintree::PaymentMethodNonce do
|
|
257
300
|
expect(nonce.bin_data.prepaid).to eq(Braintree::CreditCard::Prepaid::Unknown)
|
258
301
|
expect(nonce.bin_data.prepaid_reloadable).to eq(Braintree::CreditCard::PrepaidReloadable::Unknown)
|
259
302
|
expect(nonce.bin_data.product_id).to eq(Braintree::CreditCard::ProductId::Unknown)
|
303
|
+
expect(nonce.bin_data.purchase).to eq(Braintree::CreditCard::Purchase::Unknown)
|
260
304
|
end
|
261
305
|
|
262
306
|
it "correctly raises and exception for a non existent token" do
|
@@ -671,6 +671,30 @@ describe Braintree::PaymentMethod do
|
|
671
671
|
end
|
672
672
|
end
|
673
673
|
|
674
|
+
it "includes ani response when account information inquiry is sent in options" do
|
675
|
+
customer = Braintree::Customer.create!
|
676
|
+
nonce = nonce_for_new_payment_method(
|
677
|
+
:credit_card => {
|
678
|
+
:cvv => "123",
|
679
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
680
|
+
:expiration_date => "05/2029",
|
681
|
+
},
|
682
|
+
)
|
683
|
+
result = Braintree::PaymentMethod.create(
|
684
|
+
:payment_method_nonce => nonce,
|
685
|
+
:customer_id => customer.id,
|
686
|
+
:options => {
|
687
|
+
:verify_card => true,
|
688
|
+
:account_information_inquiry => "send_data",
|
689
|
+
},
|
690
|
+
)
|
691
|
+
|
692
|
+
expect(result).to be_success
|
693
|
+
verification = result.payment_method.verification
|
694
|
+
expect(verification.ani_first_name_response_code).not_to be_nil
|
695
|
+
expect(verification.ani_last_name_response_code).not_to be_nil
|
696
|
+
end
|
697
|
+
|
674
698
|
context "account_type" do
|
675
699
|
it "verifies card with account_type debit" do
|
676
700
|
nonce = nonce_for_new_payment_method(
|
@@ -1588,6 +1612,29 @@ describe Braintree::PaymentMethod do
|
|
1588
1612
|
end
|
1589
1613
|
end
|
1590
1614
|
|
1615
|
+
it "includes ani response after updating the options with account information inquiry" do
|
1616
|
+
customer = Braintree::Customer.create!
|
1617
|
+
credit_card = Braintree::CreditCard.create!(
|
1618
|
+
:customer_id => customer.id,
|
1619
|
+
:cvv => "123",
|
1620
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1621
|
+
:expiration_date => "05/2032",
|
1622
|
+
)
|
1623
|
+
update_result = Braintree::PaymentMethod.update(
|
1624
|
+
credit_card.token,
|
1625
|
+
:options => {
|
1626
|
+
:verify_card => true,
|
1627
|
+
:account_information_inquiry => "send_data",
|
1628
|
+
},
|
1629
|
+
)
|
1630
|
+
|
1631
|
+
expect(update_result).to be_success
|
1632
|
+
verification = update_result.payment_method.verification
|
1633
|
+
expect(verification.ani_first_name_response_code).not_to be_nil
|
1634
|
+
expect(verification.ani_last_name_response_code).not_to be_nil
|
1635
|
+
end
|
1636
|
+
|
1637
|
+
|
1591
1638
|
context "verification_currency_iso_code" do
|
1592
1639
|
it "validates verification_currency_iso_code and updates the credit card " do
|
1593
1640
|
customer = Braintree::Customer.create!
|