braintree 4.34.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 (66) 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 +2 -2
  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/payment_instrument_type.rb +1 -0
  20. data/lib/braintree/payment_method_parser.rb +1 -0
  21. data/lib/braintree/successful_result.rb +1 -0
  22. data/lib/braintree/test/nonce.rb +1 -0
  23. data/lib/braintree/test/transaction_amounts.rb +1 -0
  24. data/lib/braintree/transaction/visa_checkout_card_details.rb +2 -0
  25. data/lib/braintree/transaction.rb +8 -2
  26. data/lib/braintree/transaction_gateway.rb +12 -5
  27. data/lib/braintree/transaction_search.rb +1 -0
  28. data/lib/braintree/validation_error_collection.rb +1 -1
  29. data/lib/braintree/version.rb +1 -1
  30. data/lib/braintree/visa_checkout_card.rb +2 -0
  31. data/lib/braintree.rb +20 -3
  32. data/spec/integration/braintree/customer_spec.rb +550 -16
  33. data/spec/integration/braintree/http_spec.rb +1 -1
  34. data/spec/integration/braintree/local_payment_context_spec.rb +168 -0
  35. data/spec/integration/braintree/merchant_spec.rb +5 -169
  36. data/spec/integration/braintree/payment_method_spec.rb +174 -1
  37. data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +1 -1
  38. data/spec/integration/braintree/test_transaction_spec.rb +6 -6
  39. data/spec/integration/braintree/transaction_idempotency_spec.rb +320 -0
  40. data/spec/integration/braintree/transaction_search_spec.rb +3 -2
  41. data/spec/integration/braintree/transaction_spec.rb +91 -0
  42. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +42 -0
  43. data/spec/integration/braintree/visa_checkout_card_spec.rb +4 -100
  44. data/spec/spec_helper.rb +2 -0
  45. data/spec/unit/braintree/credit_card_verification_spec.rb +1 -1
  46. data/spec/unit/braintree/customer_spec.rb +67 -1
  47. data/spec/unit/braintree/graphql/billing_address_input_spec.rb +68 -0
  48. data/spec/unit/braintree/graphql/create_local_payment_context_input_spec.rb +63 -0
  49. data/spec/unit/braintree/graphql/monetary_amount_input_spec.rb +55 -0
  50. data/spec/unit/braintree/graphql/payer_info_input_spec.rb +92 -0
  51. data/spec/unit/braintree/local_payment_context_gateway_spec.rb +149 -0
  52. data/spec/unit/braintree/local_payment_context_spec.rb +141 -0
  53. data/spec/unit/braintree/monetary_amount_spec.rb +34 -0
  54. data/spec/unit/braintree/three_d_secure_info_spec.rb +3 -1
  55. data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +7 -7
  56. data/spec/unit/braintree/transaction/google_pay_details_spec.rb +7 -7
  57. data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +6 -6
  58. data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +6 -6
  59. data/spec/unit/braintree/transaction/payment_receipt_spec.rb +4 -4
  60. data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +6 -6
  61. data/spec/unit/braintree/transaction_gateway_spec.rb +5 -3
  62. data/spec/unit/braintree/transaction_spec.rb +31 -0
  63. data/spec/unit/braintree/visa_checkout_card_spec.rb +1 -0
  64. data/spec/unit/credit_card_details_spec.rb +6 -6
  65. data/spec/unit/spec_helper.rb +9 -0
  66. metadata +23 -6
@@ -13,6 +13,7 @@ module Braintree
13
13
  SepaDirectDebitAccount = "sepa_debit_account"
14
14
  UsBankAccount = "us_bank_account"
15
15
  VenmoAccount = "venmo_account"
16
+ # NEXT_MAJOR_VERSION remove VisaCheckoutCard
16
17
  VisaCheckoutCard = "visa_checkout_card"
17
18
  end
18
19
  end
@@ -15,6 +15,7 @@ module Braintree
15
15
  elsif attributes[:venmo_account]
16
16
  VenmoAccount._new(gateway, attributes[:venmo_account])
17
17
  elsif attributes[:visa_checkout_card]
18
+ warn "[DEPRECATED] VisaCheckoutCard is no longer a supported payment method type"
18
19
  VisaCheckoutCard._new(gateway, attributes[:visa_checkout_card])
19
20
  elsif attributes[:samsung_pay_card]
20
21
  warn "[DEPRECATED] SamsungPayCard is no longer a supported payment method type"
@@ -27,6 +27,7 @@ module Braintree
27
27
  attr_reader :us_bank_account_verification
28
28
  attr_reader :session_id
29
29
  attr_reader :customer_recommendations
30
+ attr_reader :payment_context
30
31
 
31
32
  def initialize(attributes = {})
32
33
  @attrs = attributes.keys
@@ -65,6 +65,7 @@ module Braintree
65
65
  PayPalFuturePaymentRefreshToken = "fake-paypal-future-refresh-token-nonce"
66
66
  GatewayRejectedFraud = "fake-gateway-rejected-fraud-nonce"
67
67
  GatewayRejectedRiskThresholds = "fake-gateway-rejected-risk-thresholds-nonce"
68
+ # NEXT_MAJOR_VERSION VisaCheckoutCard is deprecated, remove associated nonces
68
69
  VisaCheckoutAmEx = "fake-visa-checkout-amex-nonce"
69
70
  VisaCheckoutDiscover = "fake-visa-checkout-discover-nonce"
70
71
  VisaCheckoutMasterCard = "fake-visa-checkout-mastercard-nonce"
@@ -3,6 +3,7 @@ module Braintree
3
3
  # NEXT_MAJOR_VERSION are these even being used anymore? Can we remove this class??
4
4
  module TransactionAmounts
5
5
  Authorize = "1000.00"
6
+ PartiallyAuthorized = "1004.00"
6
7
  Decline = "2000.00"
7
8
  HardDecline = "2015.00"
8
9
  Fail = "3000.00"
@@ -1,5 +1,7 @@
1
1
  module Braintree
2
2
  class Transaction
3
+ # DEPRECATED: Visa Checkout is no longer supported for creating new transactions.
4
+ # This class is retained for search functionality and historical transaction data only.
3
5
  class VisaCheckoutCardDetails
4
6
  include BaseModule
5
7
 
@@ -86,6 +86,7 @@ module Braintree
86
86
  attr_reader :ach_reject_reason
87
87
  attr_reader :ach_return_code
88
88
  attr_reader :ach_return_responses
89
+ attr_reader :ach_type
89
90
  attr_reader :acquirer_reference_number
90
91
  attr_reader :add_ons
91
92
  attr_reader :additional_processor_response # The raw response from the processor.
@@ -133,6 +134,7 @@ module Braintree
133
134
  attr_reader :order_id
134
135
  attr_reader :packages
135
136
  attr_reader :partial_settlement_transaction_ids
137
+ attr_reader :partially_authorized
136
138
  attr_reader :payment_instrument_type
137
139
  attr_reader :payment_receipt
138
140
  attr_reader :paypal_details
@@ -150,6 +152,7 @@ module Braintree
150
152
  attr_reader :refund_ids
151
153
  attr_reader :refunded_installments
152
154
  attr_reader :refunded_transaction_id
155
+ attr_reader :requested_ach_type
153
156
  attr_reader :retried
154
157
  attr_reader :retried_transaction_id # the primary/parent transaction id of any retried transaction
155
158
  attr_reader :retrieval_reference_number
@@ -169,6 +172,7 @@ module Braintree
169
172
  attr_reader :status_history
170
173
  attr_reader :subscription_details
171
174
  attr_reader :subscription_id
175
+ attr_reader :surcharge_amount
172
176
  attr_reader :tax_amount
173
177
  attr_reader :tax_exempt
174
178
  attr_reader :three_d_secure_info
@@ -310,7 +314,7 @@ module Braintree
310
314
  @payment_receipt = PaymentReceipt.new(attributes[:payment_receipt]) if attributes[:payment_receipt]
311
315
  @paypal_details = PayPalDetails.new(@paypal)
312
316
  @paypal_here_details = PayPalHereDetails.new(@paypal_here)
313
- @samsung_pay_card_details = SamsungPayCardDetails.new(attributes[:samsung_pay_card]) #Deprecated
317
+ @samsung_pay_card_details = SamsungPayCardDetails.new(attributes[:samsung_pay_card]) # Deprecated
314
318
  @sca_exemption_requested = attributes[:sca_exemption_requested]
315
319
  @sepa_direct_debit_account_details = SepaDirectDebitAccountDetails.new(@sepa_debit_account_detail)
316
320
  @service_fee_amount = Util.to_big_decimal(service_fee_amount)
@@ -318,9 +322,11 @@ module Braintree
318
322
  @shipping_details = AddressDetails.new(@shipping)
319
323
  @status_history = attributes[:status_history] ? attributes[:status_history].map { |s| StatusDetails.new(s) } : []
320
324
  @subscription_details = SubscriptionDetails.new(@subscription)
325
+ @surcharge_amount = Util.to_big_decimal(surcharge_amount)
326
+ @partially_authorized = %w[1004].include?(processor_response_code)
321
327
  @tax_amount = Util.to_big_decimal(tax_amount)
322
328
  @venmo_account_details = VenmoAccountDetails.new(@venmo_account)
323
- @visa_checkout_card_details = VisaCheckoutCardDetails.new(attributes[:visa_checkout_card])
329
+ @visa_checkout_card_details = VisaCheckoutCardDetails.new(attributes[:visa_checkout_card]) # Deprecated
324
330
 
325
331
  @facilitated_details = FacilitatedDetails.new(attributes[:facilitated_details]) if attributes[:facilitated_details]
326
332
  @facilitator_details = FacilitatorDetails.new(attributes[:facilitator_details]) if attributes[:facilitator_details]
@@ -168,8 +168,12 @@ module Braintree
168
168
  return_object_or_raise(:transaction) { submit_for_partial_settlement(*args) }
169
169
  end
170
170
 
171
- def void(transaction_id)
172
- response = @config.http.put("#{@config.base_merchant_path}/transactions/#{transaction_id}/void")
171
+ def void(transaction_id, options = {})
172
+ transaction_params = options.empty? ? nil : options
173
+ response = @config.http.put(
174
+ "#{@config.base_merchant_path}/transactions/#{transaction_id}/void",
175
+ transaction_params ? {:transaction => transaction_params} : nil,
176
+ )
173
177
  _handle_transaction_response(response)
174
178
  end
175
179
 
@@ -194,13 +198,13 @@ module Braintree
194
198
  # three_d_secure_token has been deprecated in favor of three_d_secure_authentication_id
195
199
  def self._create_signature
196
200
  [
197
- :amount, :billing_address_id, :channel, :currency_iso_code, :customer_id, :device_data,
201
+ :accept_partial_authorization, :amount, :api_request_key, :billing_address_id, :channel, :currency_iso_code, :customer_id, :device_data,
198
202
  :discount_amount, :exchange_rate_quote_id, :foreign_retailer,
199
203
  :merchant_account_id, :order_id, :payment_method_nonce, :payment_method_token, :processing_merchant_category_code,
200
204
  :product_sku, :purchase_order_number, :service_fee_amount, :shared_billing_address_id,
201
205
  :shared_customer_id, :shared_payment_method_nonce, :shared_payment_method_token,
202
206
  :shared_shipping_address_id, :shipping_address_id, :shipping_amount, :shipping_tax_amount,
203
- :ships_from_postal_code, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,:three_d_secure_token, #Deprecated
207
+ :ships_from_postal_code,:surcharge_amount, :tax_amount, :tax_exempt, :three_d_secure_authentication_id,:three_d_secure_token, #Deprecated
204
208
  :transaction_source, :type, :venmo_sdk_payment_method_code, # Deprecated
205
209
  :sca_exemption,
206
210
  {:apple_pay_card => [:number, :cardholder_name, :cryptogram, :expiration_month, :expiration_year, :eci_indicator]},
@@ -208,7 +212,7 @@ module Braintree
208
212
  :billing => AddressGateway._shared_signature
209
213
  },
210
214
  {:credit_card => [:token, :cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year, :number, {:payment_reader_card_details => [:encrypted_card_data, :key_serial_number]}, {:network_tokenization_attributes => [:cryptogram, :ecommerce_indicator, :token_requestor_id]}]},
211
- {:customer => [:id, :company, :email, :fax, :first_name, :last_name, :phone, :website]},
215
+ {:customer => [:id, :company, :email, :fax, :first_name, {:international_phone => [:country_code, :national_number]}, :last_name, :phone, :website]},
212
216
  {:custom_fields => :_any_key_},
213
217
  {:descriptor => [:name, :phone, :url]},
214
218
  {:external_vault => [
@@ -250,6 +254,7 @@ module Braintree
250
254
  :store_shipping_address_in_vault,
251
255
  :submit_for_settlement,
252
256
  {:three_d_secure => [:required]},
257
+ {:us_bank_account => [:ach_type]},
253
258
  {:venmo => [:profile_id]},
254
259
  :venmo_sdk_session, # Deprecated
255
260
  ]
@@ -317,6 +322,7 @@ module Braintree
317
322
 
318
323
  def self._submit_for_settlement_signature
319
324
  [
325
+ :api_request_key,
320
326
  :order_id,
321
327
  {:descriptor => [:name, :phone, :url]},
322
328
  {:industry => [
@@ -368,6 +374,7 @@ module Braintree
368
374
  def self._refund_signature
369
375
  [
370
376
  :amount,
377
+ :api_request_key,
371
378
  :merchant_account_id,
372
379
  :order_id,
373
380
  ]
@@ -1,6 +1,7 @@
1
1
  module Braintree
2
2
  class TransactionSearch < AdvancedSearch
3
3
  text_fields(
4
+ :acquirer_reference_number,
4
5
  :billing_company,
5
6
  :billing_country_name,
6
7
  :billing_extended_address,
@@ -39,7 +39,7 @@ module Braintree
39
39
  end
40
40
 
41
41
  def for_index(index)
42
- self.for("index_#{index}".to_sym)
42
+ self.for(:"index_#{index}")
43
43
  end
44
44
 
45
45
  def inspect
@@ -1,7 +1,7 @@
1
1
  module Braintree
2
2
  module Version
3
3
  Major = 4
4
- Minor = 34
4
+ Minor = 36
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
@@ -1,4 +1,6 @@
1
1
  module Braintree
2
+ # DEPRECATED: Visa Checkout is no longer supported for creating new transactions.
3
+ # This class is retained for search functionality and historical transaction data only.
2
4
  class VisaCheckoutCard
3
5
  include BaseModule
4
6
  include Braintree::Util::TokenEquality
data/lib/braintree.rb CHANGED
@@ -89,6 +89,10 @@ require "braintree/graphql/inputs/update_customer_session_input"
89
89
  require "braintree/graphql/inputs/paypal_purchase_unit_input"
90
90
  require "braintree/graphql/inputs/paypal_payee_input"
91
91
  require "braintree/graphql/inputs/monetary_amount_input"
92
+ require "braintree/graphql/inputs/create_local_payment_context_input"
93
+ require "braintree/graphql/inputs/payer_info_input"
94
+ require "braintree/graphql/inputs/billing_address_input"
95
+ require "braintree/graphql/inputs/shipping_address_input"
92
96
  require "braintree/graphql/types/customer_recommendations_payload"
93
97
  require "braintree/graphql/types/payment_options"
94
98
  require "braintree/graphql/types/payment_recommendations"
@@ -97,17 +101,20 @@ require "braintree/graphql_client"
97
101
  require "braintree/google_pay_card"
98
102
  require "braintree/local_payment_completed"
99
103
  require "braintree/local_payment_completed/blik_alias"
100
- require "braintree/local_payment_reversed"
104
+ require "braintree/local_payment_context"
105
+ require "braintree/local_payment_context_gateway"
101
106
  require "braintree/local_payment_expired"
102
107
  require "braintree/local_payment_funded"
103
- require "braintree/transaction/local_payment_details"
108
+ require "braintree/local_payment_reversed"
109
+ require "braintree/local_payment_type"
104
110
  require "braintree/merchant"
105
- require "braintree/merchant_gateway"
106
111
  require "braintree/merchant_account"
112
+ require "braintree/merchant_gateway"
107
113
  require "braintree/merchant_account_gateway"
108
114
  require "braintree/merchant_account/address_details"
109
115
  require "braintree/meta_checkout_card"
110
116
  require "braintree/meta_checkout_token"
117
+ require "braintree/monetary_amount"
111
118
  require "braintree/oauth_gateway"
112
119
  require "braintree/oauth_credentials"
113
120
  require "braintree/payment_instrument_type"
@@ -172,6 +179,7 @@ require "braintree/transaction/installment/adjustment"
172
179
  require "braintree/transaction/payment_receipt"
173
180
  require "braintree/transaction/payment_receipt/card_present_data.rb"
174
181
  require "braintree/transaction/payment_receipt/merchant_address.rb"
182
+ require "braintree/transaction/local_payment_details"
175
183
  require "braintree/transaction/meta_checkout_card_details"
176
184
  require "braintree/transaction/meta_checkout_token_details"
177
185
  require "braintree/transaction/package_details"
@@ -206,3 +214,12 @@ require "braintree/xml/generator"
206
214
  require "braintree/xml/nokogiri"
207
215
  require "braintree/xml/rexml"
208
216
  require "braintree/xml/parser"
217
+
218
+ module Braintree
219
+ ApplePayDetails = Transaction::ApplePayDetails
220
+ CreditCardDetails = Transaction::CreditCardDetails
221
+ GooglePayDetails = Transaction::GooglePayDetails
222
+ MetaCheckoutCardDetails = Transaction::MetaCheckoutCardDetails
223
+ MetaCheckoutTokenDetails = Transaction::MetaCheckoutTokenDetails
224
+ VisaCheckoutCardDetails = Transaction::VisaCheckoutCardDetails
225
+ end