braintree 4.15.0 → 4.17.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/account_updater_daily_report.rb +3 -3
- data/lib/braintree/ach_mandate.rb +1 -1
- data/lib/braintree/add_on_gateway.rb +1 -1
- data/lib/braintree/address.rb +4 -4
- data/lib/braintree/address_gateway.rb +5 -5
- data/lib/braintree/advanced_search.rb +10 -10
- data/lib/braintree/apple_pay.rb +3 -3
- data/lib/braintree/apple_pay_card.rb +3 -3
- data/lib/braintree/apple_pay_options.rb +3 -3
- data/lib/braintree/authorization_adjustment.rb +3 -3
- data/lib/braintree/base_module.rb +1 -1
- data/lib/braintree/bin_data.rb +2 -2
- data/lib/braintree/client_token_gateway.rb +1 -1
- data/lib/braintree/configuration.rb +22 -22
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
- data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
- data/lib/braintree/credit_card.rb +9 -9
- data/lib/braintree/credit_card_gateway.rb +8 -8
- data/lib/braintree/credit_card_verification.rb +3 -3
- data/lib/braintree/credit_card_verification_gateway.rb +28 -11
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +5 -9
- data/lib/braintree/customer_gateway.rb +7 -7
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/descriptor.rb +1 -1
- data/lib/braintree/digest.rb +1 -1
- data/lib/braintree/disbursement.rb +5 -5
- data/lib/braintree/discount_gateway.rb +1 -1
- data/lib/braintree/dispute/evidence.rb +1 -1
- data/lib/braintree/dispute/paypal_message.rb +1 -1
- data/lib/braintree/dispute/status_history.rb +1 -1
- data/lib/braintree/dispute/transaction.rb +1 -1
- data/lib/braintree/dispute/transaction_details.rb +1 -1
- data/lib/braintree/dispute.rb +3 -3
- data/lib/braintree/dispute_gateway.rb +1 -1
- data/lib/braintree/dispute_search.rb +1 -1
- data/lib/braintree/document_upload.rb +2 -2
- data/lib/braintree/document_upload_gateway.rb +3 -3
- data/lib/braintree/enriched_customer_data.rb +2 -2
- data/lib/braintree/error_result.rb +2 -3
- data/lib/braintree/errors.rb +3 -3
- data/lib/braintree/exceptions.rb +1 -2
- data/lib/braintree/exchange_rate.rb +2 -2
- data/lib/braintree/exchange_rate_quote.rb +3 -3
- data/lib/braintree/exchange_rate_quote_gateway.rb +1 -1
- data/lib/braintree/exchange_rate_quote_input.rb +3 -3
- data/lib/braintree/exchange_rate_quote_request.rb +3 -3
- data/lib/braintree/exchange_rate_quote_response.rb +3 -3
- data/lib/braintree/facilitated_details.rb +1 -1
- data/lib/braintree/facilitator_details.rb +1 -1
- data/lib/braintree/google_pay_card.rb +3 -3
- data/lib/braintree/granted_payment_instrument_update.rb +1 -1
- data/lib/braintree/graphql_client.rb +1 -1
- data/lib/braintree/http.rb +5 -5
- data/lib/braintree/local_payment_completed.rb +2 -2
- data/lib/braintree/local_payment_expired.rb +2 -2
- data/lib/braintree/local_payment_funded.rb +2 -2
- data/lib/braintree/local_payment_reversed.rb +2 -2
- data/lib/braintree/merchant.rb +3 -3
- data/lib/braintree/merchant_account.rb +2 -2
- data/lib/braintree/merchant_account_gateway.rb +9 -9
- data/lib/braintree/meta_checkout_card.rb +89 -0
- data/lib/braintree/meta_checkout_token.rb +88 -0
- data/lib/braintree/modification.rb +3 -3
- data/lib/braintree/oauth_credentials.rb +3 -3
- data/lib/braintree/paginated_collection.rb +2 -2
- data/lib/braintree/paginated_result.rb +1 -1
- data/lib/braintree/payment_instrument_type.rb +2 -0
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +2 -2
- data/lib/braintree/payment_method_gateway.rb +8 -7
- data/lib/braintree/payment_method_nonce.rb +4 -4
- data/lib/braintree/payment_method_nonce_details.rb +1 -1
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +1 -1
- data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
- data/lib/braintree/paypal_account.rb +1 -2
- data/lib/braintree/paypal_account_gateway.rb +5 -5
- data/lib/braintree/plan.rb +1 -1
- data/lib/braintree/plan_gateway.rb +2 -2
- data/lib/braintree/resource_collection.rb +2 -2
- data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
- data/lib/braintree/risk_data.rb +1 -1
- data/lib/braintree/samsung_pay_card.rb +5 -5
- data/lib/braintree/sepa_direct_debit_account.rb +2 -2
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +1 -1
- data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
- data/lib/braintree/sha256_digest.rb +1 -1
- data/lib/braintree/subscription/status_details.rb +1 -1
- data/lib/braintree/subscription.rb +2 -2
- data/lib/braintree/subscription_gateway.rb +6 -6
- data/lib/braintree/subscription_search.rb +1 -1
- data/lib/braintree/successful_result.rb +2 -2
- data/lib/braintree/test/credit_card.rb +7 -10
- data/lib/braintree/test/merchant_account.rb +1 -1
- data/lib/braintree/test/nonce.rb +3 -0
- data/lib/braintree/test/transaction_amounts.rb +2 -3
- data/lib/braintree/testing_gateway.rb +1 -1
- data/lib/braintree/three_d_secure_info.rb +1 -1
- data/lib/braintree/transaction/address_details.rb +2 -1
- data/lib/braintree/transaction/credit_card_details.rb +1 -1
- data/lib/braintree/transaction/customer_details.rb +1 -1
- data/lib/braintree/transaction/disbursement_details.rb +1 -1
- data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
- data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -0
- data/lib/braintree/transaction/samsung_pay_card_details.rb +1 -1
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +1 -1
- data/lib/braintree/transaction/status_details.rb +1 -1
- data/lib/braintree/transaction/subscription_details.rb +1 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +1 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
- data/lib/braintree/transaction.rb +22 -16
- data/lib/braintree/transaction_gateway.rb +9 -10
- data/lib/braintree/transaction_line_item.rb +2 -2
- data/lib/braintree/transaction_line_item_gateway.rb +1 -1
- data/lib/braintree/transaction_review.rb +1 -1
- data/lib/braintree/transaction_search.rb +1 -1
- data/lib/braintree/unknown_payment_method.rb +1 -1
- data/lib/braintree/us_bank_account.rb +2 -2
- data/lib/braintree/us_bank_account_verification.rb +23 -15
- data/lib/braintree/us_bank_account_verification_search.rb +1 -1
- data/lib/braintree/util.rb +3 -3
- data/lib/braintree/validation_error.rb +1 -1
- data/lib/braintree/validation_error_collection.rb +3 -3
- data/lib/braintree/venmo_account.rb +3 -3
- data/lib/braintree/venmo_profile_data.rb +6 -4
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +7 -7
- data/lib/braintree/webhook_notification.rb +2 -2
- data/lib/braintree/webhook_notification_gateway.rb +4 -4
- data/lib/braintree/webhook_testing.rb +1 -1
- data/lib/braintree/webhook_testing_gateway.rb +1 -1
- data/lib/braintree/xml/generator.rb +1 -1
- data/lib/braintree/xml/libxml.rb +1 -1
- data/lib/braintree/xml/parser.rb +3 -3
- data/lib/braintree/xml/rexml.rb +2 -2
- data/lib/braintree/xml.rb +1 -1
- data/lib/braintree.rb +4 -1
- data/spec/integration/braintree/client_api/spec_helper.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +45 -0
- data/spec/integration/braintree/dispute_search_spec.rb +0 -1
- data/spec/integration/braintree/payment_method_nonce_spec.rb +20 -0
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +72 -0
- data/spec/integration/braintree/transaction_search_spec.rb +27 -0
- data/spec/integration/braintree/transaction_spec.rb +192 -66
- data/spec/unit/braintree/base_module_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +13 -8
- data/spec/unit/braintree/enriched_customer_data_spec.rb +9 -0
- data/spec/unit/braintree/http_spec.rb +1 -1
- data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
- data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +30 -1
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +5 -0
- data/spec/unit/braintree/venmo_profile_data_spec.rb +11 -0
- metadata +10 -2
@@ -78,6 +78,78 @@ describe Braintree::PaymentMethod do
|
|
78
78
|
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
79
79
|
end
|
80
80
|
end
|
81
|
+
|
82
|
+
it "succeeds and verifies with verification_add_ons for NetworkCheck with fake nonce" do
|
83
|
+
customer = Braintree::Customer.create.customer
|
84
|
+
result = Braintree::PaymentMethod.create(
|
85
|
+
:payment_method_nonce => Braintree::Test::Nonce::UsBankAccount,
|
86
|
+
:customer_id => customer.id,
|
87
|
+
:options => {
|
88
|
+
:us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
89
|
+
:verification_add_ons => Braintree::UsBankAccountVerification::VerificationAddOns::CustomerVerification,
|
90
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
91
|
+
},
|
92
|
+
)
|
93
|
+
|
94
|
+
expect(result).to be_success
|
95
|
+
us_bank_account = result.payment_method
|
96
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
97
|
+
expect(us_bank_account.routing_number).to eq("123456789")
|
98
|
+
expect(us_bank_account.last_4).to eq("0000")
|
99
|
+
expect(us_bank_account.account_type).to eq("checking")
|
100
|
+
expect(us_bank_account.account_holder_name).to eq("Dan Schulman")
|
101
|
+
expect(us_bank_account.bank_name).to match(/Wells Fargo/)
|
102
|
+
expect(us_bank_account.default).to eq(true)
|
103
|
+
expect(us_bank_account.ach_mandate.text).to eq("example mandate text")
|
104
|
+
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
105
|
+
|
106
|
+
expect(us_bank_account.verifications.count).to eq(1)
|
107
|
+
expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::Verified)
|
108
|
+
expect(us_bank_account.verifications.first.verification_method).to eq(Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck)
|
109
|
+
expect(us_bank_account.verifications.first.id).not_to be_empty
|
110
|
+
expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time
|
111
|
+
expect(us_bank_account.verifications.first.processor_response_code).to eq("1000")
|
112
|
+
expect(us_bank_account.verified).to eq(true)
|
113
|
+
|
114
|
+
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "returns additional processor response for failed NetworkCheck" do
|
118
|
+
customer = Braintree::Customer.create.customer
|
119
|
+
invalid_nonce = generate_non_plaid_us_bank_account_nonce(account_number = "1000000005")
|
120
|
+
result = Braintree::PaymentMethod.create(
|
121
|
+
:payment_method_nonce => invalid_nonce,
|
122
|
+
:customer_id => customer.id,
|
123
|
+
:options => {
|
124
|
+
:us_bank_account_verification_method => Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
|
125
|
+
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
|
126
|
+
},
|
127
|
+
)
|
128
|
+
|
129
|
+
expect(result).to be_success
|
130
|
+
us_bank_account = result.payment_method
|
131
|
+
expect(us_bank_account).to be_a(Braintree::UsBankAccount)
|
132
|
+
expect(us_bank_account.routing_number).to eq("021000021")
|
133
|
+
expect(us_bank_account.last_4).to eq("0005")
|
134
|
+
expect(us_bank_account.account_type).to eq("checking")
|
135
|
+
expect(us_bank_account.account_holder_name).to eq("John Doe")
|
136
|
+
expect(us_bank_account.bank_name).to match(/CHASE/)
|
137
|
+
expect(us_bank_account.default).to eq(true)
|
138
|
+
expect(us_bank_account.ach_mandate.text).to eq("cl mandate text")
|
139
|
+
expect(us_bank_account.ach_mandate.accepted_at).to be_a Time
|
140
|
+
|
141
|
+
expect(us_bank_account.verifications.count).to eq(1)
|
142
|
+
expect(us_bank_account.verifications.first.status).to eq(Braintree::UsBankAccountVerification::Status::ProcessorDeclined)
|
143
|
+
expect(us_bank_account.verifications.first.verification_method).to eq(Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck)
|
144
|
+
expect(us_bank_account.verifications.first.id).not_to be_empty
|
145
|
+
expect(us_bank_account.verifications.first.verification_determined_at).to be_a Time
|
146
|
+
expect(us_bank_account.verifications.first.processor_response_code).to eq("2061")
|
147
|
+
expect(us_bank_account.verifications.first.additional_processor_response).to eq("Invalid routing number")
|
148
|
+
|
149
|
+
expect(us_bank_account.verified).to eq(false)
|
150
|
+
|
151
|
+
expect(Braintree::PaymentMethod.find(us_bank_account.token)).to be_a(Braintree::UsBankAccount)
|
152
|
+
end
|
81
153
|
end
|
82
154
|
|
83
155
|
it "fails with invalid nonce" do
|
@@ -1494,6 +1494,33 @@ describe Braintree::Transaction, "search" do
|
|
1494
1494
|
}.to raise_error(Braintree::UnexpectedError)
|
1495
1495
|
end
|
1496
1496
|
end
|
1497
|
+
|
1498
|
+
it "searches by payment instrument type meta checkout" do
|
1499
|
+
meta_checkout_card_transaction = Braintree::Transaction.sale!(
|
1500
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1501
|
+
:options => {
|
1502
|
+
:submit_for_settlement => true
|
1503
|
+
},
|
1504
|
+
:payment_method_nonce => Braintree::Test::Nonce::MetaCheckoutCard,
|
1505
|
+
)
|
1506
|
+
|
1507
|
+
meta_checkout_token_transaction = Braintree::Transaction.sale!(
|
1508
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
1509
|
+
:options => {
|
1510
|
+
:submit_for_settlement => true
|
1511
|
+
},
|
1512
|
+
:payment_method_nonce => Braintree::Test::Nonce::MetaCheckoutToken,
|
1513
|
+
)
|
1514
|
+
|
1515
|
+
collection = Braintree::Transaction.search do |search|
|
1516
|
+
search.payment_instrument_type.in ["MetaCheckout"]
|
1517
|
+
end
|
1518
|
+
|
1519
|
+
collection.maximum_size.should == 2
|
1520
|
+
txn_ids = collection.map(&:id)
|
1521
|
+
expect(txn_ids).to include(meta_checkout_card_transaction.id)
|
1522
|
+
expect(txn_ids).to include(meta_checkout_token_transaction.id)
|
1523
|
+
end
|
1497
1524
|
end
|
1498
1525
|
|
1499
1526
|
context "pagination" do
|
@@ -2,6 +2,72 @@ 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::Transaction do
|
5
|
+
let(:industry_data_flight_params) do
|
6
|
+
{
|
7
|
+
:industry => {
|
8
|
+
:industry_type => Braintree::Transaction::IndustryType::TravelAndFlight,
|
9
|
+
:data => {
|
10
|
+
:country_code => "US",
|
11
|
+
:date_of_birth => "2012-12-12",
|
12
|
+
:passenger_first_name => "John",
|
13
|
+
:passenger_last_name => "Doe",
|
14
|
+
:passenger_middle_initial => "M",
|
15
|
+
:passenger_title => "Mr.",
|
16
|
+
:issued_date => Date.new(2018, 1, 1),
|
17
|
+
:travel_agency_name => "Expedia",
|
18
|
+
:travel_agency_code => "12345678",
|
19
|
+
:ticket_number => "ticket-number",
|
20
|
+
:issuing_carrier_code => "AA",
|
21
|
+
:customer_code => "customer-code",
|
22
|
+
:fare_amount => 70_00,
|
23
|
+
:fee_amount => 10_00,
|
24
|
+
:tax_amount => 20_00,
|
25
|
+
:restricted_ticket => false,
|
26
|
+
:legs => [
|
27
|
+
{
|
28
|
+
:conjunction_ticket => "CJ0001",
|
29
|
+
:exchange_ticket => "ET0001",
|
30
|
+
:coupon_number => "1",
|
31
|
+
:service_class => "Y",
|
32
|
+
:carrier_code => "AA",
|
33
|
+
:fare_basis_code => "W",
|
34
|
+
:flight_number => "AA100",
|
35
|
+
:departure_date => Date.new(2018, 1, 2),
|
36
|
+
:departure_airport_code => "MDW",
|
37
|
+
:departure_time => "08:00",
|
38
|
+
:arrival_airport_code => "ATX",
|
39
|
+
:arrival_time => "10:00",
|
40
|
+
:stopover_permitted => false,
|
41
|
+
:fare_amount => 35_00,
|
42
|
+
:fee_amount => 5_00,
|
43
|
+
:tax_amount => 10_00,
|
44
|
+
:endorsement_or_restrictions => "NOT REFUNDABLE"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
:conjunction_ticket => "CJ0002",
|
48
|
+
:exchange_ticket => "ET0002",
|
49
|
+
:coupon_number => "1",
|
50
|
+
:service_class => "Y",
|
51
|
+
:carrier_code => "AA",
|
52
|
+
:fare_basis_code => "W",
|
53
|
+
:flight_number => "AA200",
|
54
|
+
:departure_date => Date.new(2018, 1, 3),
|
55
|
+
:departure_airport_code => "ATX",
|
56
|
+
:departure_time => "12:00",
|
57
|
+
:arrival_airport_code => "MDW",
|
58
|
+
:arrival_time => "14:00",
|
59
|
+
:stopover_permitted => false,
|
60
|
+
:fare_amount => 35_00,
|
61
|
+
:fee_amount => 5_00,
|
62
|
+
:tax_amount => 10_00,
|
63
|
+
:endorsement_or_restrictions => "NOT REFUNDABLE"
|
64
|
+
}
|
65
|
+
]
|
66
|
+
}
|
67
|
+
},
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
5
71
|
describe "self.clone_transaction" do
|
6
72
|
it "creates a new transaction from the card of the transaction to clone" do
|
7
73
|
result = Braintree::Transaction.sale(
|
@@ -306,8 +372,8 @@ describe Braintree::Transaction do
|
|
306
372
|
check_out_date_must_follow_check_in_date = Braintree::ErrorCodes::Transaction::Industry::Lodging::CheckOutDateMustFollowCheckInDate
|
307
373
|
room_rate_format_is_invalid = Braintree::ErrorCodes::Transaction::Industry::Lodging::RoomRateFormatIsInvalid
|
308
374
|
invalid_additional_charge_kind = Braintree::ErrorCodes::Transaction::Industry::AdditionalCharge::KindIsInvalid
|
309
|
-
expect(result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort).to include(
|
310
|
-
expect(result.errors.for(:transaction).for(:industry).for(:additional_charges).for(:index_0).on(:kind).map { |e| e.code }.sort).to include(
|
375
|
+
expect(result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort).to include(invalid_folio, check_out_date_must_follow_check_in_date, room_rate_format_is_invalid)
|
376
|
+
expect(result.errors.for(:transaction).for(:industry).for(:additional_charges).for(:index_0).on(:kind).map { |e| e.code }.sort).to include(invalid_additional_charge_kind)
|
311
377
|
end
|
312
378
|
end
|
313
379
|
|
@@ -356,74 +422,18 @@ describe Braintree::Transaction do
|
|
356
422
|
|
357
423
|
context "for travel flight" do
|
358
424
|
it "accepts valid industry data" do
|
359
|
-
|
425
|
+
params = {
|
360
426
|
:type => "sale",
|
361
427
|
:amount => 1_00,
|
362
428
|
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
363
429
|
:options => {
|
364
430
|
:submit_for_settlement => true
|
365
431
|
},
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
:passenger_middle_initial => "M",
|
372
|
-
:passenger_title => "Mr.",
|
373
|
-
:issued_date => Date.new(2018, 1, 1),
|
374
|
-
:travel_agency_name => "Expedia",
|
375
|
-
:travel_agency_code => "12345678",
|
376
|
-
:ticket_number => "ticket-number",
|
377
|
-
:issuing_carrier_code => "AA",
|
378
|
-
:customer_code => "customer-code",
|
379
|
-
:fare_amount => 70_00,
|
380
|
-
:fee_amount => 10_00,
|
381
|
-
:tax_amount => 20_00,
|
382
|
-
:restricted_ticket => false,
|
383
|
-
:legs => [
|
384
|
-
{
|
385
|
-
:conjunction_ticket => "CJ0001",
|
386
|
-
:exchange_ticket => "ET0001",
|
387
|
-
:coupon_number => "1",
|
388
|
-
:service_class => "Y",
|
389
|
-
:carrier_code => "AA",
|
390
|
-
:fare_basis_code => "W",
|
391
|
-
:flight_number => "AA100",
|
392
|
-
:departure_date => Date.new(2018, 1, 2),
|
393
|
-
:departure_airport_code => "MDW",
|
394
|
-
:departure_time => "08:00",
|
395
|
-
:arrival_airport_code => "ATX",
|
396
|
-
:arrival_time => "10:00",
|
397
|
-
:stopover_permitted => false,
|
398
|
-
:fare_amount => 35_00,
|
399
|
-
:fee_amount => 5_00,
|
400
|
-
:tax_amount => 10_00,
|
401
|
-
:endorsement_or_restrictions => "NOT REFUNDABLE"
|
402
|
-
},
|
403
|
-
{
|
404
|
-
:conjunction_ticket => "CJ0002",
|
405
|
-
:exchange_ticket => "ET0002",
|
406
|
-
:coupon_number => "1",
|
407
|
-
:service_class => "Y",
|
408
|
-
:carrier_code => "AA",
|
409
|
-
:fare_basis_code => "W",
|
410
|
-
:flight_number => "AA200",
|
411
|
-
:departure_date => Date.new(2018, 1, 3),
|
412
|
-
:departure_airport_code => "ATX",
|
413
|
-
:departure_time => "12:00",
|
414
|
-
:arrival_airport_code => "MDW",
|
415
|
-
:arrival_time => "14:00",
|
416
|
-
:stopover_permitted => false,
|
417
|
-
:fare_amount => 35_00,
|
418
|
-
:fee_amount => 5_00,
|
419
|
-
:tax_amount => 10_00,
|
420
|
-
:endorsement_or_restrictions => "NOT REFUNDABLE"
|
421
|
-
}
|
422
|
-
]
|
423
|
-
}
|
424
|
-
},
|
425
|
-
)
|
426
|
-
expect(result.success?).to be(true)
|
432
|
+
}
|
433
|
+
params.merge(industry_data_flight_params)
|
434
|
+
|
435
|
+
result = Braintree::Transaction.create(params)
|
436
|
+
result.success?.should be(true)
|
427
437
|
end
|
428
438
|
|
429
439
|
it "returns errors if validations on industry data fails" do
|
@@ -1452,8 +1462,7 @@ describe Braintree::Transaction do
|
|
1452
1462
|
|
1453
1463
|
it "returns an error if no credit card is given" do
|
1454
1464
|
params = {
|
1455
|
-
:transaction => {
|
1456
|
-
}
|
1465
|
+
:transaction => {}
|
1457
1466
|
}
|
1458
1467
|
result = Braintree::Transaction.create(params[:transaction])
|
1459
1468
|
expect(result.success?).to eq(false)
|
@@ -2107,6 +2116,61 @@ describe Braintree::Transaction do
|
|
2107
2116
|
expect(result.transaction.paypal_details.debug_id).not_to be_nil
|
2108
2117
|
end
|
2109
2118
|
|
2119
|
+
it "can create a transaction with a fake meta checkout card nonce" do
|
2120
|
+
result = Braintree::Transaction.create(
|
2121
|
+
:type => "sale",
|
2122
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2123
|
+
:payment_method_nonce => Braintree::Test::Nonce::MetaCheckoutCard,
|
2124
|
+
)
|
2125
|
+
|
2126
|
+
result.success?.should == true
|
2127
|
+
result.transaction.should_not be_nil
|
2128
|
+
meta_checkout_card_details = result.transaction.meta_checkout_card_details
|
2129
|
+
meta_checkout_card_details.should_not be_nil
|
2130
|
+
meta_checkout_card_details.bin.should == "401288"
|
2131
|
+
meta_checkout_card_details.card_type.should == Braintree::CreditCard::CardType::Visa
|
2132
|
+
meta_checkout_card_details.cardholder_name.should == "Meta Checkout Card Cardholder"
|
2133
|
+
meta_checkout_card_details.container_id.should == "container123"
|
2134
|
+
meta_checkout_card_details.customer_location.should == "US"
|
2135
|
+
meta_checkout_card_details.expiration_date.should == "12/2024"
|
2136
|
+
meta_checkout_card_details.expiration_year.should == "2024"
|
2137
|
+
meta_checkout_card_details.expiration_month.should == "12"
|
2138
|
+
meta_checkout_card_details.image_url.should == "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=development"
|
2139
|
+
meta_checkout_card_details.is_network_tokenized.should == false
|
2140
|
+
meta_checkout_card_details.last_4.should == "1881"
|
2141
|
+
meta_checkout_card_details.masked_number.should == "401288******1881"
|
2142
|
+
meta_checkout_card_details.prepaid.should == "No"
|
2143
|
+
end
|
2144
|
+
|
2145
|
+
it "can create a transaction with a fake meta checkout token nonce" do
|
2146
|
+
result = Braintree::Transaction.create(
|
2147
|
+
:type => "sale",
|
2148
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
2149
|
+
:payment_method_nonce => Braintree::Test::Nonce::MetaCheckoutToken,
|
2150
|
+
)
|
2151
|
+
|
2152
|
+
result.success?.should == true
|
2153
|
+
result.transaction.should_not be_nil
|
2154
|
+
meta_checkout_token_details = result.transaction.meta_checkout_token_details
|
2155
|
+
|
2156
|
+
meta_checkout_token_details.should_not be_nil
|
2157
|
+
meta_checkout_token_details.bin.should == "401288"
|
2158
|
+
meta_checkout_token_details.card_type.should == Braintree::CreditCard::CardType::Visa
|
2159
|
+
meta_checkout_token_details.cardholder_name.should == "Meta Checkout Token Cardholder"
|
2160
|
+
meta_checkout_token_details.container_id.should == "container123"
|
2161
|
+
meta_checkout_token_details.cryptogram.should == "AlhlvxmN2ZKuAAESNFZ4GoABFA=="
|
2162
|
+
meta_checkout_token_details.customer_location.should == "US"
|
2163
|
+
meta_checkout_token_details.ecommerce_indicator.should == "07"
|
2164
|
+
meta_checkout_token_details.expiration_date.should == "12/2024"
|
2165
|
+
meta_checkout_token_details.expiration_year.should == "2024"
|
2166
|
+
meta_checkout_token_details.expiration_month.should == "12"
|
2167
|
+
meta_checkout_token_details.image_url.should == "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=development"
|
2168
|
+
meta_checkout_token_details.is_network_tokenized.should == true
|
2169
|
+
meta_checkout_token_details.last_4.should == "1881"
|
2170
|
+
meta_checkout_token_details.masked_number.should == "401288******1881"
|
2171
|
+
meta_checkout_token_details.prepaid.should == "No"
|
2172
|
+
end
|
2173
|
+
|
2110
2174
|
it "can create a transaction with a fake apple pay nonce" do
|
2111
2175
|
customer = Braintree::Customer.create!
|
2112
2176
|
result = Braintree::Transaction.create(
|
@@ -5935,6 +5999,54 @@ describe Braintree::Transaction do
|
|
5935
5999
|
end
|
5936
6000
|
end
|
5937
6001
|
|
6002
|
+
it "succeeds when industry data is provided" do
|
6003
|
+
transaction = Braintree::Transaction.create(
|
6004
|
+
:type => "sale",
|
6005
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6006
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
6007
|
+
:options => {
|
6008
|
+
:submit_for_settlement => false
|
6009
|
+
},
|
6010
|
+
).transaction
|
6011
|
+
|
6012
|
+
result = Braintree::Transaction.submit_for_settlement(transaction.id, Braintree::Test::TransactionAmounts::Authorize, industry_data_flight_params)
|
6013
|
+
expect(result.success?).to be_truthy
|
6014
|
+
end
|
6015
|
+
|
6016
|
+
it "returns errors if validations on industry data fails" do
|
6017
|
+
transaction = Braintree::Transaction.create(
|
6018
|
+
:type => "sale",
|
6019
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6020
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
6021
|
+
:options => {
|
6022
|
+
:submit_for_settlement => false
|
6023
|
+
},
|
6024
|
+
).transaction
|
6025
|
+
|
6026
|
+
options = {
|
6027
|
+
:industry => {
|
6028
|
+
:industry_type => Braintree::Transaction::IndustryType::TravelAndFlight,
|
6029
|
+
:data => {
|
6030
|
+
:fare_amount => -1_23,
|
6031
|
+
:restricted_ticket => false,
|
6032
|
+
:legs => [
|
6033
|
+
{
|
6034
|
+
:fare_amount => -1_23
|
6035
|
+
}
|
6036
|
+
]
|
6037
|
+
}
|
6038
|
+
},
|
6039
|
+
}
|
6040
|
+
|
6041
|
+
result = Braintree::Transaction.submit_for_settlement(transaction.id, Braintree::Test::TransactionAmounts::Authorize, options)
|
6042
|
+
expect(result.success?).to be_falsey
|
6043
|
+
industry_errors = result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort
|
6044
|
+
expect(industry_errors).to eq([Braintree::ErrorCodes::Transaction::Industry::TravelFlight::FareAmountCannotBeNegative])
|
6045
|
+
|
6046
|
+
leg_errors = result.errors.for(:transaction).for(:industry).for(:legs).for(:index_0).map { |e| e.code }.sort
|
6047
|
+
expect(leg_errors).to eq([Braintree::ErrorCodes::Transaction::Industry::Leg::TravelFlight::FareAmountCannotBeNegative])
|
6048
|
+
end
|
6049
|
+
|
5938
6050
|
xit "succeeds when level 2 data is provided" do
|
5939
6051
|
result = Braintree::Transaction.sale(
|
5940
6052
|
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
@@ -6371,6 +6483,20 @@ describe Braintree::Transaction do
|
|
6371
6483
|
expect(result.success?).to eq(false)
|
6372
6484
|
expect(result.errors.for(:transaction).on(:base)[0].code).to eq(Braintree::ErrorCodes::Transaction::CannotSubmitForSettlement)
|
6373
6485
|
end
|
6486
|
+
|
6487
|
+
it "succeeds when industry data is provided" do
|
6488
|
+
transaction = Braintree::Transaction.create(
|
6489
|
+
:type => "sale",
|
6490
|
+
:amount => Braintree::Test::TransactionAmounts::Authorize,
|
6491
|
+
:payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
|
6492
|
+
:options => {
|
6493
|
+
:submit_for_settlement => false
|
6494
|
+
},
|
6495
|
+
).transaction
|
6496
|
+
|
6497
|
+
result = Braintree::Transaction.submit_for_partial_settlement(transaction.id, Braintree::Test::TransactionAmounts::Authorize, industry_data_flight_params)
|
6498
|
+
expect(result.success?).to be_truthy
|
6499
|
+
end
|
6374
6500
|
end
|
6375
6501
|
|
6376
6502
|
describe "self.submit_for_partial_settlement!" do
|
@@ -8,11 +8,11 @@ describe Braintree::BaseModule do
|
|
8
8
|
klass = Class.new { include Braintree::BaseModule }
|
9
9
|
klass.return_object_or_raise(:obj) { result }
|
10
10
|
rescue Braintree::ValidationsFailed => ex
|
11
|
-
end
|
12
11
|
expect(ex).not_to eq(nil)
|
13
12
|
expect(ex.error_result).to eq(result)
|
14
13
|
expect(ex.inspect).to include(result.inspect)
|
15
14
|
expect(ex.to_s).to include(result.inspect)
|
15
|
+
end
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -22,30 +22,35 @@ describe Braintree::CreditCardVerificationGateway do
|
|
22
22
|
it "creates a credit card verification gateway signature" do
|
23
23
|
result = Braintree::CreditCardVerificationGateway._create_signature
|
24
24
|
expect(result.inspect).to include("credit_card")
|
25
|
-
expect(result.inspect).to include("
|
25
|
+
expect(result.inspect).to include("billing_address")
|
26
26
|
expect(result.inspect).to include("cardholder_name")
|
27
27
|
expect(result.inspect).to include("cvv")
|
28
28
|
expect(result.inspect).to include("expiration_date")
|
29
29
|
expect(result.inspect).to include("expiration_month")
|
30
30
|
expect(result.inspect).to include("expiration_year")
|
31
31
|
expect(result.inspect).to include("number")
|
32
|
-
expect(result.inspect).to include("
|
32
|
+
expect(result.inspect).to include("external_vault")
|
33
|
+
expect(result.inspect).to include("previous_network_transaction_id")
|
34
|
+
expect(result.inspect).to include("status")
|
33
35
|
expect(result.inspect).to include("intended_transaction_source")
|
34
36
|
expect(result.inspect).to include("options")
|
37
|
+
expect(result.inspect).to include("account_type")
|
35
38
|
expect(result.inspect).to include("amount")
|
36
39
|
expect(result.inspect).to include("merchant_account_id")
|
37
|
-
expect(result.inspect).to include("account_type")
|
38
40
|
expect(result.inspect).to include("payment_method_nonce")
|
41
|
+
expect(result.inspect).to include("risk_data")
|
42
|
+
expect(result.inspect).to include("customer_browser")
|
43
|
+
expect(result.inspect).to include("customer_ip")
|
39
44
|
expect(result.inspect).to include("three_d_secure_authentication_id")
|
40
45
|
expect(result.inspect).to include("three_d_secure_pass_thru")
|
41
|
-
expect(result.inspect).to include("eci_flag")
|
42
|
-
expect(result.inspect).to include("cavv")
|
43
|
-
expect(result.inspect).to include("xid")
|
44
|
-
expect(result.inspect).to include("three_d_secure_version")
|
45
46
|
expect(result.inspect).to include("authentication_response")
|
46
|
-
expect(result.inspect).to include("
|
47
|
+
expect(result.inspect).to include("cavv")
|
47
48
|
expect(result.inspect).to include("cavv_algorithm")
|
49
|
+
expect(result.inspect).to include("directory_response")
|
48
50
|
expect(result.inspect).to include("ds_transaction_id")
|
51
|
+
expect(result.inspect).to include("eci_flag")
|
52
|
+
expect(result.inspect).to include("three_d_secure_version")
|
53
|
+
expect(result.inspect).to include("xid")
|
49
54
|
end
|
50
55
|
end
|
51
56
|
end
|
@@ -12,6 +12,13 @@ describe Braintree::EnrichedCustomerData do
|
|
12
12
|
describe "self._new" do
|
13
13
|
it "initializes the object with the appropriate attributes set" do
|
14
14
|
|
15
|
+
address = {
|
16
|
+
street_address: "a-street-address",
|
17
|
+
extended_address: "an-extended-address",
|
18
|
+
locality: "a-locality",
|
19
|
+
region: "a-region",
|
20
|
+
postal_code: "a-postal-code"
|
21
|
+
}
|
15
22
|
params = {
|
16
23
|
fields_updated: ["username"],
|
17
24
|
profile_data: {
|
@@ -20,6 +27,8 @@ describe Braintree::EnrichedCustomerData do
|
|
20
27
|
last_name: "a-last-name",
|
21
28
|
phone_number: "a-phone-number",
|
22
29
|
email: "a-email",
|
30
|
+
billing_address: address,
|
31
|
+
shipping_address: address,
|
23
32
|
},
|
24
33
|
}
|
25
34
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::Transaction::MetaCheckoutCardDetails do
|
4
|
+
let(:attributes) do {
|
5
|
+
|
6
|
+
:bin => "abc1234",
|
7
|
+
:container_id => "a-container-id",
|
8
|
+
:card_type => "Visa",
|
9
|
+
:cardholder_name => "Meta Checkout Card CardHolder",
|
10
|
+
:commercial => "NO",
|
11
|
+
:country_of_issuance => "US",
|
12
|
+
:created_at => "2023-05-05T21:28:37Z",
|
13
|
+
:debit => "NO",
|
14
|
+
:durbin_regulated => "NO",
|
15
|
+
:expiration_month => "05",
|
16
|
+
:expiration_year => "2024",
|
17
|
+
:healthcare => "NO",
|
18
|
+
:last_4 => "1234",
|
19
|
+
:payroll => "NO",
|
20
|
+
:prepaid => "NO",
|
21
|
+
:token => "token1",
|
22
|
+
:unique_number_identifier => "abc1234",
|
23
|
+
:updated_at => "2023-05-05T21:28:37Z"
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "unit tests" do
|
28
|
+
it "initializes with the correct attributes" do
|
29
|
+
card = Braintree::Transaction::MetaCheckoutCardDetails.new(attributes)
|
30
|
+
|
31
|
+
card.bin.should == "abc1234"
|
32
|
+
card.container_id.should == "a-container-id"
|
33
|
+
card.card_type.should == "Visa"
|
34
|
+
card.cardholder_name.should == "Meta Checkout Card CardHolder"
|
35
|
+
card.commercial == "NO"
|
36
|
+
card.country_of_issuance == "US"
|
37
|
+
card.created_at == "2023-05-05T21:28:37Z"
|
38
|
+
card.updated_at == "2023-05-05T21:28:37Z"
|
39
|
+
card.debit == "NO"
|
40
|
+
card.payroll == "NO"
|
41
|
+
card.prepaid == "NO"
|
42
|
+
card.healthcare == "NO"
|
43
|
+
card.token == "token1"
|
44
|
+
card.unique_number_identifier == "abc1234"
|
45
|
+
card.expiration_month.should == "05"
|
46
|
+
card.expiration_year.should == "2024"
|
47
|
+
card.last_4.should == "1234"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "sets expiration date correctly" do
|
51
|
+
card = Braintree::Transaction::MetaCheckoutCardDetails.new(attributes)
|
52
|
+
card.expiration_date.should == "05/2024"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "masks the card number correctly" do
|
56
|
+
card = Braintree::Transaction::MetaCheckoutCardDetails.new(attributes)
|
57
|
+
card.masked_number.should == "abc1234******1234"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::MetaCheckoutCard do
|
4
|
+
let(:attributes) do {
|
5
|
+
|
6
|
+
:bin => "abc1234",
|
7
|
+
:container_id => "a-container-id",
|
8
|
+
:card_type => "Visa",
|
9
|
+
:cardholder_name => "Meta Checkout Card CardHolder",
|
10
|
+
:commercial => "NO",
|
11
|
+
:country_of_issuance => "US",
|
12
|
+
:created_at => "2023-05-05T21:28:37Z",
|
13
|
+
:debit => "NO",
|
14
|
+
:durbin_regulated => "NO",
|
15
|
+
:expiration_month => "05",
|
16
|
+
:expiration_year => "2024",
|
17
|
+
:healthcare => "NO",
|
18
|
+
:last_4 => "1234",
|
19
|
+
:payroll => "NO",
|
20
|
+
:prepaid => "NO",
|
21
|
+
:token => "token1",
|
22
|
+
:unique_number_identifier => "abc1234",
|
23
|
+
:updated_at => "2023-05-05T21:28:37Z"
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "unit tests" do
|
28
|
+
it "initializes with the correct attributes" do
|
29
|
+
card = Braintree::MetaCheckoutCard._new(:gateway, attributes)
|
30
|
+
|
31
|
+
card.bin.should == "abc1234"
|
32
|
+
card.container_id.should == "a-container-id"
|
33
|
+
card.card_type.should == "Visa"
|
34
|
+
card.cardholder_name.should == "Meta Checkout Card CardHolder"
|
35
|
+
card.commercial == "NO"
|
36
|
+
card.country_of_issuance == "US"
|
37
|
+
card.created_at == "2023-05-05T21:28:37Z"
|
38
|
+
card.updated_at == "2023-05-05T21:28:37Z"
|
39
|
+
card.debit == "NO"
|
40
|
+
card.payroll == "NO"
|
41
|
+
card.prepaid == "NO"
|
42
|
+
card.healthcare == "NO"
|
43
|
+
card.token == "token1"
|
44
|
+
card.unique_number_identifier == "abc1234"
|
45
|
+
card.expiration_month.should == "05"
|
46
|
+
card.expiration_year.should == "2024"
|
47
|
+
card.last_4.should == "1234"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "sets expiration date correctly" do
|
51
|
+
card = Braintree::MetaCheckoutCard._new(:gateway, attributes)
|
52
|
+
card.expiration_date.should == "05/2024"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "masks the card number correctly" do
|
56
|
+
card = Braintree::MetaCheckoutCard._new(:gateway, attributes)
|
57
|
+
card.masked_number.should == "abc1234******1234"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|