braintree 4.35.0 → 4.37.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 (57) 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 +3 -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 +3 -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/credit_card_verification_spec.rb +36 -0
  27. data/spec/integration/braintree/customer_spec.rb +550 -0
  28. data/spec/integration/braintree/http_spec.rb +1 -1
  29. data/spec/integration/braintree/local_payment_context_spec.rb +168 -0
  30. data/spec/integration/braintree/merchant_spec.rb +5 -169
  31. data/spec/integration/braintree/payment_method_spec.rb +174 -1
  32. data/spec/integration/braintree/transaction_idempotency_spec.rb +320 -0
  33. data/spec/integration/braintree/transaction_search_spec.rb +3 -2
  34. data/spec/integration/braintree/transaction_spec.rb +110 -1
  35. data/spec/integration/braintree/transaction_us_bank_account_spec.rb +2 -1
  36. data/spec/spec_helper.rb +2 -0
  37. data/spec/unit/braintree/credit_card_verification_spec.rb +8 -1
  38. data/spec/unit/braintree/customer_spec.rb +67 -1
  39. data/spec/unit/braintree/graphql/billing_address_input_spec.rb +68 -0
  40. data/spec/unit/braintree/graphql/create_local_payment_context_input_spec.rb +63 -0
  41. data/spec/unit/braintree/graphql/monetary_amount_input_spec.rb +55 -0
  42. data/spec/unit/braintree/graphql/payer_info_input_spec.rb +92 -0
  43. data/spec/unit/braintree/local_payment_context_gateway_spec.rb +149 -0
  44. data/spec/unit/braintree/local_payment_context_spec.rb +141 -0
  45. data/spec/unit/braintree/monetary_amount_spec.rb +34 -0
  46. data/spec/unit/braintree/three_d_secure_info_spec.rb +3 -1
  47. data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +7 -7
  48. data/spec/unit/braintree/transaction/google_pay_details_spec.rb +7 -7
  49. data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +6 -6
  50. data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +6 -6
  51. data/spec/unit/braintree/transaction/payment_receipt_spec.rb +4 -4
  52. data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +6 -6
  53. data/spec/unit/braintree/transaction_gateway_spec.rb +4 -3
  54. data/spec/unit/braintree/transaction_spec.rb +22 -0
  55. data/spec/unit/credit_card_details_spec.rb +6 -6
  56. data/spec/unit/spec_helper.rb +9 -0
  57. metadata +20 -3
@@ -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
@@ -122,6 +122,7 @@ module Braintree
122
122
  attr_reader :installment_count
123
123
  attr_reader :installments
124
124
  attr_reader :local_payment_details
125
+ attr_reader :mastercard_transaction_link_id
125
126
  attr_reader :merchant_account_id
126
127
  attr_reader :merchant_advice_code
127
128
  attr_reader :merchant_advice_code_text
@@ -172,6 +173,7 @@ module Braintree
172
173
  attr_reader :status_history
173
174
  attr_reader :subscription_details
174
175
  attr_reader :subscription_id
176
+ attr_reader :surcharge_amount
175
177
  attr_reader :tax_amount
176
178
  attr_reader :tax_exempt
177
179
  attr_reader :three_d_secure_info
@@ -321,6 +323,7 @@ module Braintree
321
323
  @shipping_details = AddressDetails.new(@shipping)
322
324
  @status_history = attributes[:status_history] ? attributes[:status_history].map { |s| StatusDetails.new(s) } : []
323
325
  @subscription_details = SubscriptionDetails.new(@subscription)
326
+ @surcharge_amount = Util.to_big_decimal(surcharge_amount)
324
327
  @partially_authorized = %w[1004].include?(processor_response_code)
325
328
  @tax_amount = Util.to_big_decimal(tax_amount)
326
329
  @venmo_account_details = VenmoAccountDetails.new(@venmo_account)
@@ -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
- :accept_partial_authorization, :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 => [
@@ -318,6 +322,7 @@ module Braintree
318
322
 
319
323
  def self._submit_for_settlement_signature
320
324
  [
325
+ :api_request_key,
321
326
  :order_id,
322
327
  {:descriptor => [:name, :phone, :url]},
323
328
  {:industry => [
@@ -369,6 +374,7 @@ module Braintree
369
374
  def self._refund_signature
370
375
  [
371
376
  :amount,
377
+ :api_request_key,
372
378
  :merchant_account_id,
373
379
  :order_id,
374
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 = 35
4
+ Minor = 37
5
5
  Tiny = 0
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
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
@@ -48,6 +48,42 @@ describe Braintree::CreditCardVerification, "search" do
48
48
  expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
49
49
  end
50
50
 
51
+ it "returns mastercard transaction link id in response" do
52
+ verification_params = {
53
+ :credit_card => {
54
+ :expiration_date => "05/2032",
55
+ :number => Braintree::Test::CreditCardNumbers::MasterCard,
56
+ },
57
+ }
58
+
59
+ result = Braintree::CreditCardVerification.create(verification_params)
60
+
61
+ expect(result).to be_success
62
+ expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
63
+ expect(result.credit_card_verification.processor_response_code).to eq("1000")
64
+ expect(result.credit_card_verification.processor_response_text).to eq("Approved")
65
+ expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
66
+ expect(result.credit_card_verification.mastercard_transaction_link_id).to match(/\A[a-zA-Z0-9]{22}\z/)
67
+ end
68
+
69
+ it "doesnot return mastercard transaction link id in response for a non mastercard" do
70
+ verification_params = {
71
+ :credit_card => {
72
+ :expiration_date => "05/2032",
73
+ :number => Braintree::Test::CreditCardNumbers::Visa,
74
+ },
75
+ }
76
+
77
+ result = Braintree::CreditCardVerification.create(verification_params)
78
+
79
+ expect(result).to be_success
80
+ expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
81
+ expect(result.credit_card_verification.processor_response_code).to eq("1000")
82
+ expect(result.credit_card_verification.processor_response_text).to eq("Approved")
83
+ expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
84
+ expect(result.credit_card_verification.mastercard_transaction_link_id).to be_nil
85
+ end
86
+
51
87
  it "creates a new verification for Visa ANI" do
52
88
  verification_params = {
53
89
  :credit_card => {