Skip to content

Commit

Permalink
2.95.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Mar 28, 2019
1 parent 1a92747 commit 6e56c70
Show file tree
Hide file tree
Showing 15 changed files with 375 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
# 2.95.0
* Deprecate `GrantedPaymentInstrumentUpdate` and add `GrantorUpdatedGrantedPaymentMethod` and `RecipientUpdatedGrantedPaymentMethod`
* Add account_type support for transaction sale, verification, and payment_method create/update

# 2.94.0
* Add `bin` field to `payment_method_nonce_details`
* Add Error indicating pdf uploads too long for dispute evidence.
Expand Down
2 changes: 1 addition & 1 deletion lib/braintree/credit_card_verification_gateway.rb
Expand Up @@ -46,7 +46,7 @@ def _fetch_verifications(search, ids)

def self._create_signature
[
{:options => [:amount, :merchant_account_id]},
{:options => [:amount, :merchant_account_id, :account_type]},
{:credit_card => [
:cardholder_name, :cvv, :expiration_date, :expiration_month, :expiration_year,
:number, {:billing_address => AddressGateway._shared_signature}
Expand Down
10 changes: 10 additions & 0 deletions lib/braintree/error_codes.rb
Expand Up @@ -100,6 +100,8 @@ module CreditCard
TokenIsTooLong = "91720"
VenmoSDKPaymentMethodCodeCardTypeIsNotAccepted = "91726"
VerificationNotSupportedOnThisMerchantAccount = "91730"
VerificationAccountTypeIsInvalid = "91757"
VerificationAccountTypeNotSupported = "91758"

module Options
UpdateExistingTokenIsInvalid = "91723"
Expand Down Expand Up @@ -419,6 +421,12 @@ module Options
module PayPal
CustomFieldTooLong = "91580"
end

module CreditCard
AccountTypeIsInvalid = "915184"
AccountTypeNotSupported = "915185"
AccountTypeDebitDoesNotSupportAuths = "915186"
end
end

module Industry
Expand Down Expand Up @@ -724,6 +732,8 @@ module Options
MerchantAccountIsSuspended = "94205"
MerchantAccountIsForbidden = "94206"
MerchantAccountCannotBeSubMerchantAccount = "94208"
AccountTypeIsInvalid = "942184"
AccountTypeNotSupported = "942185"
end
end

Expand Down
1 change: 1 addition & 0 deletions lib/braintree/payment_method_gateway.rb
Expand Up @@ -155,6 +155,7 @@ def self._signature(type) # :nodoc:
options = [
:make_default, :verification_merchant_account_id, :verify_card, :venmo_sdk_session,
:verification_amount, :us_bank_account_verification_method,
:verification_account_type,
:paypal => [
:payee_email,
:order_id,
Expand Down
3 changes: 3 additions & 0 deletions lib/braintree/test/credit_card.rb
Expand Up @@ -32,6 +32,9 @@ module CardTypeIndicators
MasterCards = %w[5105105105105100 5555555555554444]

Elo = "5066991111111118"
Hiper = "6370950000000005"
Hipercard = "6062820524845321"

Visa = "4012888888881881"
VisaInternational = "4009348888881881" # :nodoc:
VisaPrepaid = "4500600000000061"
Expand Down
1 change: 1 addition & 0 deletions lib/braintree/transaction/credit_card_details.rb
Expand Up @@ -3,6 +3,7 @@ class Transaction
class CreditCardDetails # :nodoc:
include BaseModule

attr_reader :account_type
attr_reader :bin
attr_reader :card_type
attr_reader :cardholder_name
Expand Down
3 changes: 2 additions & 1 deletion lib/braintree/transaction_gateway.rb
Expand Up @@ -223,7 +223,8 @@ def self._create_signature # :nodoc:
{:paypal => [:custom_field, :payee_id, :payee_email, :description, {:supplementary_data => :_any_key_}]},
{:three_d_secure => [:required]},
{:amex_rewards => [:request_id, :points, :currency_amount, :currency_iso_code]},
{:venmo => [:profile_id]}
{:venmo => [:profile_id]},
{:credit_card => [:account_type]},
]
},
{:external_vault => [
Expand Down
2 changes: 1 addition & 1 deletion lib/braintree/version.rb
@@ -1,7 +1,7 @@
module Braintree
module Version
Major = 2
Minor = 94
Minor = 95
Tiny = 0

String = "#{Major}.#{Minor}.#{Tiny}"
Expand Down
4 changes: 4 additions & 0 deletions lib/braintree/webhook_notification.rb
Expand Up @@ -40,7 +40,11 @@ module Kind
ConnectedMerchantStatusTransitioned = "connected_merchant_status_transitioned"
ConnectedMerchantPayPalStatusChanged = "connected_merchant_paypal_status_changed"

# NEXT_MAJOR_VERSION remove GrantedPaymentInstrumentUpdate. Kind is not sent by Braintree Gateway.
# Kind will either be GrantorUpdatedGrantedPaymentMethod or RecipientUpdatedGrantedPaymentMethod.
GrantedPaymentInstrumentUpdate = "granted_payment_instrument_update"
GrantorUpdatedGrantedPaymentMethod = "grantor_updated_granted_payment_method"
RecipientUpdatedGrantedPaymentMethod = "recipient_updated_granted_payment_method"
GrantedPaymentInstrumentRevoked = "granted_payment_instrument_revoked"

LocalPaymentCompleted = "local_payment_completed"
Expand Down
5 changes: 5 additions & 0 deletions lib/braintree/webhook_testing_gateway.rb
Expand Up @@ -76,8 +76,13 @@ def _subject_sample_xml(kind, id)
_ideal_payment_complete_sample_xml(id)
when Braintree::WebhookNotification::Kind::IdealPaymentFailed
_ideal_payment_failed_sample_xml(id)
# NEXT_MAJOR_VERSION remove GrantedPaymentInstrumentUpdate
when Braintree::WebhookNotification::Kind::GrantedPaymentInstrumentUpdate
_granted_payment_instrument_update_sample_xml(id)
when Braintree::WebhookNotification::Kind::GrantorUpdatedGrantedPaymentMethod
_granted_payment_instrument_update_sample_xml(id)
when Braintree::WebhookNotification::Kind::RecipientUpdatedGrantedPaymentMethod
_granted_payment_instrument_update_sample_xml(id)
when Braintree::WebhookNotification::Kind::LocalPaymentCompleted
_local_payment_completed_sample_xml(id)
else
Expand Down
63 changes: 63 additions & 0 deletions spec/integration/braintree/credit_card_verification_spec.rb
Expand Up @@ -61,6 +61,69 @@
result.success?.should == false
result.errors.for(:verification).for(:options).first.code.should == Braintree::ErrorCodes::Verification::Options::AmountCannotBeNegative
end

it "returns account type with debit" do
result = Braintree::CreditCardVerification.create(
:credit_card => {
:expiration_date => "01/2020",
:number => Braintree::Test::CreditCardNumbers::Hiper
},
:options => {
:merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
:account_type => "debit",
},
)

result.success?.should == true
result.credit_card_verification.credit_card[:account_type].should == "debit"
end

it "returns account type with credit" do
result = Braintree::CreditCardVerification.create(
:credit_card => {
:expiration_date => "01/2020",
:number => Braintree::Test::CreditCardNumbers::Hiper
},
:options => {
:merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
:account_type => "credit",
},
)

result.success?.should == true
result.credit_card_verification.credit_card[:account_type].should == "credit"
end

it "errors with unsupported account type" do
result = Braintree::CreditCardVerification.create(
:credit_card => {
:expiration_date => "01/2020",
:number => Braintree::Test::CreditCardNumbers::Visa
},
:options => {
:account_type => "credit",
},
)

result.success?.should == false
result.errors.for(:verification).for(:options).on(:account_type)[0].code.should == Braintree::ErrorCodes::Verification::Options::AccountTypeNotSupported
end

it "errors with invalid account type" do
result = Braintree::CreditCardVerification.create(
:credit_card => {
:expiration_date => "01/2020",
:number => Braintree::Test::CreditCardNumbers::Hiper
},
:options => {
:merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
:account_type => "ach",
},
)

result.success?.should == false
result.errors.for(:verification).for(:options).on(:account_type)[0].code.should == Braintree::ErrorCodes::Verification::Options::AccountTypeIsInvalid
end
end

describe "self.find" do
Expand Down
141 changes: 141 additions & 0 deletions spec/integration/braintree/payment_method_spec.rb
Expand Up @@ -487,6 +487,147 @@ def make_token
found_credit_card.billing_address.street_address.should == "456 Xyz Way"
end

context "account_type" do
it "verifies card with account_type debit" do
nonce = nonce_for_new_payment_method(
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Hiper,
:expiration_month => "11",
:expiration_year => "2099",
}
)
customer = Braintree::Customer.create!
result = Braintree::PaymentMethod.create(
:payment_method_nonce => nonce,
:customer_id => customer.id,
:options => {
:verify_card => true,
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
:verification_account_type => "debit",
}
)

result.should be_success
result.payment_method.verification.credit_card[:account_type].should == "debit"
end

it "verifies card with account_type credit" do
nonce = nonce_for_new_payment_method(
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Hiper,
:expiration_month => "11",
:expiration_year => "2099",
}
)
customer = Braintree::Customer.create!
result = Braintree::PaymentMethod.create(
:payment_method_nonce => nonce,
:customer_id => customer.id,
:options => {
:verify_card => true,
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
:verification_account_type => "credit",
}
)

result.should be_success
result.payment_method.verification.credit_card[:account_type].should == "credit"
end

it "errors with invalid account_type" do
nonce = nonce_for_new_payment_method(
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Hiper,
:expiration_month => "11",
:expiration_year => "2099",
}
)
customer = Braintree::Customer.create!
result = Braintree::PaymentMethod.create(
:payment_method_nonce => nonce,
:customer_id => customer.id,
:options => {
:verify_card => true,
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
:verification_account_type => "ach",
}
)

result.should_not be_success
result.errors.for(:credit_card).for(:options).on(:verification_account_type)[0].code.should == Braintree::ErrorCodes::CreditCard::VerificationAccountTypeIsInvalid
end

it "errors when account_type not supported by merchant" do
nonce = nonce_for_new_payment_method(
:credit_card => {
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_month => "11",
:expiration_year => "2099",
}
)
customer = Braintree::Customer.create!
result = Braintree::PaymentMethod.create(
:payment_method_nonce => nonce,
:customer_id => customer.id,
:options => {
:verify_card => true,
:verification_account_type => "credit",
}
)

result.should_not be_success
result.errors.for(:credit_card).for(:options).on(:verification_account_type)[0].code.should == Braintree::ErrorCodes::CreditCard::VerificationAccountTypeNotSupported
end

it "updates the credit card with account_type credit" do
customer = Braintree::Customer.create!
credit_card = Braintree::CreditCard.create!(
:cardholder_name => "Original Holder",
:customer_id => customer.id,
:cvv => "123",
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2012"
)
update_result = Braintree::PaymentMethod.update(credit_card.token,
:cardholder_name => "New Holder",
:cvv => "456",
:number => Braintree::Test::CreditCardNumbers::Hiper,
:expiration_date => "06/2013",
:options => {
:verify_card => true,
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
:verification_account_type => "credit",
},
)
update_result.success?.should == true
update_result.payment_method.verification.credit_card[:account_type].should == "credit"
end

it "updates the credit card with account_type debit" do
customer = Braintree::Customer.create!
credit_card = Braintree::CreditCard.create!(
:cardholder_name => "Original Holder",
:customer_id => customer.id,
:cvv => "123",
:number => Braintree::Test::CreditCardNumbers::Visa,
:expiration_date => "05/2012"
)
update_result = Braintree::PaymentMethod.update(credit_card.token,
:cardholder_name => "New Holder",
:cvv => "456",
:number => Braintree::Test::CreditCardNumbers::Hiper,
:expiration_date => "06/2013",
:options => {
:verify_card => true,
:verification_merchant_account_id => SpecHelper::HiperBRLMerchantAccountId,
:verification_account_type => "debit",
},
)
update_result.success?.should == true
update_result.payment_method.verification.credit_card[:account_type].should == "debit"
end
end

context "paypal" do
it "creates a payment method from an unvalidated future paypal account nonce" do
nonce = nonce_for_paypal_account(:consent_code => "PAYPAL_CONSENT_CODE")
Expand Down

0 comments on commit 6e56c70

Please sign in to comment.