spec/integration/braintree/transaction_spec.rb in braintree-2.91.0 vs spec/integration/braintree/transaction_spec.rb in braintree-2.92.0

- old
+ new

@@ -285,10 +285,13 @@ result.success?.should == true result.transaction.id.should =~ /^\w{6,}$/ result.transaction.type.should == "sale" result.transaction.amount.should == BigDecimal.new(Braintree::Test::TransactionAmounts::Authorize) result.transaction.processor_authorization_code.should_not be_nil + result.transaction.processor_response_code.should == "1000" + result.transaction.processor_response_text.should == "Approved" + result.transaction.processor_response_type.should == Braintree::ProcessorResponseTypes::Approved result.transaction.voice_referral_number.should be_nil result.transaction.credit_card_details.bin.should == Braintree::Test::CreditCardNumbers::Visa[0, 6] result.transaction.credit_card_details.last_4.should == Braintree::Test::CreditCardNumbers::Visa[-4..-1] result.transaction.credit_card_details.expiration_date.should == "05/2009" result.transaction.credit_card_details.customer_location.should == "US" @@ -382,11 +385,11 @@ ) result.success?.should == true end - it "returns processor response code and text as well as the additional processor response if declined" do + it "returns processor response code and text as well as the additional processor response if soft declined" do result = Braintree::Transaction.create( :type => "sale", :amount => Braintree::Test::TransactionAmounts::Decline, :credit_card => { :number => Braintree::Test::CreditCardNumbers::Visa, @@ -397,13 +400,33 @@ result.transaction.id.should =~ /^\w{6,}$/ result.transaction.type.should == "sale" result.transaction.status.should == Braintree::Transaction::Status::ProcessorDeclined result.transaction.processor_response_code.should == "2000" result.transaction.processor_response_text.should == "Do Not Honor" + result.transaction.processor_response_type.should == Braintree::ProcessorResponseTypes::SoftDeclined result.transaction.additional_processor_response.should == "2000 : Do Not Honor" end + it "returns processor response code and text as well as the additional processor response if hard declined" do + result = Braintree::Transaction.create( + :type => "sale", + :amount => Braintree::Test::TransactionAmounts::HardDecline, + :credit_card => { + :number => Braintree::Test::CreditCardNumbers::Visa, + :expiration_date => "05/2009" + } + ) + result.success?.should == false + result.transaction.id.should =~ /^\w{6,}$/ + result.transaction.type.should == "sale" + result.transaction.status.should == Braintree::Transaction::Status::ProcessorDeclined + result.transaction.processor_response_code.should == "2015" + result.transaction.processor_response_text.should == "Transaction Not Allowed" + result.transaction.processor_response_type.should == Braintree::ProcessorResponseTypes::HardDeclined + result.transaction.additional_processor_response.should == "2015 : Transaction Not Allowed" + end + it "accepts all four country codes" do result = Braintree::Transaction.sale( :amount => "100", :customer => { :last_name => "Adama", @@ -4009,10 +4032,11 @@ transaction.amount.should == BigDecimal.new("100.00") transaction.currency_iso_code.should == "USD" transaction.order_id.should == "123" transaction.channel.should == "MyShoppingCartProvider" transaction.processor_response_code.should == "1000" + transaction.authorization_expires_at.between?(Time.now, Time.now + (60 * 60 * 24 * 60)).should == true transaction.created_at.between?(Time.now - 60, Time.now).should == true transaction.updated_at.between?(Time.now - 60, Time.now).should == true transaction.credit_card_details.bin.should == "510510" transaction.credit_card_details.cardholder_name.should == "The Cardholder" transaction.credit_card_details.last_4.should == "5100" @@ -5398,10 +5422,11 @@ transaction.status.should == Braintree::Transaction::Status::Authorized transaction.amount.should == BigDecimal.new("100.00") transaction.order_id.should == "123" transaction.channel.should == "MyShoppingCartProvider" transaction.processor_response_code.should == "1000" + transaction.authorization_expires_at.between?(Time.now, Time.now + (60 * 60 * 24 * 60)).should == true transaction.created_at.between?(Time.now - 60, Time.now).should == true transaction.updated_at.between?(Time.now - 60, Time.now).should == true transaction.credit_card_details.bin.should == "510510" transaction.credit_card_details.last_4.should == "5100" transaction.credit_card_details.cardholder_name.should == "The Cardholder" @@ -5919,9 +5944,37 @@ authorization_adjustment.amount.should == "-20.00" authorization_adjustment.success.should == true authorization_adjustment.timestamp.should be_a Time authorization_adjustment.processor_response_code.should == "1000" authorization_adjustment.processor_response_text.should == "Approved" + end + + it "includes authorization adjustments soft declined on found transactions" do + found_transaction = Braintree::Transaction.find("authadjustmenttransactionsoftdeclined") + + found_transaction.authorization_adjustments.count.should == 1 + + authorization_adjustment = found_transaction.authorization_adjustments.first + authorization_adjustment.amount.should == "-20.00" + authorization_adjustment.success.should == false + authorization_adjustment.timestamp.should be_a Time + authorization_adjustment.processor_response_code.should == "3000" + authorization_adjustment.processor_response_text.should == "Processor Network Unavailable - Try Again" + authorization_adjustment.processor_response_type.should == Braintree::ProcessorResponseTypes::SoftDeclined + end + + it "includes authorization adjustments hard declined on found transactions" do + found_transaction = Braintree::Transaction.find("authadjustmenttransactionharddeclined") + + found_transaction.authorization_adjustments.count.should == 1 + + authorization_adjustment = found_transaction.authorization_adjustments.first + authorization_adjustment.amount.should == "-20.00" + authorization_adjustment.success.should == false + authorization_adjustment.timestamp.should be_a Time + authorization_adjustment.processor_response_code.should == "2015" + authorization_adjustment.processor_response_text.should == "Transaction Not Allowed" + authorization_adjustment.processor_response_type.should == Braintree::ProcessorResponseTypes::HardDeclined end end describe "vault_credit_card" do it "returns the Braintree::CreditCard if the transaction credit card is stored in the vault" do