braintree 4.15.0 → 4.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/account_updater_daily_report.rb +3 -3
  3. data/lib/braintree/ach_mandate.rb +1 -1
  4. data/lib/braintree/add_on_gateway.rb +1 -1
  5. data/lib/braintree/address.rb +4 -4
  6. data/lib/braintree/address_gateway.rb +5 -5
  7. data/lib/braintree/advanced_search.rb +10 -10
  8. data/lib/braintree/apple_pay.rb +3 -3
  9. data/lib/braintree/apple_pay_card.rb +3 -3
  10. data/lib/braintree/apple_pay_options.rb +3 -3
  11. data/lib/braintree/authorization_adjustment.rb +3 -3
  12. data/lib/braintree/base_module.rb +1 -1
  13. data/lib/braintree/bin_data.rb +2 -2
  14. data/lib/braintree/client_token_gateway.rb +1 -1
  15. data/lib/braintree/configuration.rb +22 -22
  16. data/lib/braintree/connected_merchant_paypal_status_changed.rb +1 -1
  17. data/lib/braintree/connected_merchant_status_transitioned.rb +1 -1
  18. data/lib/braintree/credit_card.rb +9 -9
  19. data/lib/braintree/credit_card_gateway.rb +8 -8
  20. data/lib/braintree/credit_card_verification.rb +3 -3
  21. data/lib/braintree/credit_card_verification_gateway.rb +28 -11
  22. data/lib/braintree/credit_card_verification_search.rb +1 -1
  23. data/lib/braintree/customer.rb +5 -9
  24. data/lib/braintree/customer_gateway.rb +7 -7
  25. data/lib/braintree/customer_search.rb +1 -1
  26. data/lib/braintree/descriptor.rb +1 -1
  27. data/lib/braintree/digest.rb +1 -1
  28. data/lib/braintree/disbursement.rb +5 -5
  29. data/lib/braintree/discount_gateway.rb +1 -1
  30. data/lib/braintree/dispute/evidence.rb +1 -1
  31. data/lib/braintree/dispute/paypal_message.rb +1 -1
  32. data/lib/braintree/dispute/status_history.rb +1 -1
  33. data/lib/braintree/dispute/transaction.rb +1 -1
  34. data/lib/braintree/dispute/transaction_details.rb +1 -1
  35. data/lib/braintree/dispute.rb +3 -3
  36. data/lib/braintree/dispute_gateway.rb +1 -1
  37. data/lib/braintree/dispute_search.rb +1 -1
  38. data/lib/braintree/document_upload.rb +2 -2
  39. data/lib/braintree/document_upload_gateway.rb +3 -3
  40. data/lib/braintree/enriched_customer_data.rb +2 -2
  41. data/lib/braintree/error_codes.rb +4 -0
  42. data/lib/braintree/error_result.rb +2 -3
  43. data/lib/braintree/errors.rb +3 -3
  44. data/lib/braintree/exceptions.rb +1 -2
  45. data/lib/braintree/exchange_rate.rb +2 -2
  46. data/lib/braintree/exchange_rate_quote.rb +3 -3
  47. data/lib/braintree/exchange_rate_quote_gateway.rb +1 -1
  48. data/lib/braintree/exchange_rate_quote_input.rb +3 -3
  49. data/lib/braintree/exchange_rate_quote_request.rb +3 -3
  50. data/lib/braintree/exchange_rate_quote_response.rb +3 -3
  51. data/lib/braintree/facilitated_details.rb +1 -1
  52. data/lib/braintree/facilitator_details.rb +1 -1
  53. data/lib/braintree/google_pay_card.rb +3 -3
  54. data/lib/braintree/granted_payment_instrument_update.rb +1 -1
  55. data/lib/braintree/graphql_client.rb +1 -1
  56. data/lib/braintree/http.rb +5 -5
  57. data/lib/braintree/local_payment_completed.rb +2 -2
  58. data/lib/braintree/local_payment_expired.rb +2 -2
  59. data/lib/braintree/local_payment_funded.rb +2 -2
  60. data/lib/braintree/local_payment_reversed.rb +2 -2
  61. data/lib/braintree/merchant.rb +3 -3
  62. data/lib/braintree/merchant_account.rb +2 -2
  63. data/lib/braintree/merchant_account_gateway.rb +9 -9
  64. data/lib/braintree/meta_checkout_card.rb +89 -0
  65. data/lib/braintree/meta_checkout_token.rb +88 -0
  66. data/lib/braintree/modification.rb +3 -3
  67. data/lib/braintree/oauth_credentials.rb +3 -3
  68. data/lib/braintree/paginated_collection.rb +2 -2
  69. data/lib/braintree/paginated_result.rb +1 -1
  70. data/lib/braintree/payment_instrument_type.rb +2 -0
  71. data/lib/braintree/payment_method_customer_data_updated_metadata.rb +2 -2
  72. data/lib/braintree/payment_method_gateway.rb +8 -7
  73. data/lib/braintree/payment_method_nonce.rb +4 -4
  74. data/lib/braintree/payment_method_nonce_details.rb +1 -1
  75. data/lib/braintree/payment_method_nonce_details_payer_info.rb +1 -1
  76. data/lib/braintree/payment_method_nonce_gateway.rb +1 -1
  77. data/lib/braintree/paypal_account.rb +1 -2
  78. data/lib/braintree/paypal_account_gateway.rb +5 -5
  79. data/lib/braintree/plan.rb +1 -1
  80. data/lib/braintree/plan_gateway.rb +2 -2
  81. data/lib/braintree/resource_collection.rb +2 -2
  82. data/lib/braintree/revoked_payment_method_metadata.rb +1 -1
  83. data/lib/braintree/risk_data.rb +1 -1
  84. data/lib/braintree/samsung_pay_card.rb +5 -5
  85. data/lib/braintree/sepa_direct_debit_account.rb +2 -2
  86. data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +1 -1
  87. data/lib/braintree/settlement_batch_summary_gateway.rb +1 -1
  88. data/lib/braintree/sha256_digest.rb +1 -1
  89. data/lib/braintree/subscription/status_details.rb +1 -1
  90. data/lib/braintree/subscription.rb +2 -2
  91. data/lib/braintree/subscription_gateway.rb +6 -6
  92. data/lib/braintree/subscription_search.rb +1 -1
  93. data/lib/braintree/successful_result.rb +2 -2
  94. data/lib/braintree/test/credit_card.rb +7 -10
  95. data/lib/braintree/test/merchant_account.rb +1 -1
  96. data/lib/braintree/test/nonce.rb +3 -0
  97. data/lib/braintree/test/transaction_amounts.rb +2 -3
  98. data/lib/braintree/testing_gateway.rb +1 -1
  99. data/lib/braintree/three_d_secure_info.rb +1 -1
  100. data/lib/braintree/transaction/address_details.rb +2 -1
  101. data/lib/braintree/transaction/credit_card_details.rb +1 -1
  102. data/lib/braintree/transaction/customer_details.rb +1 -1
  103. data/lib/braintree/transaction/disbursement_details.rb +1 -1
  104. data/lib/braintree/transaction/meta_checkout_card_details.rb +52 -0
  105. data/lib/braintree/transaction/meta_checkout_token_details.rb +54 -0
  106. data/lib/braintree/transaction/package_details.rb +16 -0
  107. data/lib/braintree/transaction/samsung_pay_card_details.rb +1 -1
  108. data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +1 -1
  109. data/lib/braintree/transaction/status_details.rb +1 -1
  110. data/lib/braintree/transaction/subscription_details.rb +1 -1
  111. data/lib/braintree/transaction/us_bank_account_details.rb +1 -1
  112. data/lib/braintree/transaction/visa_checkout_card_details.rb +1 -1
  113. data/lib/braintree/transaction.rb +32 -16
  114. data/lib/braintree/transaction_gateway.rb +30 -13
  115. data/lib/braintree/transaction_line_item.rb +13 -10
  116. data/lib/braintree/transaction_line_item_gateway.rb +1 -1
  117. data/lib/braintree/transaction_review.rb +1 -1
  118. data/lib/braintree/transaction_search.rb +1 -1
  119. data/lib/braintree/unknown_payment_method.rb +1 -1
  120. data/lib/braintree/us_bank_account.rb +2 -2
  121. data/lib/braintree/us_bank_account_verification.rb +23 -15
  122. data/lib/braintree/us_bank_account_verification_search.rb +1 -1
  123. data/lib/braintree/util.rb +3 -3
  124. data/lib/braintree/validation_error.rb +1 -1
  125. data/lib/braintree/validation_error_collection.rb +3 -3
  126. data/lib/braintree/venmo_account.rb +3 -3
  127. data/lib/braintree/venmo_profile_data.rb +6 -4
  128. data/lib/braintree/version.rb +1 -1
  129. data/lib/braintree/visa_checkout_card.rb +7 -7
  130. data/lib/braintree/webhook_notification.rb +2 -2
  131. data/lib/braintree/webhook_notification_gateway.rb +4 -4
  132. data/lib/braintree/webhook_testing.rb +1 -1
  133. data/lib/braintree/webhook_testing_gateway.rb +1 -1
  134. data/lib/braintree/xml/generator.rb +1 -1
  135. data/lib/braintree/xml/libxml.rb +1 -1
  136. data/lib/braintree/xml/parser.rb +3 -3
  137. data/lib/braintree/xml/rexml.rb +2 -2
  138. data/lib/braintree/xml.rb +1 -1
  139. data/lib/braintree.rb +5 -1
  140. data/spec/integration/braintree/client_api/spec_helper.rb +2 -2
  141. data/spec/integration/braintree/credit_card_spec.rb +4 -5
  142. data/spec/integration/braintree/credit_card_verification_spec.rb +46 -1
  143. data/spec/integration/braintree/customer_spec.rb +4 -4
  144. data/spec/integration/braintree/dispute_search_spec.rb +0 -1
  145. data/spec/integration/braintree/package_tracking_spec.rb +111 -0
  146. data/spec/integration/braintree/payment_method_nonce_spec.rb +20 -0
  147. data/spec/integration/braintree/payment_method_spec.rb +2 -2
  148. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +72 -0
  149. data/spec/integration/braintree/transaction_line_item_spec.rb +6 -0
  150. data/spec/integration/braintree/transaction_search_spec.rb +27 -0
  151. data/spec/integration/braintree/transaction_spec.rb +299 -89
  152. data/spec/unit/braintree/base_module_spec.rb +1 -1
  153. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +13 -8
  154. data/spec/unit/braintree/enriched_customer_data_spec.rb +9 -0
  155. data/spec/unit/braintree/http_spec.rb +1 -1
  156. data/spec/unit/braintree/meta_checkout_card_details_spec.rb +60 -0
  157. data/spec/unit/braintree/meta_checkout_card_spec.rb +60 -0
  158. data/spec/unit/braintree/meta_checkout_token_details_spec.rb +63 -0
  159. data/spec/unit/braintree/meta_checkout_token_spec.rb +63 -0
  160. data/spec/unit/braintree/package_tracking_spec.rb +74 -0
  161. data/spec/unit/braintree/transaction_gateway_spec.rb +32 -3
  162. data/spec/unit/braintree/us_bank_account_verification_spec.rb +5 -0
  163. data/spec/unit/braintree/venmo_profile_data_spec.rb +11 -0
  164. metadata +13 -2
@@ -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(*[invalid_folio, check_out_date_must_follow_check_in_date, room_rate_format_is_invalid])
310
- 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])
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
- result = Braintree::Transaction.create(
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
- :industry => {
367
- :industry_type => Braintree::Transaction::IndustryType::TravelAndFlight,
368
- :data => {
369
- :passenger_first_name => "John",
370
- :passenger_last_name => "Doe",
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,63 @@ 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
+ next_year = Date.today().next_year().year.to_s
2136
+ meta_checkout_card_details.expiration_date.should == "12/".concat(next_year)
2137
+ meta_checkout_card_details.expiration_year.should == next_year
2138
+ meta_checkout_card_details.expiration_month.should == "12"
2139
+ meta_checkout_card_details.image_url.should == "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=development"
2140
+ meta_checkout_card_details.is_network_tokenized.should == false
2141
+ meta_checkout_card_details.last_4.should == "1881"
2142
+ meta_checkout_card_details.masked_number.should == "401288******1881"
2143
+ meta_checkout_card_details.prepaid.should == "No"
2144
+ end
2145
+
2146
+ it "can create a transaction with a fake meta checkout token nonce" do
2147
+ result = Braintree::Transaction.create(
2148
+ :type => "sale",
2149
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
2150
+ :payment_method_nonce => Braintree::Test::Nonce::MetaCheckoutToken,
2151
+ )
2152
+
2153
+ result.success?.should == true
2154
+ result.transaction.should_not be_nil
2155
+ meta_checkout_token_details = result.transaction.meta_checkout_token_details
2156
+
2157
+ meta_checkout_token_details.should_not be_nil
2158
+ meta_checkout_token_details.bin.should == "401288"
2159
+ meta_checkout_token_details.card_type.should == Braintree::CreditCard::CardType::Visa
2160
+ meta_checkout_token_details.cardholder_name.should == "Meta Checkout Token Cardholder"
2161
+ meta_checkout_token_details.container_id.should == "container123"
2162
+ meta_checkout_token_details.cryptogram.should == "AlhlvxmN2ZKuAAESNFZ4GoABFA=="
2163
+ meta_checkout_token_details.customer_location.should == "US"
2164
+ meta_checkout_token_details.ecommerce_indicator.should == "07"
2165
+ next_year = Date.today().next_year().year.to_s
2166
+ meta_checkout_token_details.expiration_date.should == "12/".concat(next_year)
2167
+ meta_checkout_token_details.expiration_year.should == next_year
2168
+ meta_checkout_token_details.expiration_month.should == "12"
2169
+ meta_checkout_token_details.image_url.should == "https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=development"
2170
+ meta_checkout_token_details.is_network_tokenized.should == true
2171
+ meta_checkout_token_details.last_4.should == "1881"
2172
+ meta_checkout_token_details.masked_number.should == "401288******1881"
2173
+ meta_checkout_token_details.prepaid.should == "No"
2174
+ end
2175
+
2110
2176
  it "can create a transaction with a fake apple pay nonce" do
2111
2177
  customer = Braintree::Customer.create!
2112
2178
  result = Braintree::Transaction.create(
@@ -2684,7 +2750,7 @@ describe Braintree::Transaction do
2684
2750
  },
2685
2751
  :three_d_secure_authentication_id => three_d_secure_authentication_id,
2686
2752
  :three_d_secure_pass_thru => {
2687
- :eci_flag => "02",
2753
+ :eci_flag => "05",
2688
2754
  :cavv => "some_cavv",
2689
2755
  :xid => "some_xid",
2690
2756
  :three_d_secure_version => "1.0.2",
@@ -2771,7 +2837,7 @@ describe Braintree::Transaction do
2771
2837
  :expiration_date => "12/12",
2772
2838
  },
2773
2839
  :three_d_secure_pass_thru => {
2774
- :eci_flag => "02",
2840
+ :eci_flag => "05",
2775
2841
  :cavv => "some_cavv",
2776
2842
  :xid => "some_xid",
2777
2843
  :three_d_secure_version => "1.0.2",
@@ -2796,7 +2862,7 @@ describe Braintree::Transaction do
2796
2862
  :expiration_date => "12/12",
2797
2863
  },
2798
2864
  :three_d_secure_pass_thru => {
2799
- :eci_flag => "02",
2865
+ :eci_flag => "05",
2800
2866
  :cavv => "some_cavv",
2801
2867
  :xid => "some_xid",
2802
2868
  :three_d_secure_version => "1.0.2",
@@ -2883,7 +2949,7 @@ describe Braintree::Transaction do
2883
2949
  :expiration_date => "12/12",
2884
2950
  },
2885
2951
  :three_d_secure_pass_thru => {
2886
- :eci_flag => "02",
2952
+ :eci_flag => "05",
2887
2953
  :cavv => "some_cavv",
2888
2954
  :xid => "some_xid",
2889
2955
  :three_d_secure_version => "invalid",
@@ -2907,7 +2973,7 @@ describe Braintree::Transaction do
2907
2973
  :expiration_date => "12/12",
2908
2974
  },
2909
2975
  :three_d_secure_pass_thru => {
2910
- :eci_flag => "02",
2976
+ :eci_flag => "05",
2911
2977
  :cavv => "some_cavv",
2912
2978
  :xid => "some_xid",
2913
2979
  :three_d_secure_version => "1.0.2",
@@ -2931,7 +2997,7 @@ describe Braintree::Transaction do
2931
2997
  :expiration_date => "12/12",
2932
2998
  },
2933
2999
  :three_d_secure_pass_thru => {
2934
- :eci_flag => "02",
3000
+ :eci_flag => "05",
2935
3001
  :cavv => "some_cavv",
2936
3002
  :xid => "some_xid",
2937
3003
  :three_d_secure_version => "1.0.2",
@@ -2955,7 +3021,7 @@ describe Braintree::Transaction do
2955
3021
  :expiration_date => "12/12",
2956
3022
  },
2957
3023
  :three_d_secure_pass_thru => {
2958
- :eci_flag => "02",
3024
+ :eci_flag => "05",
2959
3025
  :cavv => "some_cavv",
2960
3026
  :xid => "some_xid",
2961
3027
  :three_d_secure_version => "1.0.2",
@@ -4541,6 +4607,84 @@ describe Braintree::Transaction do
4541
4607
  expect(result.success?).to eq(false)
4542
4608
  expect(result.errors.for(:transaction).on(:line_items)[0].code).to eq(Braintree::ErrorCodes::Transaction::TooManyLineItems)
4543
4609
  end
4610
+
4611
+ context "UPC code and type" do
4612
+ let(:line_item) do
4613
+ {
4614
+ :quantity => "1",
4615
+ :name => "Name #1",
4616
+ :description => "Description #1",
4617
+ :kind => "debit",
4618
+ :unit_amount => "45.12",
4619
+ :unit_tax_amount => "1.23",
4620
+ :unit_of_measure => "gallon",
4621
+ :discount_amount => "1.02",
4622
+ :tax_amount => "4.50",
4623
+ :total_amount => "45.15",
4624
+ :product_code => "23434",
4625
+ :commodity_code => "9SAASSD8724",
4626
+ :url => "https://example.com/products/23434",
4627
+ :upc_code => "042100005264",
4628
+ :upc_type => "UPC-A",
4629
+ :image_url => "https://google.com/image.png",
4630
+ }
4631
+ end
4632
+
4633
+ it "accepts valid values" do
4634
+ result = Braintree::Transaction.create(
4635
+ :type => "sale",
4636
+ :amount => "45.15",
4637
+ :payment_method_nonce => Braintree::Test::Nonce::Transactable,
4638
+ :line_items => [line_item],
4639
+ )
4640
+ expect(result.success?).to eq(true)
4641
+ expect(result.transaction.line_items.length).to eq(1)
4642
+ line_item = result.transaction.line_items[0]
4643
+ expect(line_item.upc_code).to eq("042100005264")
4644
+ expect(line_item.upc_type).to eq("UPC-A")
4645
+ end
4646
+
4647
+ it "returns validation errors for invalid UPC code and type too long" do
4648
+ line_item[:upc_code] = "THISCODELONGERTHAN17CHARS"
4649
+ line_item[:upc_type] = "USB-C"
4650
+ result = Braintree::Transaction.create(
4651
+ :type => "sale",
4652
+ :amount => "45.15",
4653
+ :payment_method_nonce => Braintree::Test::Nonce::Transactable,
4654
+ :line_items => [line_item],
4655
+ )
4656
+
4657
+ expect(result.success?).to eq(false)
4658
+ expect(result.errors.for(:transaction).for(:line_items).for(:index_0).on(:upc_code)[0].code).to eq(Braintree::ErrorCodes::TransactionLineItem::UPCCodeIsTooLong)
4659
+ expect(result.errors.for(:transaction).for(:line_items).for(:index_0).on(:upc_type)[0].code).to eq(Braintree::ErrorCodes::TransactionLineItem::UPCTypeIsInvalid)
4660
+ end
4661
+
4662
+ it "returns UPC code missing error when code is not present" do
4663
+ line_item.delete(:upc_code)
4664
+ result = Braintree::Transaction.create(
4665
+ :type => "sale",
4666
+ :amount => "45.15",
4667
+ :payment_method_nonce => Braintree::Test::Nonce::Transactable,
4668
+ :line_items => [line_item],
4669
+ )
4670
+
4671
+ expect(result.success?).to eq(false)
4672
+ expect(result.errors.for(:transaction).for(:line_items).for(:index_0).on(:upc_code)[0].code).to eq(Braintree::ErrorCodes::TransactionLineItem::UPCCodeIsMissing)
4673
+ end
4674
+
4675
+ it "returns UPC type missing error when type is not present" do
4676
+ line_item.delete(:upc_type)
4677
+ result = Braintree::Transaction.create(
4678
+ :type => "sale",
4679
+ :amount => "45.15",
4680
+ :payment_method_nonce => Braintree::Test::Nonce::Transactable,
4681
+ :line_items => [line_item],
4682
+ )
4683
+
4684
+ expect(result.success?).to eq(false)
4685
+ expect(result.errors.for(:transaction).for(:line_items).for(:index_0).on(:upc_type)[0].code).to eq(Braintree::ErrorCodes::TransactionLineItem::UPCTypeIsMissing)
4686
+ end
4687
+ end
4544
4688
  end
4545
4689
 
4546
4690
  context "level 3 summary data" do
@@ -5756,7 +5900,7 @@ describe Braintree::Transaction do
5756
5900
  end
5757
5901
 
5758
5902
  context "Pinless debit transaction" do
5759
- xit "succesfully submits for settlement" do
5903
+ it "succesfully submits for settlement" do
5760
5904
  result = Braintree::Transaction.sale(
5761
5905
  :amount => Braintree::Test::TransactionAmounts::Authorize,
5762
5906
  :merchant_account_id => SpecHelper::PinlessDebitMerchantAccountId,
@@ -5767,10 +5911,28 @@ describe Braintree::Transaction do
5767
5911
  },
5768
5912
  )
5769
5913
  expect(result.success?).to be_truthy
5770
- expect(result.transaction.status).to eq(Braintree::Transaction::Status::SubmittedForSettlement)
5771
5914
  expect(result.transaction.debit_network).not_to be_nil
5772
5915
  end
5773
5916
  end
5917
+
5918
+ context "Process debit as credit" do
5919
+ it "succesfully completed pinless eligible transaction in signature" do
5920
+ result = Braintree::Transaction.sale(
5921
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
5922
+ :merchant_account_id => SpecHelper::PinlessDebitMerchantAccountId,
5923
+ :currency_iso_code => "USD",
5924
+ :payment_method_nonce => Braintree::Test::Nonce::TransactablePinlessDebitVisa,
5925
+ :options => {
5926
+ :submit_for_settlement => true,
5927
+ :credit_card => {
5928
+ :process_debit_as_credit => true
5929
+ }
5930
+ },
5931
+ )
5932
+ expect(result.success?).to be_truthy
5933
+ expect(result.transaction.debit_network).to be_nil
5934
+ end
5935
+ end
5774
5936
  end
5775
5937
 
5776
5938
  describe "self.sale!" do
@@ -5935,6 +6097,54 @@ describe Braintree::Transaction do
5935
6097
  end
5936
6098
  end
5937
6099
 
6100
+ it "succeeds when industry data is provided" do
6101
+ transaction = Braintree::Transaction.create(
6102
+ :type => "sale",
6103
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
6104
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
6105
+ :options => {
6106
+ :submit_for_settlement => false
6107
+ },
6108
+ ).transaction
6109
+
6110
+ result = Braintree::Transaction.submit_for_settlement(transaction.id, Braintree::Test::TransactionAmounts::Authorize, industry_data_flight_params)
6111
+ expect(result.success?).to be_truthy
6112
+ end
6113
+
6114
+ it "returns errors if validations on industry data fails" do
6115
+ transaction = Braintree::Transaction.create(
6116
+ :type => "sale",
6117
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
6118
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
6119
+ :options => {
6120
+ :submit_for_settlement => false
6121
+ },
6122
+ ).transaction
6123
+
6124
+ options = {
6125
+ :industry => {
6126
+ :industry_type => Braintree::Transaction::IndustryType::TravelAndFlight,
6127
+ :data => {
6128
+ :fare_amount => -1_23,
6129
+ :restricted_ticket => false,
6130
+ :legs => [
6131
+ {
6132
+ :fare_amount => -1_23
6133
+ }
6134
+ ]
6135
+ }
6136
+ },
6137
+ }
6138
+
6139
+ result = Braintree::Transaction.submit_for_settlement(transaction.id, Braintree::Test::TransactionAmounts::Authorize, options)
6140
+ expect(result.success?).to be_falsey
6141
+ industry_errors = result.errors.for(:transaction).for(:industry).map { |e| e.code }.sort
6142
+ expect(industry_errors).to eq([Braintree::ErrorCodes::Transaction::Industry::TravelFlight::FareAmountCannotBeNegative])
6143
+
6144
+ leg_errors = result.errors.for(:transaction).for(:industry).for(:legs).for(:index_0).map { |e| e.code }.sort
6145
+ expect(leg_errors).to eq([Braintree::ErrorCodes::Transaction::Industry::Leg::TravelFlight::FareAmountCannotBeNegative])
6146
+ end
6147
+
5938
6148
  xit "succeeds when level 2 data is provided" do
5939
6149
  result = Braintree::Transaction.sale(
5940
6150
  :amount => Braintree::Test::TransactionAmounts::Authorize,
@@ -6371,6 +6581,20 @@ describe Braintree::Transaction do
6371
6581
  expect(result.success?).to eq(false)
6372
6582
  expect(result.errors.for(:transaction).on(:base)[0].code).to eq(Braintree::ErrorCodes::Transaction::CannotSubmitForSettlement)
6373
6583
  end
6584
+
6585
+ it "succeeds when industry data is provided" do
6586
+ transaction = Braintree::Transaction.create(
6587
+ :type => "sale",
6588
+ :amount => Braintree::Test::TransactionAmounts::Authorize,
6589
+ :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment,
6590
+ :options => {
6591
+ :submit_for_settlement => false
6592
+ },
6593
+ ).transaction
6594
+
6595
+ result = Braintree::Transaction.submit_for_partial_settlement(transaction.id, Braintree::Test::TransactionAmounts::Authorize, industry_data_flight_params)
6596
+ expect(result.success?).to be_truthy
6597
+ end
6374
6598
  end
6375
6599
 
6376
6600
  describe "self.submit_for_partial_settlement!" do
@@ -7613,20 +7837,6 @@ describe Braintree::Transaction do
7613
7837
  expect(adjustment_transaction.errors.for(:authorization_adjustment).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::NoNetAmountToPerformAuthAdjustment)
7614
7838
  end
7615
7839
 
7616
- it "returns failure, when transaction status is not authorized" do
7617
- additional_params = {:options => {:submit_for_settlement => true}}
7618
- initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
7619
- expect(initial_transaction.success?).to eq(true)
7620
-
7621
- adjustment_transaction = Braintree::Transaction.adjust_authorization(
7622
- initial_transaction.transaction.id, "85.50"
7623
- )
7624
-
7625
- expect(adjustment_transaction.success?).to eq(false)
7626
- expect(adjustment_transaction.transaction.amount).to eq(BigDecimal("75.50"))
7627
- expect(adjustment_transaction.errors.for(:transaction).on(:base).first.code).to eq(Braintree::ErrorCodes::Transaction::TransactionMustBeInStateAuthorized)
7628
- end
7629
-
7630
7840
  it "returns failure, when transaction authorization type final or undefined" do
7631
7841
  additional_params = {:transaction_source => "recurring"}
7632
7842
  initial_transaction = Braintree::Transaction.sale(first_data_master_transaction_params.merge(additional_params))
@@ -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("credit_card")
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("billing_address")
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("directory_response")
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
 
@@ -121,7 +121,7 @@ END
121
121
  end
122
122
 
123
123
  describe "_compose_headers" do
124
- before (:each) do
124
+ before(:each) do
125
125
  config = Braintree::Configuration.new
126
126
  @http = Braintree::Http.new(config)
127
127
  end
@@ -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