Skip to content

Commit

Permalink
4.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Jun 21, 2021
1 parent 954e045 commit 39d3e24
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 4.2.0
* Add `default?` to `PaymentMethodNonce` (thanks @klouvas)
* Add error code `TaxAmountIsRequiredForAibSwedish` for attribute `tax_amount` in `transaction` key for AIB:Domestic Transactions in Sweden

## 4.1.0
* Add `payment_reader_card_details` parameter to `Transaction.sale`
* Add webhook sample for `GrantedPaymentMethodRevoked`
Expand Down
1 change: 1 addition & 0 deletions lib/braintree/error_codes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ module Transaction
SubscriptionStatusMustBePastDue = "91531"
TaxAmountCannotBeNegative = "81534"
TaxAmountFormatIsInvalid = "81535"
TaxAmountIsRequiredForAibSwedish = "815224"
TaxAmountIsTooLarge = "81536"
ThreeDSecureAuthenticationFailed = "81571"
ThreeDSecureAuthenticationIdDoesntMatchNonceThreeDSecureAuthentication = "915198"
Expand Down
9 changes: 6 additions & 3 deletions lib/braintree/payment_method_nonce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def self.find(*args)
end

attr_reader :bin_data
attr_reader :default
attr_reader :details
attr_reader :nonce
attr_reader :three_d_secure_info
Expand All @@ -23,14 +24,16 @@ def self.find(*args)

def initialize(gateway, attributes) # :nodoc:
@gateway = gateway
@nonce = attributes.fetch(:nonce)
@type = attributes.fetch(:type)
set_instance_variables_from_hash(attributes)
@details = PaymentMethodNonceDetails.new(attributes[:details]) if attributes[:details]
@authentication_insight = attributes.fetch(:authentication_insight, nil)
@three_d_secure_info = ThreeDSecureInfo.new(attributes[:three_d_secure_info]) if attributes[:three_d_secure_info]
@bin_data = BinData.new(attributes[:bin_data]) if attributes[:bin_data]
end

def default?
@default
end

def to_s # :nodoc:
nonce
end
Expand Down
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 = 1
Minor = 2
Tiny = 0

String = "#{Major}.#{Minor}.#{Tiny}"
Expand Down
2 changes: 2 additions & 0 deletions spec/integration/braintree/payment_method_nonce_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
result.payment_method_nonce.should_not be_nil
result.payment_method_nonce.nonce.should_not be_nil
result.payment_method_nonce.details.should_not be_nil
result.payment_method_nonce.default?.should be_truthy
end

it "correctly raises and exception for a non existent token" do
Expand Down Expand Up @@ -67,6 +68,7 @@
payment_method_nonce.should_not be_nil
payment_method_nonce.nonce.should_not be_nil
payment_method_nonce.details.should_not be_nil
payment_method_nonce.default?.should be_truthy
end
end

Expand Down
16 changes: 16 additions & 0 deletions spec/integration/braintree/transaction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5058,6 +5058,22 @@
result.errors.for(:transaction).on(:currency_iso_code)[0].code.should == Braintree::ErrorCodes::Transaction::CurrencyCodeNotSupportedByMerchantAccount
end

it "validates tax_amount for Aib domestic sweden transaction and returns error" do
params = {
:transaction => {
:amount => Braintree::Test::TransactionAmounts::Authorize,
:merchant_account_id => SpecHelper::AibSwedenMaMerchantAccountId,
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2030"
}
}
}
result = Braintree::Transaction.sale(params[:transaction])
result.success?.should == false
result.errors.for(:transaction).on(:tax_amount)[0].code.should == Braintree::ErrorCodes::Transaction::TaxAmountIsRequiredForAibSwedish
end

it "skips advanced fraud checking if transaction[options][skip_advanced_fraud_checking] is set to true" do
with_advanced_fraud_kount_integration_merchant do
result = Braintree::Transaction.sale(
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module SpecHelper
HiperBRLMerchantAccountId = "hiper_brl"
CardProcessorBRLMerchantAccountId = "card_processor_brl"
FakeFirstDataMerchantAccountId = "fake_first_data_merchant_account"
AibSwedenMaMerchantAccountId = "aib_swe_ma"

TrialPlan = {
:description => "Plan for integration tests -- with trial",
Expand Down
40 changes: 40 additions & 0 deletions spec/unit/braintree/payment_method_nonce_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")

describe Braintree::PaymentMethodNonce do
let(:payment_method_nonce) {
Braintree::PaymentMethodNonce._new(
:gateway,
:nonce => "some-nonce",
:type => "CreditCard",
:default => true,
:details => {
:bin => "some-bin"
},
:three_d_secure_info => {
:liability_shift_possible => false,
:liability_shifted => false
},
:bin_data => {
:country_of_issuance => "USA"
},
)
}

describe "#initialize" do
it "sets attributes" do
expect(payment_method_nonce.nonce).to eq("some-nonce")
expect(payment_method_nonce.type).to eq("CreditCard")
expect(payment_method_nonce.default).to be true
expect(payment_method_nonce.details.bin).to eq("some-bin")
expect(payment_method_nonce.three_d_secure_info.liability_shift_possible).to be false
expect(payment_method_nonce.three_d_secure_info.liability_shifted).to be false
expect(payment_method_nonce.bin_data.country_of_issuance).to eq("USA")
end
end

describe "default" do
it "is aliased to default?" do
expect(payment_method_nonce.default?).to be true
end
end
end

0 comments on commit 39d3e24

Please sign in to comment.