braintree 4.22.0 → 4.23.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 (34) hide show
  1. checksums.yaml +4 -4
  2. data/lib/braintree/client_token_gateway.rb +2 -2
  3. data/lib/braintree/credit_card_gateway.rb +1 -0
  4. data/lib/braintree/customer.rb +2 -1
  5. data/lib/braintree/customer_gateway.rb +2 -0
  6. data/lib/braintree/error_codes.rb +3 -0
  7. data/lib/braintree/local_payment_completed/blik_alias.rb +23 -0
  8. data/lib/braintree/local_payment_completed.rb +2 -0
  9. data/lib/braintree/payment_instrument_type.rb +1 -0
  10. data/lib/braintree/payment_method_gateway.rb +3 -0
  11. data/lib/braintree/payment_method_parser.rb +1 -0
  12. data/lib/braintree/samsung_pay_card.rb +2 -0
  13. data/lib/braintree/test/nonce.rb +1 -0
  14. data/lib/braintree/transaction/local_payment_details.rb +1 -0
  15. data/lib/braintree/transaction/samsung_pay_card_details.rb +2 -0
  16. data/lib/braintree/transaction.rb +2 -1
  17. data/lib/braintree/version.rb +1 -1
  18. data/lib/braintree/webhook_testing_gateway.rb +33 -0
  19. data/lib/braintree.rb +1 -0
  20. data/lib/ssl/api_braintreegateway_com.ca.crt +401 -168
  21. data/spec/integration/braintree/client_api/client_token_spec.rb +229 -38
  22. data/spec/integration/braintree/credit_card_spec.rb +2 -2
  23. data/spec/integration/braintree/credit_card_verification_spec.rb +1 -1
  24. data/spec/integration/braintree/customer_spec.rb +23 -2
  25. data/spec/integration/braintree/payment_method_spec.rb +29 -2
  26. data/spec/integration/braintree/samsung_pay_card_spec.rb +3 -1
  27. data/spec/integration/braintree/transaction_spec.rb +0 -21
  28. data/spec/unit/braintree/client_token_spec.rb +1 -1
  29. data/spec/unit/braintree/credit_card_spec.rb +2 -2
  30. data/spec/unit/braintree/customer_spec.rb +1 -0
  31. data/spec/unit/braintree/local_payment_completed_spec.rb +28 -0
  32. data/spec/unit/braintree/transaction/local_payment_details_spec.rb +6 -0
  33. data/spec/unit/braintree/webhook_notification_spec.rb +22 -1
  34. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3eefd7e093c28bf6167e2147719c79ddfde8823a01d2a5941d3b88b7ddb7b001
4
- data.tar.gz: b61191ffd282fad509d02061f26f4fd61bdead52eaa33a11c165cc32cde8e9c9
3
+ metadata.gz: 80f9d00b4dec8e85066f61cecaf04c5863399c8c6552d5158d0fe69f8b81a64f
4
+ data.tar.gz: 4664e8431f59bf1293d6cafbaf3623b6fe2069aa81af17520384b5e85c34a0a5
5
5
  SHA512:
6
- metadata.gz: 80b27a7c007729e9236d3f8b3ececb6eb89c207e2954bfad63d225d28e2984054b36c3f3193f8ee65596471b2682ddf72c10dfac25651288709142238c73e3da
7
- data.tar.gz: b7bece4ac524d149d38bb311bb125a56b6b80d2198218bdabbbf993a5a7208bc1d35e9d863ea6b63ca002409a35fde7e47793f6471daea6b3aa5d0202d12fc8e
6
+ metadata.gz: 73131e462a1c99744d967f82cecdda88dc2780e04c3bb69f51cd7149fc8e747d7e487e31cc5e5e3fe7f4440d6da3ef42a90ee7e027c7fa0f567ad2b84a6119dd
7
+ data.tar.gz: a17216eb8f219f33af17d79accae60eccc23e059753ac159aed34063ec7f8abb0566c6268097647bb1a657fabf507d4f9d1d90c39e3c73b0e66f9d4c1a29c8bc
@@ -30,12 +30,12 @@ module Braintree
30
30
  :address_id, :customer_id, :proxy_merchant_id, :merchant_account_id,
31
31
  :version,
32
32
  {:domains => [:_any_key_]},
33
- {:options => [:make_default, :verify_card, :fail_on_duplicate_payment_method]}
33
+ {:options => [:fail_on_duplicate_payment_method, :fail_on_duplicate_payment_method_for_customer, :make_default, :verify_card]}
34
34
  ]
35
35
  end
36
36
 
37
37
  def _validate_options(options)
38
- [:make_default, :fail_on_duplicate_payment_method, :verify_card].each do |credit_card_option|
38
+ [:fail_on_duplicate_payment_method, :fail_on_duplicate_payment_method_for_customer, :make_default, :verify_card].each do |credit_card_option|
39
39
  if options[credit_card_option]
40
40
  raise ArgumentError.new("cannot specify #{credit_card_option} without a customer_id") unless options[:customer_id]
41
41
  end
@@ -97,6 +97,7 @@ module Braintree
97
97
  # The old venmo SDK class has been deprecated
98
98
  options = [
99
99
  :fail_on_duplicate_payment_method,
100
+ :fail_on_duplicate_payment_method_for_customer,
100
101
  :make_default,
101
102
  :skip_advanced_fraud_checking,
102
103
  :venmo_sdk_session, # Deprecated
@@ -80,6 +80,7 @@ module Braintree
80
80
  Configuration.gateway.customer.update!(*args)
81
81
  end
82
82
 
83
+ # NEXT_MAJOR_VERSION remove samsung_pay_cards
83
84
  def initialize(gateway, attributes)
84
85
  @gateway = gateway
85
86
  set_instance_variables_from_hash(attributes)
@@ -91,7 +92,7 @@ module Braintree
91
92
  @us_bank_accounts = (@us_bank_accounts || []).map { |pm| UsBankAccount._new gateway, pm }
92
93
  @visa_checkout_cards = (@visa_checkout_cards|| []).map { |pm| VisaCheckoutCard._new gateway, pm }
93
94
  @sepa_direct_debit_accounts = (@sepa_debit_accounts || []).map { |pm| SepaDirectDebitAccount._new gateway, pm }
94
- @samsung_pay_cards = (@samsung_pay_cards|| []).map { |pm| SamsungPayCard._new gateway, pm }
95
+ @samsung_pay_cards = (@samsung_pay_cards|| []).map { |pm| SamsungPayCard._new gateway, pm } # Deprecated
95
96
  @addresses = (@addresses || []).map { |addr| Address._new gateway, addr }
96
97
  @tax_identifiers = (@tax_identifiers || []).map { |addr| TaxIdentifier._new gateway, addr }
97
98
  @custom_fields = attributes[:custom_fields].is_a?(Hash) ? attributes[:custom_fields] : {}
@@ -62,6 +62,8 @@ module Braintree
62
62
 
63
63
  def self._create_signature
64
64
  credit_card_signature = CreditCardGateway._create_signature - [:customer_id]
65
+ credit_card_options = credit_card_signature.find { |item| item.respond_to?(:keys) && item.keys == [:options] }
66
+ credit_card_options[:options].delete_if { |option| option == :fail_on_duplicate_payment_method_for_customer }
65
67
  paypal_account_signature = PayPalAccountGateway._create_nested_signature
66
68
  paypal_options_shipping_signature = AddressGateway._shared_signature
67
69
  options = [
@@ -75,6 +75,7 @@ module Braintree
75
75
  CvvIsRequired = "81706"
76
76
  CvvVerificationFailed = "81736"
77
77
  DuplicateCardExists = "81724"
78
+ DuplicateCardExistsForCustomer = "81763"
78
79
  ExpirationDateConflict = "91708"
79
80
  ExpirationDateIsInvalid = "81710"
80
81
  ExpirationDateIsRequired = "81709"
@@ -83,6 +84,7 @@ module Braintree
83
84
  ExpirationYearIsInvalid = "81713"
84
85
  InvalidParamsForCreditCardUpdate = "91745"
85
86
  InvalidVenmoSDKPaymentMethodCode = "91727"
87
+ LimitExceededforDuplicatePaymentMethodCheckForCustomer = "81764"
86
88
  NetworkTokenizationAttributeCryptogramIsRequired = "81762"
87
89
  NumberIsInvalid = "81715"
88
90
  NumberIsProhibited = "81750"
@@ -712,6 +714,7 @@ module Braintree
712
714
  module ClientToken
713
715
  CustomerDoesNotExist = "92804"
714
716
  FailOnDuplicatePaymentMethodRequiresCustomerId = "92803"
717
+ FailOnDuplicatePaymentMethodForCustomerRequiresCustomerId = "92805"
715
718
  InvalidDomainFormat = "92011"
716
719
  MakeDefaultRequiresCustomerId = "92801"
717
720
  MerchantAccountDoesNotExist = "92807"
@@ -0,0 +1,23 @@
1
+ module Braintree
2
+ class LocalPaymentCompleted
3
+ class BlikAlias
4
+ include BaseModule
5
+
6
+ attr_reader :key
7
+ attr_reader :label
8
+
9
+ def initialize(attributes)
10
+ set_instance_variables_from_hash attributes unless attributes.nil?
11
+ end
12
+
13
+ def inspect
14
+ attrs = [:key, :label]
15
+ formatted_attrs = attrs.map do |attr|
16
+ "#{attr}: #{send(attr).inspect}"
17
+ end
18
+
19
+ "#<#{formatted_attrs.join(", ")}>"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -3,6 +3,7 @@ module Braintree
3
3
  include BaseModule
4
4
 
5
5
  attr_reader :bic
6
+ attr_reader :blik_aliases
6
7
  attr_reader :iban_last_chars
7
8
  attr_reader :payer_id
8
9
  attr_reader :payer_name
@@ -13,6 +14,7 @@ module Braintree
13
14
  def initialize(attributes)
14
15
  set_instance_variables_from_hash(attributes)
15
16
  @transaction = Transaction._new(Configuration.gateway, transaction) unless transaction.nil?
17
+ blik_aliases.map { |attrs| BlikAlias.new(attrs) } if blik_aliases
16
18
  end
17
19
 
18
20
  class << self
@@ -8,6 +8,7 @@ module Braintree
8
8
  MetaCheckoutToken = "meta_checkout_token"
9
9
  PayPalAccount = "paypal_account"
10
10
  PayPalHere = "paypal_here"
11
+ # NEXT_MAJOR_VERSION remove SamsungPayCard
11
12
  SamsungPayCard = "samsung_pay_card"
12
13
  SepaDirectDebitAccount = "sepa_debit_account"
13
14
  UsBankAccount = "us_bank_account"
@@ -204,9 +204,12 @@ module Braintree
204
204
  case type
205
205
  when :create
206
206
  options << :fail_on_duplicate_payment_method
207
+ options << :fail_on_duplicate_payment_method_for_customer
207
208
  signature << :customer_id
208
209
  signature << :paypal_refresh_token
209
210
  when :update
211
+ options << :fail_on_duplicate_payment_method
212
+ options << :fail_on_duplicate_payment_method_for_customer
210
213
  billing_address_params << {:options => [:update_existing]}
211
214
  else
212
215
  raise ArgumentError
@@ -17,6 +17,7 @@ module Braintree
17
17
  elsif attributes[:visa_checkout_card]
18
18
  VisaCheckoutCard._new(gateway, attributes[:visa_checkout_card])
19
19
  elsif attributes[:samsung_pay_card]
20
+ warn "[DEPRECATED] SamsungPayCard is no longer a supported payment method type"
20
21
  SamsungPayCard._new(gateway, attributes[:samsung_pay_card])
21
22
  elsif attributes[:sepa_debit_account]
22
23
  SepaDirectDebitAccount._new(gateway, attributes[:sepa_debit_account])
@@ -1,4 +1,6 @@
1
1
  module Braintree
2
+ # NEXT_MAJOR_VERSION remove this class
3
+ # SamsungPayCard has been deprecated
2
4
  class SamsungPayCard
3
5
  include BaseModule
4
6
  include Braintree::Util::TokenEquality
@@ -69,6 +69,7 @@ module Braintree
69
69
  VisaCheckoutDiscover = "fake-visa-checkout-discover-nonce"
70
70
  VisaCheckoutMasterCard = "fake-visa-checkout-mastercard-nonce"
71
71
  VisaCheckoutVisa = "fake-visa-checkout-visa-nonce"
72
+ # NEXT_MAJOR_VERSION SamsungPay is deprecated, remove all associated nonces
72
73
  SamsungPayAmEx = "tokensam_fake_american_express"
73
74
  SamsungPayDiscover = "tokensam_fake_discover"
74
75
  SamsungPayMasterCard = "tokensam_fake_mastercard"
@@ -3,6 +3,7 @@ module Braintree
3
3
  class LocalPaymentDetails
4
4
  include BaseModule
5
5
 
6
+ attr_reader :blik_aliases
6
7
  attr_reader :capture_id
7
8
  attr_reader :custom_field
8
9
  attr_reader :debug_id
@@ -1,5 +1,7 @@
1
1
  module Braintree
2
2
  class Transaction
3
+ # NEXT_MAJOR_VERSION remove this class
4
+ # SamsungPayCard has been deprecated
3
5
  class SamsungPayCardDetails
4
6
  include BaseModule
5
7
 
@@ -311,6 +311,7 @@ module Braintree
311
311
  Configuration.gateway.transaction.void!(*args)
312
312
  end
313
313
 
314
+ # NEXT_MAJOR_VERSION remove SamsungPayCardDetails
314
315
  def initialize(gateway, attributes)
315
316
  @gateway = gateway
316
317
  set_instance_variables_from_hash(attributes)
@@ -332,7 +333,7 @@ module Braintree
332
333
  @payment_receipt = PaymentReceipt.new(attributes[:payment_receipt]) if attributes[:payment_receipt]
333
334
  @paypal_details = PayPalDetails.new(@paypal)
334
335
  @paypal_here_details = PayPalHereDetails.new(@paypal_here)
335
- @samsung_pay_card_details = SamsungPayCardDetails.new(attributes[:samsung_pay_card])
336
+ @samsung_pay_card_details = SamsungPayCardDetails.new(attributes[:samsung_pay_card]) #Deprecated
336
337
  @sca_exemption_requested = attributes[:sca_exemption_requested]
337
338
  @sepa_direct_debit_account_details = SepaDirectDebitAccountDetails.new(@sepa_debit_account_detail)
338
339
  @service_fee_amount = Util.to_big_decimal(service_fee_amount)
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 4
4
- Minor = 22
4
+ Minor = 23
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
@@ -1094,9 +1094,42 @@ module Braintree
1094
1094
  end
1095
1095
 
1096
1096
  def _local_payment_completed_sample_xml(id)
1097
+ if id == "blik_one_click_id"
1098
+ _blik_one_click_local_payment_completed_sample_xml(id)
1099
+ else
1100
+ _default_local_payment_completed_sample_xml(id)
1101
+ end
1102
+ end
1103
+
1104
+ def _default_local_payment_completed_sample_xml(id)
1105
+ <<-XML
1106
+ <local-payment>
1107
+ <bic>BIC</bic>
1108
+ <iban_last_chars>1234</iban_last_chars>
1109
+ <payer-id>ABCPAYER</payer-id>
1110
+ <payer-name>PAYERNAME</payer-name>
1111
+ <payment-id>PAY-XYZ123</payment-id>
1112
+ <payment-method-nonce>ee257d98-de40-47e8-96b3-a6954ea7a9a4</payment-method-nonce>
1113
+ <transaction>
1114
+ <id>#{id}</id>
1115
+ <status>authorized</status>
1116
+ <amount>49.99</amount>
1117
+ <order-id>order4567</order-id>
1118
+ </transaction>
1119
+ </local-payment>
1120
+ XML
1121
+ end
1122
+
1123
+ def _blik_one_click_local_payment_completed_sample_xml(id)
1097
1124
  <<-XML
1098
1125
  <local-payment>
1099
1126
  <bic>BIC</bic>
1127
+ <blik-aliases type='array'>
1128
+ <blik-alias>
1129
+ <key>alias-key-1</key>
1130
+ <label>alias-label-1</label>
1131
+ </blik-alias>
1132
+ </blik-aliases>
1100
1133
  <iban_last_chars>1234</iban_last_chars>
1101
1134
  <payer-id>ABCPAYER</payer-id>
1102
1135
  <payer-name>PAYERNAME</payer-name>
data/lib/braintree.rb CHANGED
@@ -78,6 +78,7 @@ require "braintree/gateway"
78
78
  require "braintree/graphql_client"
79
79
  require "braintree/google_pay_card"
80
80
  require "braintree/local_payment_completed"
81
+ require "braintree/local_payment_completed/blik_alias"
81
82
  require "braintree/local_payment_reversed"
82
83
  require "braintree/local_payment_expired"
83
84
  require "braintree/local_payment_funded"