Skip to content

Commit

Permalink
4.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Jan 11, 2023
1 parent c523c2d commit 7a01335
Show file tree
Hide file tree
Showing 42 changed files with 892 additions and 50 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 4.10.0
* Add `billing_address` attribute reader to `ApplePayCard`
* Add `pre_dispute_program` to `Dispute` and `DisputeSearch`
* Add `AutoAccepted` status to `Dispute`
* Add `DisputeAutoAccepted` webhook to `WebhookNotification`
* Add `ExcessiveRetry` to `GatewayRejectionReason`
* Add `SEPADirectDebitAccount` payment method
* Add `sepa_direct_debit_return_code` to `Transaction`
* Add `sepa_direct_debit_account_details` to `Transaction`
* Add `sepa_direct_debit_account_nonce_details` to `PaymentMethodNonceDetails`
* Add `SEPA_DIRECT_DEBIT_ACCOUNT` to `PaymentInstrumentType`
* Add `sepa_debit_paypal_v2_order_id` to `TransactionSearch`
* Add `sepa_direct_debit_accounts` to `Customer`
* Add SEPA Direct Debit specific error codes

## 4.9.0
* Add `cardholder_name` attribute reader to `ApplePayCard` (Thanks @AxelTheGerman)
* Deprecate `chargeback_protection_level` and add `protection_level` to `Dispute` and `DisputeSearch`
Expand Down
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ group :development do
gem "rubocop", "~>1.12.0"
gem "webrick", "~>1.7.0"
end

group :test do
gem "rspec_junit_formatter"
end
4 changes: 4 additions & 0 deletions lib/braintree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@
require "braintree/us_bank_account_verification_search"
require "braintree/us_bank_account_gateway"
require "braintree/transaction/us_bank_account_details"
require "braintree/sepa_direct_debit_account"
require "braintree/sepa_direct_debit_account_gateway"
require "braintree/sepa_direct_debit_account_nonce_details"
require "braintree/sha256_digest"
require "braintree/signature_service"
require "braintree/subscription"
Expand All @@ -150,6 +153,7 @@
require "braintree/transaction/paypal_details"
require "braintree/transaction/paypal_here_details"
require "braintree/transaction/samsung_pay_card_details"
require "braintree/transaction/sepa_direct_debit_account_details"
require "braintree/transaction/status_details"
require "braintree/transaction/subscription_details"
require "braintree/transaction/venmo_account_details"
Expand Down
2 changes: 2 additions & 0 deletions lib/braintree/apple_pay_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module CardType
All = constants.map { |c| const_get(c) }
end

attr_reader :billing_address
attr_reader :bin
attr_reader :card_type
attr_reader :cardholder_name
Expand Down Expand Up @@ -39,6 +40,7 @@ module CardType
def initialize(gateway, attributes) # :nodoc:
@gateway = gateway
set_instance_variables_from_hash(attributes)
@billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil
@subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
end

Expand Down
5 changes: 4 additions & 1 deletion lib/braintree/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Customer
attr_reader :paypal_accounts
attr_reader :phone
attr_reader :samsung_pay_cards
attr_reader :sepa_direct_debit_accounts
attr_reader :tax_identifiers
attr_reader :updated_at
attr_reader :us_bank_accounts
Expand Down Expand Up @@ -89,6 +90,7 @@ def initialize(gateway, attributes) # :nodoc:
@venmo_accounts = (@venmo_accounts || []).map { |pm| VenmoAccount._new gateway, pm }
@us_bank_accounts = (@us_bank_accounts || []).map { |pm| UsBankAccount._new gateway, pm }
@visa_checkout_cards = (@visa_checkout_cards|| []).map { |pm| VisaCheckoutCard._new gateway, pm }
@sepa_direct_debit_accounts = (@sepa_debit_accounts || []).map { |pm| SepaDirectDebitAccount._new gateway, pm }
@samsung_pay_cards = (@samsung_pay_cards|| []).map { |pm| SamsungPayCard._new gateway, pm }
@addresses = (@addresses || []).map { |addr| Address._new gateway, addr }
@tax_identifiers = (@tax_identifiers || []).map { |addr| TaxIdentifier._new gateway, addr }
Expand Down Expand Up @@ -121,7 +123,8 @@ def payment_methods
@venmo_accounts +
@us_bank_accounts +
@visa_checkout_cards +
@samsung_pay_cards
@samsung_pay_cards +
@sepa_direct_debit_accounts
end

def inspect # :nodoc:
Expand Down
9 changes: 9 additions & 0 deletions lib/braintree/dispute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Dispute # :nodoc:
attr_reader :merchant_account_id
attr_reader :original_dispute_id
attr_reader :paypal_messages
attr_reader :pre_dispute_program
attr_reader :processor_comments
attr_reader :protection_level
attr_reader :reason
Expand All @@ -37,6 +38,7 @@ class Dispute # :nodoc:

module Status
Accepted = "accepted"
AutoAccepted = "auto_accepted"
Disputed = "disputed"
Expired = "expired"
Open = "open"
Expand Down Expand Up @@ -86,6 +88,13 @@ module ProtectionLevel
All = constants.map { |c| const_get(c) }
end

module PreDisputeProgram
None = "none"
VisaRdr = "visa_rdr"

All = constants.map { |c| const_get(c) }
end

class << self
protected :new
def _new(*args) # :nodoc:
Expand Down
1 change: 1 addition & 0 deletions lib/braintree/dispute_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class DisputeSearch < AdvancedSearch # :nodoc:
multiple_value_field :protection_level, :allows => Dispute::ProtectionLevel::All
multiple_value_field :kind, :allows => Dispute::Kind::All
multiple_value_field :merchant_account_id
multiple_value_field :pre_dispute_program, :allows => Dispute::PreDisputeProgram::All
multiple_value_field :reason, :allows => Dispute::Reason::All
multiple_value_field :reason_code
multiple_value_field :status, :allows => Dispute::Status::All
Expand Down
6 changes: 6 additions & 0 deletions lib/braintree/error_codes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ module PayPalAccount
TokenIsInUse = "92906"
end

module SepaDirectDebitAccount
SepaDebitAccountPaymentMethodMandateTypeIsNotSupported = "87115"
SepaDebitAccountPaymentMethodCustomerIdIsInvalid = "87116"
SepaDebitAccountPaymentMethodCustomerIdIsRequired = "87117"
end

module Subscription
BillingDayOfMonthCannotBeUpdated = "91918"
BillingDayOfMonthIsInvalid = "91914"
Expand Down
4 changes: 4 additions & 0 deletions lib/braintree/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def us_bank_account
UsBankAccountGateway.new(self)
end

def sepa_direct_debit_account
SepaDirectDebitAccountGateway.new(self)
end

def merchant
MerchantGateway.new(self)
end
Expand Down
13 changes: 7 additions & 6 deletions lib/braintree/payment_instrument_type.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
module Braintree
module PaymentInstrumentType
PayPalAccount = "paypal_account"
CreditCard = "credit_card"
ApplePayCard = "apple_pay_card"
CreditCard = "credit_card"
GooglePayCard = "android_pay_card"
VenmoAccount = "venmo_account"
UsBankAccount = "us_bank_account"
VisaCheckoutCard = "visa_checkout_card"
SamsungPayCard = "samsung_pay_card"
LocalPayment = "local_payment"
PayPalAccount = "paypal_account"
PayPalHere = "paypal_here"
SamsungPayCard = "samsung_pay_card"
SepaDirectDebitAccount = "sepa_debit_account"
UsBankAccount = "us_bank_account"
VenmoAccount = "venmo_account"
VisaCheckoutCard = "visa_checkout_card"
end
end
2 changes: 2 additions & 0 deletions lib/braintree/payment_method_gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def find(token)
GooglePayCard._new(@gateway, response[:android_pay_card])
elsif response.has_key?(:venmo_account)
VenmoAccount._new(@gateway, response[:venmo_account])
elsif response.has_key?(:sepa_debit_account)
SepaDirectDebitAccount._new(@gateway, response[:sepa_debit_account])
else
UnknownPaymentMethod._new(@gateway, response)
end
Expand Down
3 changes: 3 additions & 0 deletions lib/braintree/payment_method_nonce_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ class PaymentMethodNonceDetails # :nodoc:
attr_reader :is_network_tokenized
attr_reader :last_two
attr_reader :payer_info
attr_reader :sepa_direct_debit_account_nonce_details

alias_method :is_network_tokenized?, :is_network_tokenized

def initialize(attributes)
set_instance_variables_from_hash attributes unless attributes.nil?
@payer_info = PaymentMethodNonceDetailsPayerInfo.new(attributes[:payer_info]) if attributes[:payer_info]
@sepa_direct_debit_account_nonce_details = ::Braintree::SepaDirectDebitAccountNonceDetails.new(attributes)
end

def inspect
Expand All @@ -26,6 +28,7 @@ def inspect
:is_network_tokenized,
:last_two,
:payer_info,
:sepa_direct_debit_account_nonce_details,
]

formatted_attrs = attr_order.map do |attr|
Expand Down
2 changes: 2 additions & 0 deletions lib/braintree/payment_method_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def self.parse_payment_method(gateway, attributes)
VisaCheckoutCard._new(gateway, attributes[:visa_checkout_card])
elsif attributes[:samsung_pay_card]
SamsungPayCard._new(gateway, attributes[:samsung_pay_card])
elsif attributes[:sepa_debit_account]
SepaDirectDebitAccount._new(gateway, attributes[:sepa_debit_account])
else
UnknownPaymentMethod._new(gateway, attributes)
end
Expand Down
58 changes: 58 additions & 0 deletions lib/braintree/sepa_direct_debit_account.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module Braintree
class SepaDirectDebitAccount
include BaseModule

attr_reader :bank_reference_token
attr_reader :created_at
attr_reader :customer_id
attr_reader :customer_global_id
attr_reader :default
attr_reader :global_id
attr_reader :image_url
attr_reader :last_4
attr_reader :mandate_type
attr_reader :merchant_or_partner_customer_id
attr_reader :token
attr_reader :updated_at
attr_reader :view_mandate_url

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

def default?
@default
end

class << self
protected :new
end

def self._new(*args) # :nodoc:
self.new(*args)
end

def self.find(*args)
Configuration.gateway.sepa_direct_debit_account.find(*args)
end

def self.delete(*args)
Configuration.gateway.sepa_direct_debit_account.delete(*args)
end

def self.sale(token, transaction_attributes)
options = transaction_attributes[:options] || {}
Configuration.gateway.transaction.sale(
transaction_attributes.merge(
:payment_method_token => token,
:options => options.merge(:submit_for_settlement => true),
),
)
end

def self.sale!(token, transaction_attributes)
return_object_or_raise(:transaction) { sale(token, transaction_attributes) }
end
end
end
25 changes: 25 additions & 0 deletions lib/braintree/sepa_direct_debit_account_gateway.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Braintree
class SepaDirectDebitAccountGateway
def initialize(gateway)
@gateway = gateway
@config = gateway.config
@config.assert_has_access_token_or_keys
end

def find(token)
raise ArgumentError if token.nil? || token.to_s.strip == ""
response = @config.http.get("#{@config.base_merchant_path}/payment_methods/sepa_debit_account/#{token}")
SepaDirectDebitAccount._new(@gateway, response[:sepa_debit_account])
rescue NotFoundError
raise NotFoundError, "sepa direct debit account with token #{token.inspect} not found"
end

def delete(token)
raise ArgumentError if token.nil? || token.to_s.strip == ""
@config.http.delete("#{@config.base_merchant_path}/payment_methods/sepa_debit_account/#{token}")
SuccessfulResult.new
rescue NotFoundError
raise NotFoundError, "sepa direct debit account with token #{token.inspect} not found"
end
end
end
28 changes: 28 additions & 0 deletions lib/braintree/sepa_direct_debit_account_nonce_details.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Braintree
class SepaDirectDebitAccountNonceDetails# :nodoc:
include BaseModule

attr_reader :bank_reference_token
attr_reader :last_4
attr_reader :mandate_type
attr_reader :merchant_or_partner_customer_id

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

def inspect
attr_order = [
:bank_reference_token,
:last_4,
:mandate_type,
:merchant_or_partner_customer_id,
]

formatted_attrs = attr_order.map do |attr|
"#{attr}: #{send(attr).inspect}"
end
"#<SepaDirectDebitAccountNonceDetails#{formatted_attrs.join(", ")}>"
end
end
end
2 changes: 2 additions & 0 deletions lib/braintree/test/nonce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Nonce
Transactable = "fake-valid-nonce"
Consumed = "fake-consumed-nonce"
PayPalOneTimePayment = "fake-paypal-one-time-nonce"
#NEXT_MAJOR_VERSION - no longer supported in the Gateway, remove this constant
PayPalFuturePayment = "fake-paypal-future-nonce"
PayPalBillingAgreement = "fake-paypal-billing-agreement-nonce"
LocalPayment = "fake-local-payment-method-nonce"
Expand Down Expand Up @@ -68,6 +69,7 @@ module Nonce
SamsungPayDiscover = "tokensam_fake_discover"
SamsungPayMasterCard = "tokensam_fake_mastercard"
SamsungPayVisa = "tokensam_fake_visa"
SepaDirectDebit = "fake-sepa-direct-debit-nonce"
end
end
end
4 changes: 4 additions & 0 deletions lib/braintree/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module GatewayRejectionReason
AVSAndCVV = "avs_and_cvv"
CVV = "cvv"
Duplicate = "duplicate"
ExcessiveRetry = "excessive_retry"
Fraud = "fraud"
RiskThreshold = "risk_threshold"
ThreeDSecure = "three_d_secure"
Expand Down Expand Up @@ -153,6 +154,8 @@ module Status
attr_reader :samsung_pay_card_details
attr_reader :sca_exemption_requested
attr_reader :service_fee_amount
attr_reader :sepa_direct_debit_account_details
attr_reader :sepa_direct_debit_return_code
attr_reader :settlement_batch_id
attr_reader :shipping_amount
attr_reader :shipping_details
Expand Down Expand Up @@ -307,6 +310,7 @@ def initialize(gateway, attributes) # :nodoc:
@paypal_here_details = PayPalHereDetails.new(@paypal_here)
@samsung_pay_card_details = SamsungPayCardDetails.new(attributes[:samsung_pay_card])
@sca_exemption_requested = attributes[:sca_exemption_requested]
@sepa_direct_debit_account_details = SepaDirectDebitAccountDetails.new(@sepa_debit_account_detail)
@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) } : []
Expand Down
27 changes: 27 additions & 0 deletions lib/braintree/transaction/sepa_direct_debit_account_details.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Braintree
class Transaction
class SepaDirectDebitAccountDetails # :nodoc:
include BaseModule

attr_reader :bank_reference_token
attr_reader :capture_id
attr_reader :debug_id
attr_reader :global_id
attr_reader :last_4
attr_reader :mandate_type
attr_reader :merchant_or_partner_customer_id
attr_reader :paypal_v2_order_id
attr_reader :refund_from_transaction_fee_amount
attr_reader :refund_from_transaction_fee_currency_iso_code
attr_reader :refund_id
attr_reader :settlement_type
attr_reader :token
attr_reader :transaction_fee_amount
attr_reader :transaction_fee_currency_iso_code

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

0 comments on commit 7a01335

Please sign in to comment.