braintree 4.35.0 → 4.36.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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/apple_pay_card.rb +7 -0
  3. data/lib/braintree/apple_pay_gateway.rb +43 -0
  4. data/lib/braintree/base_module.rb +9 -0
  5. data/lib/braintree/credit_card_verification.rb +2 -0
  6. data/lib/braintree/customer.rb +1 -1
  7. data/lib/braintree/customer_gateway.rb +2 -0
  8. data/lib/braintree/error_codes.rb +20 -0
  9. data/lib/braintree/gateway.rb +4 -0
  10. data/lib/braintree/graphql/inputs/billing_address_input.rb +34 -0
  11. data/lib/braintree/graphql/inputs/create_local_payment_context_input.rb +44 -0
  12. data/lib/braintree/graphql/inputs/payer_info_input.rb +38 -0
  13. data/lib/braintree/graphql/inputs/shipping_address_input.rb +34 -0
  14. data/lib/braintree/local_payment_context.rb +108 -0
  15. data/lib/braintree/local_payment_context_gateway.rb +132 -0
  16. data/lib/braintree/local_payment_type.rb +6 -0
  17. data/lib/braintree/merchant_gateway.rb +16 -16
  18. data/lib/braintree/monetary_amount.rb +24 -0
  19. data/lib/braintree/successful_result.rb +1 -0
  20. data/lib/braintree/transaction.rb +2 -0
  21. data/lib/braintree/transaction_gateway.rb +11 -5
  22. data/lib/braintree/transaction_search.rb +1 -0
  23. data/lib/braintree/validation_error_collection.rb +1 -1
  24. data/lib/braintree/version.rb +1 -1
  25. data/lib/braintree.rb +20 -3
  26. data/spec/integration/braintree/customer_spec.rb +550 -0
  27. data/spec/integration/braintree/http_spec.rb +1 -1
  28. data/spec/integration/braintree/local_payment_context_spec.rb +168 -0
  29. data/spec/integration/braintree/merchant_spec.rb +5 -169
  30. data/spec/integration/braintree/payment_method_spec.rb +174 -1
  31. data/spec/integration/braintree/transaction_idempotency_spec.rb +320 -0
  32. data/spec/integration/braintree/transaction_search_spec.rb +3 -2
  33. data/spec/integration/braintree/transaction_spec.rb +75 -0
  34. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +2 -1
  35. data/spec/spec_helper.rb +2 -0
  36. data/spec/unit/braintree/credit_card_verification_spec.rb +1 -1
  37. data/spec/unit/braintree/customer_spec.rb +67 -1
  38. data/spec/unit/braintree/graphql/billing_address_input_spec.rb +68 -0
  39. data/spec/unit/braintree/graphql/create_local_payment_context_input_spec.rb +63 -0
  40. data/spec/unit/braintree/graphql/monetary_amount_input_spec.rb +55 -0
  41. data/spec/unit/braintree/graphql/payer_info_input_spec.rb +92 -0
  42. data/spec/unit/braintree/local_payment_context_gateway_spec.rb +149 -0
  43. data/spec/unit/braintree/local_payment_context_spec.rb +141 -0
  44. data/spec/unit/braintree/monetary_amount_spec.rb +34 -0
  45. data/spec/unit/braintree/three_d_secure_info_spec.rb +3 -1
  46. data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +7 -7
  47. data/spec/unit/braintree/transaction/google_pay_details_spec.rb +7 -7
  48. data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +6 -6
  49. data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +6 -6
  50. data/spec/unit/braintree/transaction/payment_receipt_spec.rb +4 -4
  51. data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +6 -6
  52. data/spec/unit/braintree/transaction_gateway_spec.rb +4 -3
  53. data/spec/unit/braintree/transaction_spec.rb +12 -0
  54. data/spec/unit/credit_card_details_spec.rb +6 -6
  55. data/spec/unit/spec_helper.rb +9 -0
  56. metadata +19 -2
@@ -338,6 +338,153 @@ describe Braintree::Customer do
338
338
  result.customer.credit_cards[0].verification.currency_iso_code == "USD"
339
339
  end
340
340
 
341
+ it "errors when verification amount is negative for apple pay" do
342
+ result = Braintree::Customer.create(
343
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
344
+ :apple_pay_card => {
345
+ :options => {
346
+ :verify_card => true,
347
+ :verification_amount => "-10.00",
348
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
349
+ }
350
+ },
351
+ )
352
+
353
+ expect(result).to_not be_success
354
+ expect(result.errors.for(:apple_pay).for(:options).on(:verification_amount)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAmountCannotBeNegative
355
+ end
356
+
357
+ it "errors when verification amount format is invalid for apple pay" do
358
+ result = Braintree::Customer.create(
359
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
360
+ :apple_pay_card => {
361
+ :options => {
362
+ :verify_card => true,
363
+ :verification_amount => "0.001",
364
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
365
+ }
366
+ },
367
+ )
368
+
369
+ expect(result).to_not be_success
370
+ expect(result.errors.for(:apple_pay).for(:options).on(:verification_amount)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAmountFormatIsInvalid
371
+ end
372
+
373
+ it "errors when verification amount is not supported for processor on apple pay" do
374
+ result = Braintree::Customer.create(
375
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
376
+ :apple_pay_card => {
377
+ :options => {
378
+ :verify_card => true,
379
+ :verification_amount => "0.01",
380
+ :verification_merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
381
+ }
382
+ },
383
+ )
384
+
385
+ expect(result).to_not be_success
386
+ expect(result.errors.for(:apple_pay).for(:options).on(:verification_amount)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAmountNotSupportedByProcessor
387
+ end
388
+
389
+ it "errors when verification amount is too large on apple pay" do
390
+ result = Braintree::Customer.create(
391
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
392
+ :apple_pay_card => {
393
+ :options => {
394
+ :verify_card => true,
395
+ :verification_amount => ((2**31) / 100.0).to_s,
396
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
397
+ }
398
+ },
399
+ )
400
+
401
+ expect(result).to_not be_success
402
+ expect(result.errors.for(:apple_pay).for(:options).on(:verification_amount)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAmountIsTooLarge
403
+ end
404
+
405
+ it "errors when verification merchant account is invalid" do
406
+ result = Braintree::Customer.create(
407
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
408
+ :apple_pay_card => {
409
+ :options => {
410
+ :verify_card => true,
411
+ :verification_amount => "10.00",
412
+ :verification_merchant_account_id => "BAD_MERCHANT_ACCOUNT",
413
+ }
414
+ },
415
+ )
416
+
417
+ expect(result).to_not be_success
418
+ expect(result.errors.for(:apple_pay).for(:options).on(:verification_merchant_account_id)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationMerchantAccountIdIsInvalid
419
+ end
420
+
421
+ it "errors when verification merchant account is suspended" do
422
+ result = Braintree::Customer.create(
423
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
424
+ :apple_pay_card => {
425
+ :options => {
426
+ :verify_card => true,
427
+ :verification_amount => "10.00",
428
+ :verification_merchant_account_id => SpecHelper::SuspendedAccount,
429
+ }
430
+ },
431
+ )
432
+
433
+ expect(result).to_not be_success
434
+ expect(result.errors.for(:apple_pay).for(:options).on(:verification_merchant_account_id)[1].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationMerchantAccountIsSuspended
435
+ end
436
+
437
+ it "errors when network_transaction_id is present for an apple pay verification" do
438
+ result = Braintree::Customer.create(
439
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
440
+ :apple_pay_card => {
441
+ :network_transaction_id => "test123",
442
+ :options => {
443
+ :verify_card => true,
444
+ :verification_amount => "10.00",
445
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
446
+ }
447
+ },
448
+ )
449
+
450
+ expect(result).to_not be_success
451
+ expect(result.errors.for(:apple_pay).on(:network_transaction_id_not_allowed)[0].code).to eq Braintree::ErrorCodes::ApplePay::NetworkTransactionIdNotAllowed
452
+ end
453
+
454
+ it "errors with invalid account_type for apple pay" do
455
+ result = Braintree::Customer.create(
456
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
457
+ :apple_pay_card => {
458
+ :options => {
459
+ :verify_card => true,
460
+ :verification_amount => "10.00",
461
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
462
+ :verification_account_type => "ach",
463
+ }
464
+ },
465
+ )
466
+
467
+ expect(result).to_not be_success
468
+ expect(result.errors.for(:apple_pay).on(:verification_account_type)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAccountTypeIsInvalid
469
+ end
470
+
471
+ it "errors when account_type not supported by merchant on apple_pay" do
472
+ result = Braintree::Customer.create(
473
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
474
+ :apple_pay_card => {
475
+ :options => {
476
+ :verify_card => true,
477
+ :verification_amount => "10.00",
478
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
479
+ :verification_account_type => "credit",
480
+ }
481
+ },
482
+ )
483
+
484
+ expect(result).to_not be_success
485
+ expect(result.errors.for(:apple_pay).for(:options).on(:verification_account_type)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAccountTypeNotSupported
486
+ end
487
+
341
488
  it "errors when verification_currency_iso_code is not supported by merchant account" do
342
489
  result = Braintree::Customer.create(
343
490
  :first_name => "Mike",
@@ -601,6 +748,100 @@ describe Braintree::Customer do
601
748
  expect(result.customer.payment_methods.first.token).not_to be_nil
602
749
  end
603
750
 
751
+ it "verifies the apple pay card with all verification options" do
752
+ result = Braintree::Customer.create(
753
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
754
+ :apple_pay_card => {
755
+ :options => {
756
+ :verify_card => true,
757
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
758
+ :verification_amount => "10.00"
759
+ }
760
+ },
761
+ )
762
+
763
+ expect(result).to be_success
764
+ expect(result.customer.payment_methods.first).to be_a(Braintree::ApplePayCard)
765
+
766
+ verification = result.customer.payment_methods.first.verification
767
+ expect(verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
768
+ expect(verification.amount).to eq(BigDecimal("10.00"))
769
+ expect(verification.merchant_account_id).to eq(SpecHelper::NonDefaultMerchantAccountId)
770
+ end
771
+
772
+ it "verifies the apple pay card when only verify_card set to true is provided" do
773
+ result = Braintree::Customer.create(
774
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
775
+ :apple_pay_card => {
776
+ :options => {
777
+ :verify_card => true,
778
+ }
779
+ },
780
+ )
781
+
782
+ expect(result).to be_success
783
+ expect(result.customer.payment_methods.first).to be_a(Braintree::ApplePayCard)
784
+ verification = result.customer.payment_methods.first.verification
785
+ expect(verification).not_to be_nil
786
+ end
787
+
788
+ it "does not verify the apple pay card when verify_card is false" do
789
+ result = Braintree::Customer.create(
790
+ :payment_method_nonce => Braintree::Test::Nonce::ApplePayVisa,
791
+ :apple_pay_card => {
792
+ :options => {
793
+ :verify_card => false,
794
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
795
+ :verification_amount => "10.00",
796
+ }
797
+ },
798
+ )
799
+
800
+ expect(result).to be_success
801
+ expect(result.customer.payment_methods.first).to be_a(Braintree::ApplePayCard)
802
+
803
+ verification = result.customer.payment_methods.first.verification
804
+ expect(verification).to be_nil
805
+ end
806
+
807
+ it "creates customer with raw apple pay card parameters and verification" do
808
+ result = Braintree::Customer.create(
809
+ :first_name => "John",
810
+ :last_name => "Doe",
811
+ :apple_pay_card => {
812
+ :number => Braintree::Test::CreditCardNumbers::Visa,
813
+ :expiration_month => "12",
814
+ :expiration_year => "2025",
815
+ :cryptogram => "ApplePayCryptogram123",
816
+ :eci_indicator => "7",
817
+ :cardholder_name => "John Doe",
818
+ :billing_address => {
819
+ :first_name => "John",
820
+ :last_name => "Doe",
821
+ :street_address => "123 Apple Street",
822
+ :locality => "Cupertino",
823
+ :region => "CA",
824
+ :postal_code => "95014",
825
+ :country_name => "United States of America"
826
+ },
827
+ :options => {
828
+ :verify_card => true,
829
+ :verification_amount => "15.00",
830
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
831
+ }
832
+ },
833
+ )
834
+
835
+ apple_pay_card = result.customer.payment_methods.first
836
+ verification = apple_pay_card.verification
837
+
838
+ expect(result).to be_success
839
+ expect(apple_pay_card).to be_a(Braintree::ApplePayCard)
840
+ expect(verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
841
+ expect(verification.amount).to eq(BigDecimal("15.00"))
842
+ expect(verification.merchant_account_id).to eq(SpecHelper::NonDefaultMerchantAccountId)
843
+ end
844
+
604
845
  it "can create a customer with an unknown payment method" do
605
846
  result = Braintree::Customer.create(:payment_method_nonce => Braintree::Test::Nonce::AbstractTransactable)
606
847
 
@@ -1424,6 +1665,315 @@ describe Braintree::Customer do
1424
1665
  expect(result.success?).to eq(true)
1425
1666
  end
1426
1667
 
1668
+ it "can update the customer with apple pay card verification" do
1669
+ customer = Braintree::Customer.create!(
1670
+ :first_name => "Joe",
1671
+ )
1672
+
1673
+ result = Braintree::Customer.update(
1674
+ customer.id,
1675
+ :first_name => "Updated Joe",
1676
+ :apple_pay_card => {
1677
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1678
+ :expiration_month => "12",
1679
+ :expiration_year => "2025",
1680
+ :cryptogram => "ApplePayCryptogram123",
1681
+ :eci_indicator => "07",
1682
+ :cardholder_name => "Updated Joe Cardholder",
1683
+ :options => {
1684
+ :verify_card => true,
1685
+ :verification_amount => "3.50",
1686
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId
1687
+ }
1688
+ },
1689
+ )
1690
+
1691
+ expect(result.success?).to eq(true)
1692
+ expect(result.customer.first_name).to eq("Updated Joe")
1693
+
1694
+ apple_pay_card = result.customer.payment_methods.find { |pm| pm.is_a?(Braintree::ApplePayCard) }
1695
+ expect(apple_pay_card).not_to be_nil
1696
+ expect(apple_pay_card.last_4).to eq(Braintree::Test::CreditCardNumbers::Visa[-4..-1])
1697
+ expect(apple_pay_card.cardholder_name).to eq("Updated Joe Cardholder")
1698
+
1699
+ verification = apple_pay_card.verification
1700
+ expect(verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
1701
+ expect(verification.amount).to eq(BigDecimal("3.50"))
1702
+ expect(verification.merchant_account_id).to eq(SpecHelper::NonDefaultMerchantAccountId)
1703
+ end
1704
+
1705
+ it "verifies the apple pay card when only verify_card set to true is provided" do
1706
+ customer = Braintree::Customer.create!(
1707
+ :first_name => "Joe",
1708
+ )
1709
+
1710
+ result = Braintree::Customer.update(
1711
+ customer.id,
1712
+ :apple_pay_card => {
1713
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1714
+ :expiration_month => "12",
1715
+ :expiration_year => "2025",
1716
+ :cryptogram => "ApplePayCryptogram123",
1717
+ :options => {
1718
+ :verify_card => true,
1719
+ }
1720
+ },
1721
+ )
1722
+
1723
+ expect(result).to be_success
1724
+ expect(result.customer.payment_methods.first).to be_a(Braintree::ApplePayCard)
1725
+ verification = result.customer.payment_methods.first.verification
1726
+ expect(verification).not_to be_nil
1727
+ end
1728
+
1729
+ it "does not verify the apple pay card when verify_card is false" do
1730
+ customer = Braintree::Customer.create!(
1731
+ :first_name => "Joe",
1732
+ )
1733
+
1734
+ result = Braintree::Customer.update(
1735
+ customer.id,
1736
+ :apple_pay_card => {
1737
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1738
+ :expiration_month => "12",
1739
+ :expiration_year => "2025",
1740
+ :cryptogram => "ApplePayCryptogram123",
1741
+ :options => {
1742
+ :verify_card => false,
1743
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
1744
+ :verification_amount => "10.00",
1745
+ }
1746
+ },
1747
+ )
1748
+
1749
+ expect(result).to be_success
1750
+ expect(result.customer.payment_methods.first).to be_a(Braintree::ApplePayCard)
1751
+
1752
+ verification = result.customer.payment_methods.first.verification
1753
+ expect(verification).to be_nil
1754
+ end
1755
+
1756
+ it "returns an error when verification_amount is negative during apple pay card update" do
1757
+ customer = Braintree::Customer.create!(
1758
+ :first_name => "Joe",
1759
+ :last_name => "Cool",
1760
+ )
1761
+
1762
+ result = Braintree::Customer.update(
1763
+ customer.id,
1764
+ :first_name => "Updated Joe",
1765
+ :apple_pay_card => {
1766
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1767
+ :expiration_month => "05",
1768
+ :expiration_year => "2025",
1769
+ :cryptogram => "some_cryptogram",
1770
+ :eci_indicator => "7",
1771
+ :options => {
1772
+ :verify_card => true,
1773
+ :verification_amount => "-1.00"
1774
+ }
1775
+ },
1776
+ )
1777
+
1778
+ expect(result.success?).to eq(false)
1779
+ expect(result.errors.for(:apple_pay).for(:options).on(:verification_amount)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAmountCannotBeNegative
1780
+ end
1781
+
1782
+ it "errors when verification amount format is invalid for apple pay" do
1783
+ customer = Braintree::Customer.create!(
1784
+ :first_name => "Joe",
1785
+ )
1786
+
1787
+ result = Braintree::Customer.update(
1788
+ customer.id,
1789
+ :apple_pay_card => {
1790
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1791
+ :expiration_month => "12",
1792
+ :expiration_year => "2025",
1793
+ :cryptogram => "ApplePayCryptogram123",
1794
+ :options => {
1795
+ :verify_card => true,
1796
+ :verification_amount => "0.001",
1797
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
1798
+ }
1799
+ },
1800
+ )
1801
+
1802
+ expect(result).to_not be_success
1803
+ expect(result.errors.for(:apple_pay).for(:options).on(:verification_amount)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAmountFormatIsInvalid
1804
+ end
1805
+
1806
+ it "errors when verification amount is not supported for processor on apple pay" do
1807
+ customer = Braintree::Customer.create!(
1808
+ :first_name => "Joe",
1809
+ )
1810
+
1811
+ result = Braintree::Customer.update(
1812
+ customer.id,
1813
+ :apple_pay_card => {
1814
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1815
+ :expiration_month => "12",
1816
+ :expiration_year => "2025",
1817
+ :cryptogram => "ApplePayCryptogram123",
1818
+ :options => {
1819
+ :verify_card => true,
1820
+ :verification_amount => "0.01",
1821
+ :verification_merchant_account_id => SpecHelper::CardProcessorBRLMerchantAccountId,
1822
+ }
1823
+ },
1824
+ )
1825
+
1826
+ expect(result).to_not be_success
1827
+ expect(result.errors.for(:apple_pay).for(:options).on(:verification_amount)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAmountNotSupportedByProcessor
1828
+ end
1829
+
1830
+ it "errors when verification amount is too large on apple pay" do
1831
+ customer = Braintree::Customer.create!(
1832
+ :first_name => "Joe",
1833
+ )
1834
+
1835
+ result = Braintree::Customer.update(
1836
+ customer.id,
1837
+ :apple_pay_card => {
1838
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1839
+ :expiration_month => "12",
1840
+ :expiration_year => "2025",
1841
+ :cryptogram => "ApplePayCryptogram123",
1842
+ :options => {
1843
+ :verify_card => true,
1844
+ :verification_amount => ((2**31) / 100.0).to_s,
1845
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
1846
+ }
1847
+ },
1848
+ )
1849
+
1850
+ expect(result).to_not be_success
1851
+ expect(result.errors.for(:apple_pay).for(:options).on(:verification_amount)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAmountIsTooLarge
1852
+ end
1853
+
1854
+ it "errors when verification merchant account is invalid" do
1855
+ customer = Braintree::Customer.create!(
1856
+ :first_name => "Joe",
1857
+ )
1858
+
1859
+ result = Braintree::Customer.update(
1860
+ customer.id,
1861
+ :apple_pay_card => {
1862
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1863
+ :expiration_month => "12",
1864
+ :expiration_year => "2025",
1865
+ :cryptogram => "ApplePayCryptogram123",
1866
+ :options => {
1867
+ :verify_card => true,
1868
+ :verification_amount => "10.00",
1869
+ :verification_merchant_account_id => "BAD_MERCHANT_ACCOUNT",
1870
+ }
1871
+ },
1872
+ )
1873
+
1874
+ expect(result).to_not be_success
1875
+ expect(result.errors.for(:apple_pay).for(:options).on(:verification_merchant_account_id)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationMerchantAccountIdIsInvalid
1876
+ end
1877
+
1878
+ it "errors when verification merchant account is suspended" do
1879
+ customer = Braintree::Customer.create!(
1880
+ :first_name => "Joe",
1881
+ )
1882
+
1883
+ result = Braintree::Customer.update(
1884
+ customer.id,
1885
+ :apple_pay_card => {
1886
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1887
+ :expiration_month => "12",
1888
+ :expiration_year => "2025",
1889
+ :cryptogram => "ApplePayCryptogram123",
1890
+ :options => {
1891
+ :verify_card => true,
1892
+ :verification_amount => "10.00",
1893
+ :verification_merchant_account_id => SpecHelper::SuspendedAccount,
1894
+ }
1895
+ },
1896
+ )
1897
+
1898
+ expect(result).to_not be_success
1899
+ expect(result.errors.for(:apple_pay).for(:options).on(:verification_merchant_account_id)[1].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationMerchantAccountIsSuspended
1900
+ end
1901
+
1902
+ it "errors when network_transaction_id is present for an apple pay verification" do
1903
+ customer = Braintree::Customer.create!(
1904
+ :first_name => "Joe",
1905
+ )
1906
+
1907
+ result = Braintree::Customer.update(
1908
+ customer.id,
1909
+ :apple_pay_card => {
1910
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1911
+ :expiration_month => "12",
1912
+ :expiration_year => "2025",
1913
+ :cryptogram => "ApplePayCryptogram123",
1914
+ :network_transaction_id => "test123",
1915
+ :options => {
1916
+ :verify_card => true,
1917
+ :verification_amount => "10.00",
1918
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
1919
+ }
1920
+ },
1921
+ )
1922
+
1923
+ expect(result).to_not be_success
1924
+ expect(result.errors.for(:apple_pay).on(:network_transaction_id_not_allowed)[0].code).to eq Braintree::ErrorCodes::ApplePay::NetworkTransactionIdNotAllowed
1925
+ end
1926
+
1927
+ it "errors with invalid account_type for apple pay" do
1928
+ customer = Braintree::Customer.create!(
1929
+ :first_name => "Joe",
1930
+ )
1931
+
1932
+ result = Braintree::Customer.update(
1933
+ customer.id,
1934
+ :apple_pay_card => {
1935
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1936
+ :expiration_month => "12",
1937
+ :expiration_year => "2025",
1938
+ :cryptogram => "ApplePayCryptogram123",
1939
+ :options => {
1940
+ :verify_card => true,
1941
+ :verification_amount => "10.00",
1942
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
1943
+ :verification_account_type => "ach",
1944
+ }
1945
+ },
1946
+ )
1947
+
1948
+ expect(result).to_not be_success
1949
+ expect(result.errors.for(:apple_pay).on(:verification_account_type)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAccountTypeIsInvalid
1950
+ end
1951
+
1952
+ it "errors when account_type not supported by merchant on apple_pay" do
1953
+ customer = Braintree::Customer.create!(
1954
+ :first_name => "Joe",
1955
+ )
1956
+
1957
+ result = Braintree::Customer.update(
1958
+ customer.id,
1959
+ :apple_pay_card => {
1960
+ :number => Braintree::Test::CreditCardNumbers::Visa,
1961
+ :expiration_month => "12",
1962
+ :expiration_year => "2025",
1963
+ :cryptogram => "ApplePayCryptogram123",
1964
+ :options => {
1965
+ :verify_card => true,
1966
+ :verification_amount => "10.00",
1967
+ :verification_merchant_account_id => SpecHelper::NonDefaultMerchantAccountId,
1968
+ :verification_account_type => "credit",
1969
+ }
1970
+ },
1971
+ )
1972
+
1973
+ expect(result).to_not be_success
1974
+ expect(result.errors.for(:apple_pay).for(:options).on(:verification_account_type)[0].code).to eq Braintree::ErrorCodes::ApplePay::Options::VerificationAccountTypeNotSupported
1975
+ end
1976
+
1427
1977
  it "includes risk data when skip_advanced_fraud_checking is false" do
1428
1978
  with_fraud_protection_enterprise_merchant do
1429
1979
  customer = Braintree::Customer.create!(
@@ -258,7 +258,7 @@ describe Braintree::Http do
258
258
  context = OpenSSL::X509::StoreContext.new(OpenSSL::X509::Store.new)
259
259
  context.error = 19
260
260
  expect(Braintree::Configuration.instantiate.http._verify_ssl_certificate(false, context)).to eq(false)
261
- expect(output.string).to include("SSL Verification failed -- Preverify: false, Error: self signed certificate in certificate chain (19)")
261
+ expect(output.string).to match(/SSL Verification failed -- Preverify: false, Error: self[ -]?signed certificate in certificate chain \(19\)/)
262
262
  ensure
263
263
  Braintree::Configuration.logger = old_logger
264
264
  end