braintree 4.26.0 → 4.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/apple_pay_card.rb +4 -0
  3. data/lib/braintree/bin_data.rb +7 -2
  4. data/lib/braintree/configuration.rb +1 -1
  5. data/lib/braintree/credit_card.rb +11 -5
  6. data/lib/braintree/credit_card_gateway.rb +1 -0
  7. data/lib/braintree/credit_card_verification_gateway.rb +1 -0
  8. data/lib/braintree/customer_session_gateway.rb +11 -10
  9. data/lib/braintree/error_codes.rb +5 -104
  10. data/lib/braintree/google_pay_card.rb +4 -0
  11. data/lib/braintree/graphql/enums/recommendations.rb +2 -0
  12. data/lib/braintree/graphql/enums/recommended_payment_option.rb +2 -0
  13. data/lib/braintree/graphql/inputs/create_customer_session_input.rb +10 -1
  14. data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +7 -8
  15. data/lib/braintree/graphql/inputs/customer_session_input.rb +6 -0
  16. data/lib/braintree/graphql/inputs/monetary_amount_input.rb +28 -0
  17. data/lib/braintree/graphql/inputs/paypal_payee_input.rb +28 -0
  18. data/lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb +31 -0
  19. data/lib/braintree/graphql/inputs/phone_input.rb +2 -0
  20. data/lib/braintree/graphql/inputs/update_customer_session_input.rb +5 -0
  21. data/lib/braintree/graphql/types/customer_recommendations_payload.rb +112 -18
  22. data/lib/braintree/graphql/types/payment_options.rb +2 -0
  23. data/lib/braintree/graphql/types/payment_recommendations.rb +35 -0
  24. data/lib/braintree/graphql/unions/customer_recommendations.rb +38 -25
  25. data/lib/braintree/merchant_account.rb +1 -25
  26. data/lib/braintree/merchant_account_gateway.rb +0 -81
  27. data/lib/braintree/meta_checkout_card.rb +8 -4
  28. data/lib/braintree/meta_checkout_token.rb +10 -6
  29. data/lib/braintree/payment_method_gateway.rb +3 -0
  30. data/lib/braintree/test/credit_card.rb +4 -0
  31. data/lib/braintree/transaction/apple_pay_details.rb +4 -0
  32. data/lib/braintree/transaction/credit_card_details.rb +8 -0
  33. data/lib/braintree/transaction/google_pay_details.rb +4 -0
  34. data/lib/braintree/transaction/meta_checkout_card_details.rb +9 -3
  35. data/lib/braintree/transaction/meta_checkout_token_details.rb +11 -5
  36. data/lib/braintree/transaction/visa_checkout_card_details.rb +8 -3
  37. data/lib/braintree/transaction.rb +0 -26
  38. data/lib/braintree/transaction_gateway.rb +9 -20
  39. data/lib/braintree/version.rb +1 -1
  40. data/lib/braintree/visa_checkout_card.rb +9 -4
  41. data/lib/braintree/webhook_notification.rb +0 -4
  42. data/lib/braintree/webhook_testing_gateway.rb +0 -33
  43. data/lib/braintree.rb +4 -3
  44. data/spec/integration/braintree/credit_card_spec.rb +101 -0
  45. data/spec/integration/braintree/credit_card_verification_spec.rb +118 -0
  46. data/spec/integration/braintree/customer_session_spec.rb +59 -49
  47. data/spec/integration/braintree/customer_spec.rb +71 -4
  48. data/spec/integration/braintree/disbursement_spec.rb +1 -1
  49. data/spec/integration/braintree/merchant_account_spec.rb +0 -342
  50. data/spec/integration/braintree/payment_method_nonce_spec.rb +44 -0
  51. data/spec/integration/braintree/payment_method_spec.rb +50 -3
  52. data/spec/integration/braintree/transaction_payment_facilitator_spec.rb +119 -0
  53. data/spec/integration/braintree/transaction_spec.rb +60 -328
  54. data/spec/spec_helper.rb +1 -1
  55. data/spec/unit/braintree/apple_pay_card_spec.rb +4 -0
  56. data/spec/unit/braintree/configuration_spec.rb +1 -1
  57. data/spec/unit/braintree/credit_card_spec.rb +22 -2
  58. data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +1 -0
  59. data/spec/unit/braintree/customer_session_gateway_spec.rb +10 -9
  60. data/spec/unit/braintree/customer_spec.rb +2 -1
  61. data/spec/unit/braintree/google_pay_card_spec.rb +20 -0
  62. data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +25 -4
  63. data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +21 -51
  64. data/spec/unit/braintree/graphql/customer_recommendations_spec.rb +40 -0
  65. data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +21 -7
  66. data/spec/unit/braintree/meta_checkout_card_spec.rb +8 -0
  67. data/spec/unit/braintree/meta_checkout_token_spec.rb +4 -0
  68. data/spec/unit/braintree/payment_method_nonce_spec.rb +9 -2
  69. data/spec/unit/braintree/payment_method_spec.rb +12 -0
  70. data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +20 -0
  71. data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -1
  72. data/spec/unit/braintree/transaction/google_pay_details_spec.rb +20 -0
  73. data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +20 -0
  74. data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +20 -0
  75. data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +20 -0
  76. data/spec/unit/braintree/transaction_gateway_spec.rb +19 -0
  77. data/spec/unit/braintree/transaction_spec.rb +8 -0
  78. data/spec/unit/braintree/visa_checkout_card_spec.rb +20 -0
  79. data/spec/unit/braintree/webhook_notification_spec.rb +0 -53
  80. data/spec/unit/credit_card_details_spec.rb +20 -0
  81. metadata +8 -7
  82. data/lib/braintree/merchant_account/business_details.rb +0 -17
  83. data/lib/braintree/merchant_account/funding_details.rb +0 -18
  84. data/lib/braintree/merchant_account/individual_details.rb +0 -20
  85. data/spec/unit/braintree/disbursement_spec.rb +0 -131
  86. data/spec/unit/braintree/merchant_account_spec.rb +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca8e969e0988757df5800a440fdc36293b48bc0c72cc8c56b1175d74d79f309b
4
- data.tar.gz: b44530a7eb4a73728fd4c79292633fc7d7ca0d6476c26b7277c1a3051d29fcaa
3
+ metadata.gz: f1eb371a013154345b87d1581d335e2e164844b06cfbc720574cc68819d8839f
4
+ data.tar.gz: ec7325707abf2ad90b2d17ca390ece11adead95ba1f2e8cd4fb42e78470a225b
5
5
  SHA512:
6
- metadata.gz: 2d985f754fa864774601dad717587b5d5d7f1e75a9579286100559e9cd4ab1819fd856b5c90c6d59870149b6d7bfd0cc5d2865f2d96362a208c037854b9ab312
7
- data.tar.gz: 2ab4e8c0f48d76e10f4854e3e32fe55c154c8bdd40730625409f4259921268788c9bd2baf3152724a6d665ed5d0bf53dc7b540570f2f9777ced5dc53be6aeaa8
6
+ metadata.gz: 76fb4902a1ace12c7b7730bd911296143b941de6b8d0a5cc018f1dba3ecb35c1090b00a3d0387e85cf0a54938d578fb2c29b2cf9c06674556d4509572cb24636
7
+ data.tar.gz: 404445aad78f100dcec0ece96b1d0e7f7f6103afc869333b23d6754bac28ef70f367ef0b1580f7716a4388f2f36129bcc4dcf3c4c547d70f83da5d6e5ad90b75
@@ -12,9 +12,12 @@ module Braintree
12
12
 
13
13
  attr_reader :billing_address
14
14
  attr_reader :bin
15
+ attr_reader :business
15
16
  attr_reader :card_type
16
17
  attr_reader :cardholder_name
17
18
  attr_reader :commercial
19
+ attr_reader :consumer
20
+ attr_reader :corporate
18
21
  attr_reader :country_of_issuance
19
22
  attr_reader :created_at
20
23
  attr_reader :customer_id
@@ -34,6 +37,7 @@ module Braintree
34
37
  attr_reader :prepaid
35
38
  attr_reader :prepaid_reloadable
36
39
  attr_reader :product_id
40
+ attr_reader :purchase
37
41
  attr_reader :source_card_last4
38
42
  attr_reader :source_description
39
43
  attr_reader :subscriptions
@@ -2,7 +2,10 @@ module Braintree
2
2
  class BinData
3
3
  include BaseModule
4
4
 
5
+ attr_reader :business
5
6
  attr_reader :commercial
7
+ attr_reader :consumer
8
+ attr_reader :corporate
6
9
  attr_reader :country_of_issuance
7
10
  attr_reader :debit
8
11
  attr_reader :durbin_regulated
@@ -12,6 +15,7 @@ module Braintree
12
15
  attr_reader :prepaid
13
16
  attr_reader :prepaid_reloadable
14
17
  attr_reader :product_id
18
+ attr_reader :purchase
15
19
 
16
20
  def initialize(attributes)
17
21
  set_instance_variables_from_hash attributes unless attributes.nil?
@@ -26,8 +30,9 @@ module Braintree
26
30
 
27
31
  def self._attributes
28
32
  [
29
- :commercial, :country_of_issuance, :debit, :durbin_regulated, :healthcare,
30
- :issuing_bank, :payroll, :prepaid, :prepaid_reloadable, :product_id
33
+ :business, :commercial, :consumer, :corporate, :country_of_issuance, :debit,
34
+ :durbin_regulated, :healthcare, :issuing_bank, :payroll, :prepaid,
35
+ :prepaid_reloadable, :product_id, :purchase
31
36
  ]
32
37
  end
33
38
  end
@@ -239,7 +239,7 @@ module Braintree
239
239
  when :production
240
240
  "#{endpoint}.braintreegateway.com"
241
241
  when :qa
242
- "gateway.qa2.braintreepayments.com"
242
+ "gateway.qa.braintreepayments.com"
243
243
  when :sandbox
244
244
  "api.sandbox.braintreegateway.com"
245
245
  end
@@ -45,14 +45,18 @@ module Braintree
45
45
  Unknown = "Unknown"
46
46
  end
47
47
 
48
- Commercial = CountryOfIssuance = Debit = DurbinRegulated = Healthcare =
49
- IssuingBank = Payroll = Prepaid = PrepaidReloadable = ProductId = CardTypeIndicator
48
+ Business = Commercial = Consumer = Corporate = CountryOfIssuance = Debit =
49
+ DurbinRegulated = Healthcare = IssuingBank = Payroll = Prepaid = PrepaidReloadable =
50
+ ProductId = Purchase = CardTypeIndicator
50
51
 
51
52
  attr_reader :billing_address
52
53
  attr_reader :bin
54
+ attr_reader :business
53
55
  attr_reader :card_type
54
56
  attr_reader :cardholder_name
55
57
  attr_reader :commercial
58
+ attr_reader :consumer
59
+ attr_reader :corporate
56
60
  attr_reader :country_of_issuance
57
61
  attr_reader :created_at
58
62
  attr_reader :customer_id
@@ -68,6 +72,7 @@ module Braintree
68
72
  attr_reader :prepaid
69
73
  attr_reader :prepaid_reloadable
70
74
  attr_reader :product_id
75
+ attr_reader :purchase
71
76
  attr_reader :subscriptions
72
77
  attr_reader :token
73
78
  attr_reader :unique_number_identifier
@@ -200,9 +205,10 @@ module Braintree
200
205
 
201
206
  def self._attributes
202
207
  [
203
- :billing_address, :bin, :card_type, :cardholder_name, :commercial, :country_of_issuance, :created_at, :customer_id,
204
- :debit, :durbin_regulated, :expiration_month, :expiration_year, :healthcare, :image_url, :is_network_tokenized?,
205
- :issuing_bank, :last_4, :payroll, :prepaid, :prepaid_reloadable, :product_id, :token, :updated_at
208
+ :billing_address, :bin, :business, :card_type, :cardholder_name, :commercial, :consumer, :corporate,
209
+ :country_of_issuance, :created_at, :customer_id, :debit, :durbin_regulated, :expiration_month,
210
+ :expiration_year, :healthcare, :image_url, :is_network_tokenized?, :issuing_bank, :last_4, :payroll,
211
+ :prepaid, :prepaid_reloadable, :product_id, :purchase, :token, :updated_at
206
212
  ]
207
213
  end
208
214
 
@@ -96,6 +96,7 @@ module Braintree
96
96
  # NEXT_MAJOR_VERSION Remove venmo_sdk_session
97
97
  # The old venmo SDK class has been deprecated
98
98
  options = [
99
+ :account_information_inquiry,
99
100
  :fail_on_duplicate_payment_method,
100
101
  :fail_on_duplicate_payment_method_for_customer,
101
102
  :make_default,
@@ -61,6 +61,7 @@ module Braintree
61
61
  ]},
62
62
  :intended_transaction_source,
63
63
  {:options => [
64
+ :account_information_inquiry,
64
65
  :account_type,
65
66
  :amount,
66
67
  :merchant_account_id,
@@ -19,16 +19,13 @@ module Braintree
19
19
  GRAPHQL
20
20
 
21
21
  GET_CUSTOMER_RECOMMENDATIONS = <<~GRAPHQL
22
- query CustomerRecommendations($input: CustomerRecommendationsInput!) {
23
- customerRecommendations(input: $input) {
22
+ mutation GenerateCustomerRecommendations($input: GenerateCustomerRecommendationsInput!) {
23
+ generateCustomerRecommendations(input: $input) {
24
+ sessionId
24
25
  isInPayPalNetwork
25
- recommendations {
26
- ... on PaymentRecommendations {
27
- paymentOptions {
26
+ paymentRecommendations {
28
27
  paymentOption
29
28
  recommendedPriority
30
- }
31
- }
32
29
  }
33
30
  }
34
31
  }
@@ -143,7 +140,11 @@ module Braintree
143
140
  SuccessfulResult.new(:customer_recommendations => extract_customer_recommendations_payload(response))
144
141
  end
145
142
  rescue StandardError => e
146
- raise UnexpectedError, e.message
143
+ if e.message.include?("Authorization failed")
144
+ raise AuthorizationError, e.message
145
+ else
146
+ raise ServerError, e.message
147
+ end
147
148
  end
148
149
  end
149
150
 
@@ -187,8 +188,8 @@ module Braintree
187
188
  end
188
189
 
189
190
  def extract_customer_recommendations_payload(data)
190
- customer_recommendations_hash = get_value(data, "data.customerRecommendations")
191
- Braintree::CustomerRecommendationsPayload._new(customer_recommendations_hash)
191
+ customer_recommendations_hash = get_value(data, "data.generateCustomerRecommendations")
192
+ Braintree::CustomerRecommendationsPayload._new({:response => {"generateCustomerRecommendations" => customer_recommendations_hash}})
192
193
  end
193
194
  end
194
195
  end
@@ -116,7 +116,6 @@ module Braintree
116
116
  VerificationAmountFormatIsInvalid = "91740"
117
117
  VerificationAmountIsTooLarge = "91752"
118
118
  VerificationAmountNotSupportedByProcessor = "91741"
119
- VerificationMerchantAccountCannotBeSubMerchantAccount = "91755"
120
119
  VerificationMerchantAccountIdIsInvalid = "91728"
121
120
  VerificationMerchantAccountIsForbidden = "91743"
122
121
  VerificationMerchantAccountIsSuspended = "91742"
@@ -191,6 +190,10 @@ module Braintree
191
190
  AndroidPayCardsAreNotAccepted = "83708"
192
191
  end
193
192
 
193
+ module PaymentFacilitator
194
+ PaymentFacilitatorNotApplicable = "97405"
195
+ end
196
+
194
197
  module PayPalAccount
195
198
  AuthExpired = "92911"
196
199
  CannotHaveBothAccessTokenAndConsentCode = "82903"
@@ -337,21 +340,16 @@ module Braintree
337
340
  BillingAddressConflict = "91530"
338
341
  BillingPhoneNumberIsInvalid = "915206"
339
342
  CannotBeVoided = "91504"
340
- CannotCancelRelease = "91562"
341
343
  CannotCloneCredit = "91543"
342
- CannotCloneMarketplaceTransaction = "915137"
343
344
  CannotCloneTransactionWithPayPalAccount = "91573"
344
345
  CannotCloneTransactionWithVaultCreditCard = "91540"
345
346
  CannotCloneUnsuccessfulTransaction = "91542"
346
347
  CannotCloneVoiceAuthorizations = "91541"
347
- CannotHoldInEscrow = "91560"
348
- CannotPartiallyRefundEscrowedTransaction = "91563"
349
348
  CannotRefundCredit = "91505"
350
349
  CannotRefundSettlingTransaction = "91574"
351
350
  CannotRefundUnlessSettled = "91506"
352
351
  CannotRefundWithPendingMerchantAccount = "91559"
353
352
  CannotRefundWithSuspendedMerchantAccount = "91538"
354
- CannotReleaseFromEscrow = "91561"
355
353
  CannotSimulateTransactionSettlement = "91575"
356
354
  CannotSubmitForSettlement = "91507"
357
355
  CannotUpdateTransactionDetailsNotSubmittedForSettlement = "915129"
@@ -434,7 +432,6 @@ module Braintree
434
432
  ShipsFromPostalCodeInvalidCharacters = "915167"
435
433
  ShipsFromPostalCodeIsInvalid = "915166"
436
434
  ShipsFromPostalCodeIsTooLong = "915165"
437
- SubMerchantAccountRequiresServiceFeeAmount = "91553"
438
435
  SubscriptionDoesNotBelongToCustomer = "91529"
439
436
  SubscriptionIdIsInvalid = "91528"
440
437
  SubscriptionStatusMustBePastDue = "91531"
@@ -468,6 +465,7 @@ module Braintree
468
465
  UsBankAccountNonceMustBePlaidVerified = "915171"
469
466
  UsBankAccountNotVerified = "915172"
470
467
 
468
+
471
469
  module Options
472
470
  SubmitForSettlementIsRequiredForCloning = "91544"
473
471
  SubmitForSettlementIsRequiredForPayPalUnilateral = "91582"
@@ -639,110 +637,14 @@ module Braintree
639
637
  end
640
638
 
641
639
  module MerchantAccount
642
- CannotBeUpdated = "82674"
643
- Declined = "82626"
644
- DeclinedFailedKYC = "82623"
645
- DeclinedMasterCardMatch = "82622"
646
- DeclinedOFAC = "82621"
647
- DeclinedSsnInvalid = "82624"
648
- DeclinedSsnMatchesDeceased = "82625"
649
- IdCannotBeUpdated = "82675"
650
- IdFormatIsInvalid = "82603"
651
- IdIsInUse = "82604"
652
- IdIsNotAllowed = "82605"
653
- IdIsTooLong = "82602"
654
- MasterMerchantAccountIdCannotBeUpdated = "82676"
655
- MasterMerchantAccountIdIsInvalid = "82607"
656
- MasterMerchantAccountIdIsRequired = "82606"
657
- MasterMerchantAccountMustBeActive = "82608"
658
- TosAcceptedIsRequired = "82610"
659
640
 
660
641
  module ApplicantDetails
661
- AccountNumberIsInvalid = "82670"
662
- AccountNumberIsRequired = "82614"
663
- CompanyNameIsInvalid = "82631"
664
- CompanyNameIsRequiredWithTaxId = "82633"
665
- DateOfBirthIsInvalid = "82663"
666
- DateOfBirthIsRequired = "82612"
667
642
  Declined = "82626" # Keep for backwards compatibility
668
643
  DeclinedFailedKYC = "82623" # Keep for backwards compatibility
669
644
  DeclinedMasterCardMatch = "82622" # Keep for backwards compatibility
670
645
  DeclinedOFAC = "82621" # Keep for backwards compatibility
671
646
  DeclinedSsnInvalid = "82624" # Keep for backwards compatibility
672
647
  DeclinedSsnMatchesDeceased = "82625" # Keep for backwards compatibility
673
- EmailAddressIsInvalid = "82616"
674
- EmailAddressIsRequired = "82665"
675
- FirstNameIsInvalid = "82627"
676
- FirstNameIsRequired = "82609"
677
- LastNameIsInvalid = "82628"
678
- LastNameIsRequired = "82611"
679
- PhoneIsInvalid = "82636"
680
- RoutingNumberIsInvalid = "82635"
681
- RoutingNumberIsRequired = "82613"
682
- SsnIsInvalid = "82615"
683
- TaxIdIsInvalid = "82632"
684
- TaxIdIsRequiredWithCompanyName = "82634"
685
- TaxIdMustBeBlank = "82673"
686
-
687
- module Address
688
- LocalityIsRequired = "82618"
689
- PostalCodeIsInvalid = "82630"
690
- PostalCodeIsRequired = "82619"
691
- RegionIsInvalid = "82664"
692
- RegionIsRequired = "82620"
693
- StreetAddressIsInvalid = "82629"
694
- StreetAddressIsRequired = "82617"
695
- end
696
- end
697
-
698
- module Individual
699
- DateOfBirthIsInvalid = "82666"
700
- DateOfBirthIsRequired = "82639"
701
- EmailIsInvalid = "82643"
702
- EmailIsRequired = "82667"
703
- FirstNameIsInvalid = "82644"
704
- FirstNameIsRequired = "82637"
705
- LastNameIsInvalid = "82645"
706
- LastNameIsRequired = "82638"
707
- PhoneIsInvalid = "82656"
708
- SsnIsInvalid = "82642"
709
-
710
- module Address
711
- LocalityIsRequired = "82658"
712
- PostalCodeIsInvalid = "82662"
713
- PostalCodeIsRequired = "82659"
714
- RegionIsInvalid = "82668"
715
- RegionIsRequired = "82660"
716
- StreetAddressIsInvalid = "82661"
717
- StreetAddressIsRequired = "82657"
718
- end
719
- end
720
-
721
- module Business
722
- DbaNameIsInvalid = "82646"
723
- LegalNameIsInvalid = "82677"
724
- LegalNameIsRequiredWithTaxId = "82669"
725
- TaxIdIsInvalid = "82647"
726
- TaxIdIsRequiredWithLegalName = "82648"
727
- TaxIdMustBeBlank = "82672"
728
- module Address
729
- PostalCodeIsInvalid = "82686"
730
- RegionIsInvalid = "82684"
731
- StreetAddressIsInvalid = "82685"
732
- end
733
- end
734
-
735
- module Funding
736
- AccountNumberIsInvalid = "82671"
737
- AccountNumberIsRequired = "82641"
738
- DestinationIsInvalid = "82679"
739
- DestinationIsRequired = "82678"
740
- EmailIsInvalid = "82681"
741
- EmailIsRequired = "82680"
742
- MobilePhoneIsInvalid = "82683"
743
- MobilePhoneIsRequired = "82682"
744
- RoutingNumberIsInvalid = "82649"
745
- RoutingNumberIsRequired = "82640"
746
648
  end
747
649
  end
748
650
 
@@ -808,7 +710,6 @@ module Braintree
808
710
  AmountFormatIsInvalid = "94202"
809
711
  AmountIsTooLarge = "94207"
810
712
  AmountNotSupportedByProcessor = "94203"
811
- MerchantAccountCannotBeSubMerchantAccount = "94208"
812
713
  MerchantAccountIdIsInvalid = "94204"
813
714
  MerchantAccountIsForbidden = "94206"
814
715
  MerchantAccountIsSuspended = "94205"
@@ -3,7 +3,10 @@ module Braintree
3
3
  include BaseModule
4
4
 
5
5
  attr_reader :bin
6
+ attr_reader :business
6
7
  attr_reader :commercial
8
+ attr_reader :consumer
9
+ attr_reader :corporate
7
10
  attr_reader :country_of_issuance
8
11
  attr_reader :created_at
9
12
  attr_reader :customer_id
@@ -20,6 +23,7 @@ module Braintree
20
23
  attr_reader :prepaid
21
24
  attr_reader :prepaid_reloadable
22
25
  attr_reader :product_id
26
+ attr_reader :purchase
23
27
  attr_reader :source_card_last_4
24
28
  attr_reader :source_card_type
25
29
  attr_reader :source_description
@@ -1,5 +1,7 @@
1
1
  # Represents available types of customer recommendations that can be retrieved using a PayPal customer session.
2
2
 
3
+ #Experimental
4
+ # This enum is experimental and may change in future releases.
3
5
  module Braintree
4
6
  module Recommendations
5
7
  PAYMENT_RECOMMENDATIONS = "PAYMENT_RECOMMENDATIONS"
@@ -1,5 +1,7 @@
1
1
  # Represents available payment options related to PayPal customer session recommendations.
2
2
 
3
+ #Experimental
4
+ # This enum is experimental and may change in future releases.
3
5
  module Braintree
4
6
  module RecommendedPaymentOption
5
7
  PAYPAL = "PAYPAL"
@@ -1,5 +1,7 @@
1
1
  # Represents the input to request the creation of a PayPal customer session.
2
2
 
3
+ #Experimental
4
+ # This class is experimental and may change in future releases.
3
5
  module Braintree
4
6
  class CreateCustomerSessionInput
5
7
  include BaseModule
@@ -9,12 +11,18 @@ module Braintree
9
11
  attr_reader :session_id
10
12
  attr_reader :customer
11
13
  attr_reader :domain
14
+ attr_reader :purchase_units
12
15
 
13
16
  def initialize(attributes)
14
17
  @attrs = attributes.keys
15
18
  set_instance_variables_from_hash(attributes)
16
19
  @customer = attributes[:customer] ? CustomerSessionInput.new(attributes[:customer]) : nil
17
- end
20
+ if attributes[:purchase_units]
21
+ @purchase_units = attributes[:purchase_units].map do |unit|
22
+ PayPalPurchaseUnitInput.new(unit)
23
+ end
24
+ end
25
+ end
18
26
 
19
27
  def inspect
20
28
  inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
@@ -27,6 +35,7 @@ module Braintree
27
35
  variables["sessionId"] = session_id if session_id
28
36
  variables["domain"] = domain if domain
29
37
  variables["customer"] = customer.to_graphql_variables if customer
38
+ variables["purchaseUnits"] = purchase_units.map(&:to_graphql_variables) if purchase_units
30
39
  variables
31
40
  end
32
41
  end
@@ -1,5 +1,7 @@
1
1
  # Represents the input to request PayPal customer session recommendations.
2
2
 
3
+ #Experimental
4
+ # This class is experimental and may change in future releases.
3
5
  module Braintree
4
6
  class CustomerRecommendationsInput
5
7
  include BaseModule
@@ -7,19 +9,15 @@ module Braintree
7
9
  attr_reader :attrs
8
10
  attr_reader :merchant_account_id
9
11
  attr_reader :session_id
10
- attr_reader :recommendations
11
12
  attr_reader :customer
13
+ attr_reader :purchase_units
14
+ attr_reader :domain
12
15
 
13
16
  def initialize(attributes)
14
- unless attributes[:session_id]
15
- raise ArgumentError, "Expected hash to contain a :session_id"
16
- end
17
- unless attributes[:recommendations]
18
- raise ArgumentError, "Expected hash to contain a :recommendations"
19
- end
20
17
  @attrs = attributes.keys
21
18
  set_instance_variables_from_hash(attributes)
22
19
  @customer = attributes[:customer] ? CustomerSessionInput.new(attributes[:customer]) : nil
20
+ @purchase_units = attributes[:purchase_units] ? attributes[:purchase_units].map { |pu| PayPalPurchaseUnitInput.new(pu) } : nil
23
21
  end
24
22
 
25
23
  def inspect
@@ -31,8 +29,9 @@ module Braintree
31
29
  variables = {}
32
30
  variables["merchantAccountId"] = merchant_account_id if merchant_account_id
33
31
  variables["sessionId"] = session_id if session_id
34
- variables["recommendations"] = recommendations if recommendations
35
32
  variables["customer"] = customer.to_graphql_variables if customer
33
+ variables["domain"] = domain if domain
34
+ variables["purchaseUnits"] = purchase_units.map(&:to_graphql_variables) if purchase_units
36
35
  variables
37
36
  end
38
37
  end
@@ -1,12 +1,16 @@
1
1
  # Customer identifying information for a PayPal customer session.
2
2
 
3
+ #Experimental
4
+ # This class is experimental and may change in future releases.
3
5
  module Braintree
4
6
  class CustomerSessionInput
5
7
  include BaseModule
6
8
 
7
9
  attr_reader :attrs
8
10
  attr_reader :email
11
+ attr_reader :hashed_email
9
12
  attr_reader :phone
13
+ attr_reader :hashed_phone
10
14
  attr_reader :device_fingerprint_id
11
15
  attr_reader :paypal_app_installed
12
16
  attr_reader :venmo_app_installed
@@ -26,7 +30,9 @@ module Braintree
26
30
  def to_graphql_variables
27
31
  variables = {}
28
32
  variables["email"] = email if email
33
+ variables["hashedEmail"] = hashed_email if hashed_email
29
34
  variables["phone"] = phone.to_graphql_variables if phone
35
+ variables["hashedPhone"] = hashed_phone if hashed_phone
30
36
  variables["deviceFingerprintId"] = device_fingerprint_id if device_fingerprint_id
31
37
  variables["paypalAppInstalled"] = paypal_app_installed if paypal_app_installed
32
38
  variables["venmoAppInstalled"] = venmo_app_installed if venmo_app_installed
@@ -0,0 +1,28 @@
1
+ #Experimental
2
+ # This class is experimental and may change in future releases.
3
+ module Braintree
4
+ class MonetaryAmountInput
5
+ include BaseModule
6
+
7
+ attr_reader :attrs
8
+ attr_reader :value
9
+ attr_reader :currency_code
10
+
11
+ def initialize(attributes)
12
+ @attrs = attributes.keys
13
+ set_instance_variables_from_hash(attributes)
14
+ end
15
+
16
+ def inspect
17
+ inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
18
+ "#<#{self.class} #{inspected_attributes.join(" ")}>"
19
+ end
20
+
21
+ def to_graphql_variables
22
+ variables = {}
23
+ variables["value"] = value if value
24
+ variables["currencyCode"] = currency_code if currency_code
25
+ variables
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ #Experimental
2
+ # This class is experimental and may change in future releases.
3
+ module Braintree
4
+ class PayPalPayeeInput
5
+ include BaseModule
6
+
7
+ attr_reader :attrs
8
+ attr_reader :email_address
9
+ attr_reader :client_id
10
+
11
+ def initialize(attributes)
12
+ @attrs = attributes.keys
13
+ set_instance_variables_from_hash(attributes)
14
+ end
15
+
16
+ def inspect
17
+ inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
18
+ "#<#{self.class} #{inspected_attributes.join(" ")}>"
19
+ end
20
+
21
+ def to_graphql_variables
22
+ variables = {}
23
+ variables["emailAddress"] = email_address if email_address
24
+ variables["clientId"] = client_id if client_id
25
+ variables
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,31 @@
1
+ #Experimental
2
+ # This class is experimental and may change in future releases.
3
+ module Braintree
4
+ class PayPalPurchaseUnitInput
5
+ include BaseModule
6
+
7
+ attr_reader :attrs
8
+ attr_reader :amount
9
+ attr_reader :payee
10
+
11
+ def initialize(attributes)
12
+ @attrs = attributes.keys
13
+ unless attributes[:amount]
14
+ raise ArgumentError, "Expected hash to contain a :amount"
15
+ end
16
+ set_instance_variables_from_hash(attributes)
17
+ @payee = attributes[:payee] ? PayPalPayeeInput.new(attributes[:payee]) : nil
18
+ @amount = attributes[:amount] ? MonetaryAmountInput.new(attributes[:amount]) : nil
19
+ end
20
+ def inspect
21
+ inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
22
+ "#<#{self.class} #{inspected_attributes.join(" ")}>"
23
+ end
24
+ def to_graphql_variables
25
+ variables = {}
26
+ variables["amount"] = amount.to_graphql_variables if amount
27
+ variables["payee"] = payee.to_graphql_variables if payee
28
+ variables
29
+ end
30
+ end
31
+ end
@@ -1,5 +1,7 @@
1
1
  # Phone number input for PayPal customer session.
2
2
 
3
+ #Experimental
4
+ # This class is experimental and may change in future releases.
3
5
  module Braintree
4
6
  class PhoneInput
5
7
  include BaseModule
@@ -1,5 +1,7 @@
1
1
  # Represents the input to request an update to a PayPal customer session.
2
2
 
3
+ #Experimental
4
+ # This class is experimental and may change in future releases.
3
5
  module Braintree
4
6
  class UpdateCustomerSessionInput
5
7
  include BaseModule
@@ -8,6 +10,7 @@ module Braintree
8
10
  attr_reader :merchant_account_id
9
11
  attr_reader :session_id
10
12
  attr_reader :customer
13
+ attr_reader :purchase_units
11
14
 
12
15
  def initialize(attributes)
13
16
  unless attributes[:session_id]
@@ -16,6 +19,7 @@ module Braintree
16
19
  @attrs = attributes.keys
17
20
  set_instance_variables_from_hash(attributes)
18
21
  @customer = attributes[:customer] ? CustomerSessionInput.new(attributes[:customer]) : nil
22
+ @purchase_units = attributes[:purchase_units] ? attributes[:purchase_units].map { |pu| PayPalPurchaseUnitInput.new(pu) } : nil
19
23
  end
20
24
 
21
25
  def inspect
@@ -28,6 +32,7 @@ module Braintree
28
32
  variables["merchantAccountId"] = merchant_account_id if merchant_account_id
29
33
  variables["sessionId"] = session_id if session_id
30
34
  variables["customer"] = customer.to_graphql_variables if customer
35
+ variables["purchaseUnits"] = purchase_units.map(&:to_graphql_variables) if purchase_units
31
36
  variables
32
37
  end
33
38