spec/integration/braintree/transaction_spec.rb in braintree-2.94.0 vs spec/integration/braintree/transaction_spec.rb in braintree-2.95.0

- old
+ new

@@ -2396,19 +2396,10 @@ refund_transaction = Braintree::Transaction.refund(transaction.id).transaction refund_transaction.refunded_transaction_id.should == transaction.id end - it "returns an error if already refunded" do - transaction = create_paypal_transaction_for_refund - result = Braintree::Transaction.refund(transaction.id) - result.success?.should == true - result = Braintree::Transaction.refund(transaction.id) - result.success?.should == false - result.errors.for(:transaction).on(:base)[0].code.should == Braintree::ErrorCodes::Transaction::HasAlreadyBeenRefunded - end - it "returns an error result if unsettled" do transaction = Braintree::Transaction.sale!( :amount => Braintree::Test::TransactionAmounts::Authorize, :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment ) @@ -3953,10 +3944,126 @@ result.errors.for(:transaction).for(:external_vault).on(:previous_network_transaction_id)[0].code.should == Braintree::ErrorCodes::Transaction::ExternalVault::CardTypeIsInvalid end end end + + context "account_type" do + it "creates a Hiper transaction with account type credit" do + result = Braintree::Transaction.create( + :type => "sale", + :merchant_account_id => SpecHelper::HiperBRLMerchantAccountId, + :credit_card => { + :number => Braintree::Test::CreditCardNumbers::Hiper, + :expiration_date => "05/2009" + }, + :amount => "10.00", + :options => { + :credit_card => { + :account_type => "credit", + } + } + ) + result.success?.should == true + result.transaction.credit_card_details.account_type.should == "credit" + end + + it "creates a Hipercard transaction with account_type credit" do + result = Braintree::Transaction.create( + :type => "sale", + :merchant_account_id => SpecHelper::HiperBRLMerchantAccountId, + :credit_card => { + :number => Braintree::Test::CreditCardNumbers::Hipercard, + :expiration_date => "05/2009" + }, + :amount => "10.00", + :options => { + :credit_card => { + :account_type => "credit", + } + } + ) + result.success?.should == true + result.transaction.credit_card_details.account_type.should == "credit" + end + + it "creates a Hiper transaction with account_type debit" do + result = Braintree::Transaction.create( + :type => "sale", + :merchant_account_id => SpecHelper::HiperBRLMerchantAccountId, + :credit_card => { + :number => Braintree::Test::CreditCardNumbers::Hiper, + :expiration_date => "05/2009" + }, + :amount => "10.00", + :options => { + :credit_card => { + :account_type => "debit", + }, + :submit_for_settlement => true, + } + ) + result.success?.should == true + result.transaction.credit_card_details.account_type.should == "debit" + end + + it "does not allow auths with account_type debit" do + result = Braintree::Transaction.create( + :type => "sale", + :merchant_account_id => SpecHelper::HiperBRLMerchantAccountId, + :credit_card => { + :number => Braintree::Test::CreditCardNumbers::Hiper, + :expiration_date => "05/2009" + }, + :amount => "10.00", + :options => { + :credit_card => { + :account_type => "debit", + }, + } + ) + result.success?.should == false + result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeDebitDoesNotSupportAuths + end + + it "does not allow invalid account_type" do + result = Braintree::Transaction.create( + :type => "sale", + :merchant_account_id => SpecHelper::HiperBRLMerchantAccountId, + :credit_card => { + :number => Braintree::Test::CreditCardNumbers::Hiper, + :expiration_date => "05/2009" + }, + :amount => "10.00", + :options => { + :credit_card => { + :account_type => "ach", + }, + } + ) + result.success?.should == false + result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeIsInvalid + end + + it "does not allow account_type not supported by merchant" do + result = Braintree::Transaction.create( + :type => "sale", + :credit_card => { + :number => Braintree::Test::CreditCardNumbers::Visa, + :expiration_date => "05/2009" + }, + :amount => "10.00", + :options => { + :credit_card => { + :account_type => "credit", + }, + } + ) + result.success?.should == false + result.errors.for(:transaction).for(:options).for(:credit_card).on(:account_type)[0].code.should == Braintree::ErrorCodes::Transaction::Options::CreditCard::AccountTypeNotSupported + end + end end describe "self.create!" do it "returns the transaction if valid" do transaction = Braintree::Transaction.create!( @@ -6267,11 +6374,11 @@ result = Braintree::Transaction.sale( :amount => "10.00", :venmo_sdk_payment_method_code => Braintree::Test::VenmoSDK::InvalidPaymentMethodCode ) result.success?.should == false - result.message.should == "Invalid VenmoSDK payment method code" - result.errors.first.code.should == "91727" + result.message.should include("Invalid VenmoSDK payment method code") + result.errors.map(&:code).should include("91727") end end describe "venmo_sdk_session" do it "can create a transaction and vault a card when a venmo_sdk_session is present" do