Skip to content

Commit

Permalink
4.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Jul 25, 2022
1 parent f18d293 commit 3a883be
Show file tree
Hide file tree
Showing 28 changed files with 708 additions and 48 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Changelog

## 4.8.0
* Add `ach_return_responses` to `Transaction` for search results that search for transaction that have ach return response related data.
* Add `ach_return_responses_created_at` range field to to `TransactionSearch`
* Add `reason_code` to TransactionSearch to search for reason codes on transaction that have ach return responses associated with them.
* Add 'ExchangeRateQuoteAPI'
* Add LiabilityShift class and `liability_shift` field to RiskData
* Replace generic errors with api_error_response

## 4.7.0
* Add `AchReturnCode` to transaction object
* Add `retried` boolean to `Transaction`
Expand Down
23 changes: 15 additions & 8 deletions lib/braintree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
require "braintree/error_codes"
require "braintree/error_result"
require "braintree/errors"
require "braintree/exchange_rate"
require "braintree/exchange_rate_quote"
require "braintree/exchange_rate_quote_gateway"
require "braintree/exchange_rate_quote_input"
require "braintree/exchange_rate_quote_response"
require "braintree/exchange_rate_quote_request"
require "braintree/gateway"
require "braintree/graphql_client"
require "braintree/google_pay_card"
Expand Down Expand Up @@ -102,6 +108,7 @@
require "braintree/plan_gateway"
require "braintree/processor_response_types"
require "braintree/risk_data"
require "braintree/risk_data/liability_shift"
require "braintree/facilitated_details"
require "braintree/facilitator_details"
require "braintree/three_d_secure_info"
Expand Down Expand Up @@ -130,27 +137,27 @@
require "braintree/test/nonce"
require "braintree/test/transaction_amounts"
require "braintree/testing_gateway"
require "braintree/transaction"
require "braintree/transaction_line_item"
require "braintree/test_transaction"
require "braintree/transaction"
require "braintree/transaction/address_details"
require "braintree/transaction/apple_pay_details"
require "braintree/transaction/credit_card_details"
require "braintree/transaction/customer_details"
require "braintree/transaction/disbursement_details"
require "braintree/transaction/google_pay_details"
require "braintree/transaction/installment"
require "braintree/transaction/installment/adjustment"
require "braintree/transaction/paypal_details"
require "braintree/transaction/paypal_here_details"
require "braintree/transaction/samsung_pay_card_details"
require "braintree/transaction/status_details"
require "braintree/transaction/subscription_details"
require "braintree/transaction/venmo_account_details"
require "braintree/transaction/visa_checkout_card_details"
require "braintree/transaction_gateway"
require "braintree/transaction_line_item"
require "braintree/transaction_line_item_gateway"
require "braintree/transaction_search"
require "braintree/transaction/status_details"
require "braintree/transaction/venmo_account_details"
require "braintree/transaction/visa_checkout_card_details"
require "braintree/transaction/samsung_pay_card_details"
require "braintree/transaction/installment"
require "braintree/transaction/installment/adjustment"
require "braintree/unknown_payment_method"
require "braintree/disbursement"
require "braintree/dispute_search"
Expand Down
13 changes: 13 additions & 0 deletions lib/braintree/exchange_rate.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Braintree
class ExchangeRate
include BaseModule # :nodoc:

def initialize(gateway, attributes) # :nodoc:
set_instance_variables_from_hash(attributes)
end

def self.generate(exchange_rate_quote_request)
Configuration.gateway.exchange_rate_quote.generate(exchange_rate_quote_request)
end
end
end
24 changes: 24 additions & 0 deletions lib/braintree/exchange_rate_quote.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module Braintree
class ExchangeRateQuote
include BaseModule # :nodoc:

attr_reader :attrs
attr_reader :base_amount
attr_reader :exchange_rate
attr_reader :expires_at
attr_reader :id
attr_reader :quote_amount
attr_reader :refreshes_at
attr_reader :trade_rate

def initialize(attributes) # :nodoc:
@attrs = attributes.keys
set_instance_variables_from_hash(attributes)
end

def inspect # :nodoc:
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
"#<#{self.class} #{inspected_attributes.join(" ")}>"
end
end
end
35 changes: 35 additions & 0 deletions lib/braintree/exchange_rate_quote_gateway.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module Braintree
class ExchangeRateQuoteGateway # :nodoc
def initialize(gateway)
@gateway = gateway
end

DEFINITION = <<-GRAPHQL
mutation GenerateExchangeRateQuoteInput($input: GenerateExchangeRateQuoteInput!) {
generateExchangeRateQuote(input: $input) {
quotes {
id
baseAmount {value, currencyCode}
quoteAmount {value, currencyCode}
exchangeRate
tradeRate
expiresAt
refreshesAt
}
}
}
GRAPHQL

def generate(params)
response = @gateway.config.graphql_client.query(DEFINITION, {input: params})

if response.has_key?(:data) && response[:data][:generateExchangeRateQuote]
response[:data][:generateExchangeRateQuote]
elsif response[:errors]
ErrorResult.new(@gateway, response[:errors])
else
raise UnexpectedError, "expected :generateExchangeRateQuote or :api_error_response in GraphQL response"
end
end
end
end
21 changes: 21 additions & 0 deletions lib/braintree/exchange_rate_quote_input.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Braintree
class ExchangeRateQuoteInput
include BaseModule # :nodoc:

attr_reader :attrs
attr_reader :base_currency
attr_reader :base_amount
attr_reader :markup
attr_reader :quote_currency

def initialize(attributes) # :nodoc:
@attrs = attributes.keys
set_instance_variables_from_hash(attributes)
end

def inspect # :nodoc:
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
"#<#{self.class} #{inspected_attributes.join(" ")}>"
end
end
end
18 changes: 18 additions & 0 deletions lib/braintree/exchange_rate_quote_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Braintree
class ExchangeRateQuoteRequest
include BaseModule # :nodoc:

attr_reader :quotes

def initialize(attributes) # :nodoc:
@attrs = attributes.keys
set_instance_variables_from_hash(attributes)
@quotes = (@quotes || []).map { |quote_hash| ExchangeRateQuoteInput.new(quote_hash) }
end

def inspect # :nodoc:
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
"#<#{self.class} #{inspected_attributes.join(" ")}>"
end
end
end
18 changes: 18 additions & 0 deletions lib/braintree/exchange_rate_quote_response.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Braintree
class ExchangeRateQuoteResponse
include BaseModule # :nodoc:

attr_reader :quotes

def initialize(attributes) # :nodoc:
@attrs = attributes.keys
set_instance_variables_from_hash(attributes)
@quotes = (@quotes || []).map { |quote_hash| ExchangeRateQuote.new(quote_hash) }
end

def inspect # :nodoc:
inspected_attributes = @attrs.map { |attr| "#{attr}:#{send(attr).inspect}" }
"#<#{self.class} #{inspected_attributes.join(" ")}>"
end
end
end
4 changes: 4 additions & 0 deletions lib/braintree/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def document_upload
DocumentUploadGateway.new(self)
end

def exchange_rate_quote
ExchangeRateQuoteGateway.new(self)
end

def oauth
OAuthGateway.new(self)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/braintree/plan_gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ def _do_create(path, params) # :nodoc:
response = @config.http.post("#{@config.base_merchant_path}#{path}", params)
if response[:plan]
SuccessfulResult.new(:plan => Plan._new(@gateway, response[:plan]))
elsif response[:errors]
ErrorResult.new(@gateway, response[:errors])
elsif response[:api_error_response]
ErrorResult.new(@gateway, response[:api_error_response])
else
raise UnexpectedError, "expected :plan or :errors"
raise UnexpectedError, "expected :plan or :api_error_response"
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/braintree/risk_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ class RiskData # :nodoc:
attr_reader :device_data_captured
attr_reader :fraud_service_provider
attr_reader :id
attr_reader :liability_shift
attr_reader :transaction_risk_score

def initialize(attributes)
set_instance_variables_from_hash attributes unless attributes.nil?
@liability_shift = LiabilityShift.new(attributes[:liability_shift]) if attributes[:liability_shift]
end

def inspect
attr_order = [:id, :decision, :decision_reasons, :device_data_captured, :fraud_service_provider, :transaction_risk_score]
attr_order = [:id, :decision, :decision_reasons, :device_data_captured, :fraud_service_provider, :liability_shift, :transaction_risk_score]
formatted_attrs = attr_order.map do |attr|
"#{attr}: #{send(attr).inspect}"
end
Expand Down
22 changes: 22 additions & 0 deletions lib/braintree/risk_data/liability_shift.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module Braintree
class RiskData
class LiabilityShift
include BaseModule

attr_reader :responsible_party
attr_reader :conditions

def initialize(attributes)
set_instance_variables_from_hash attributes unless attributes.nil?
end

def inspect
attr_order = [:responsible_party, :conditions]
formatted_attrs = attr_order.map do |attr|
"#{attr}: #{send(attr).inspect}"
end
"#<LiabilityShift #{formatted_attrs.join(", ")}>"
end
end
end
end
3 changes: 2 additions & 1 deletion lib/braintree/successful_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ class SuccessfulResult
attr_reader :apple_pay_options
attr_reader :credentials
attr_reader :credit_card
attr_reader :credit_card_verification
attr_reader :customer
attr_reader :disputes
attr_reader :document_upload
attr_reader :evidence
attr_reader :exchange_rate_quote_payload
attr_reader :merchant
attr_reader :merchant_account
attr_reader :merchant_accounts
Expand All @@ -22,7 +24,6 @@ class SuccessfulResult
attr_reader :supported_networks
attr_reader :transaction
attr_reader :us_bank_account_verification
attr_reader :credit_card_verification

def initialize(attributes = {}) # :nodoc:
@attrs = attributes.keys
Expand Down
41 changes: 22 additions & 19 deletions lib/braintree/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ module Status
attr_reader :venmo_account_details
attr_reader :visa_checkout_card_details
attr_reader :voice_referral_number
attr_reader :ach_return_responses

def self.adjust_authorization(*args)
Configuration.gateway.transaction.adjust_authorization(*args)
Expand Down Expand Up @@ -290,38 +291,40 @@ def self.void!(*args)
def initialize(gateway, attributes) # :nodoc:
@gateway = gateway
set_instance_variables_from_hash(attributes)

@amount = Util.to_big_decimal(amount)
@apple_pay_details = ApplePayDetails.new(@apple_pay)
@billing_details = AddressDetails.new(@billing)
@credit_card_details = CreditCardDetails.new(@credit_card)
@service_fee_amount = Util.to_big_decimal(service_fee_amount)
@subscription_details = SubscriptionDetails.new(@subscription)
@custom_fields = attributes[:custom_fields].is_a?(Hash) ? attributes[:custom_fields] : {}
@customer_details = CustomerDetails.new(@customer)
@billing_details = AddressDetails.new(@billing)
@disbursement_details = DisbursementDetails.new(@disbursement_details)
@shipping_details = AddressDetails.new(@shipping)
@status_history = attributes[:status_history] ? attributes[:status_history].map { |s| StatusDetails.new(s) } : []
@tax_amount = Util.to_big_decimal(tax_amount)
@descriptor = Descriptor.new(@descriptor)
@disbursement_details = DisbursementDetails.new(@disbursement_details)
@google_pay_details = GooglePayDetails.new(@google_pay_card)
@local_payment_details = LocalPaymentDetails.new(@local_payment)
@payment_instrument_type = attributes[:payment_instrument_type]
@paypal_details = PayPalDetails.new(@paypal)
@paypal_here_details = PayPalHereDetails.new(@paypal_here)
@apple_pay_details = ApplePayDetails.new(@apple_pay)
@google_pay_details = GooglePayDetails.new(@google_pay_card)
@samsung_pay_card_details = SamsungPayCardDetails.new(attributes[:samsung_pay_card])
@sca_exemption_requested = attributes[:sca_exemption_requested]
@service_fee_amount = Util.to_big_decimal(service_fee_amount)
@shipping_details = AddressDetails.new(@shipping)
@status_history = attributes[:status_history] ? attributes[:status_history].map { |s| StatusDetails.new(s) } : []
@subscription_details = SubscriptionDetails.new(@subscription)
@tax_amount = Util.to_big_decimal(tax_amount)
@venmo_account_details = VenmoAccountDetails.new(@venmo_account)
disputes.map! { |attrs| Dispute._new(attrs) } if disputes
@custom_fields = attributes[:custom_fields].is_a?(Hash) ? attributes[:custom_fields] : {}
add_ons.map! { |attrs| AddOn._new(attrs) } if add_ons
discounts.map! { |attrs| Discount._new(attrs) } if discounts
@payment_instrument_type = attributes[:payment_instrument_type]
@risk_data = RiskData.new(attributes[:risk_data]) if attributes[:risk_data]
@visa_checkout_card_details = VisaCheckoutCardDetails.new(attributes[:visa_checkout_card])

@facilitated_details = FacilitatedDetails.new(attributes[:facilitated_details]) if attributes[:facilitated_details]
@facilitator_details = FacilitatorDetails.new(attributes[:facilitator_details]) if attributes[:facilitator_details]
@risk_data = RiskData.new(attributes[:risk_data]) if attributes[:risk_data]
@three_d_secure_info = ThreeDSecureInfo.new(attributes[:three_d_secure_info]) if attributes[:three_d_secure_info]
@us_bank_account_details = UsBankAccountDetails.new(attributes[:us_bank_account]) if attributes[:us_bank_account]
@visa_checkout_card_details = VisaCheckoutCardDetails.new(attributes[:visa_checkout_card])
@samsung_pay_card_details = SamsungPayCardDetails.new(attributes[:samsung_pay_card])
@sca_exemption_requested = attributes[:sca_exemption_requested]
authorization_adjustments.map! { |attrs| AuthorizationAdjustment._new(attrs) } if authorization_adjustments

add_ons.map! { |attrs| AddOn._new(attrs) } if add_ons
authorization_adjustments.map! { |attrs| AuthorizationAdjustment._new(attrs) } if authorization_adjustments
discounts.map! { |attrs| Discount._new(attrs) } if discounts
disputes.map! { |attrs| Dispute._new(attrs) } if disputes
installments.map! { |attrs| Installment.new(attrs) } if installments
refunded_installments.map! { |attrs| Installment.new(attrs) } if refunded_installments
end
Expand Down
3 changes: 2 additions & 1 deletion lib/braintree/transaction_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ class TransactionSearch < AdvancedSearch # :nodoc:
multiple_value_field :source
multiple_value_field :type, :allows => Transaction::Type::All
multiple_value_field :store_ids
multiple_value_field :reason_code

key_value_fields :refund

range_fields :amount, :created_at, :authorization_expired_at, :authorized_at,
:failed_at, :gateway_rejected_at, :processor_declined_at,
:settled_at, :submitted_for_settlement_at, :voided_at,
:disbursement_date, :dispute_date
:disbursement_date, :dispute_date, :ach_return_responses_created_at
end
end
2 changes: 1 addition & 1 deletion lib/braintree/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Braintree
module Version
Major = 4
Minor = 7
Minor = 8
Tiny = 0

String = "#{Major}.#{Minor}.#{Tiny}"
Expand Down
Loading

0 comments on commit 3a883be

Please sign in to comment.