spec/integration/braintree/transaction_spec.rb in braintree-2.48.1 vs spec/integration/braintree/transaction_spec.rb in braintree-2.49.0

- old
+ new

@@ -2306,15 +2306,15 @@ result.errors.for(:transaction).on(:amount)[0].code.should == Braintree::ErrorCodes::Transaction::AmountIsRequired end context "Amex Pay with Points" do context "transaction creation" do - it "burns rewards points when submit_for_settlement is true" do + it "succeeds when submit_for_settlement is true" do result = Braintree::Transaction.sale( :amount => Braintree::Test::TransactionAmounts::Authorize, :credit_card => { - :number => Braintree::Test::CreditCardNumbers::AmExes[0], + :number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::Success, :expiration_date => "05/2009" }, :options => { :submit_for_settlement => true, :amex_rewards => { @@ -2325,42 +2325,61 @@ } } ) result.success?.should == true result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement - result.transaction.amex_rewards_response.should == "success" end - it "returns an error if the credit card is not eligible" do + it "succeeds even if the card is ineligible" do result = Braintree::Transaction.sale( :amount => Braintree::Test::TransactionAmounts::Authorize, :credit_card => { - :number => Braintree::Test::CreditCardNumbers::AmExes[0], + :number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::IneligibleCard, :expiration_date => "05/2009" }, :options => { :submit_for_settlement => true, :amex_rewards => { - :request_id => Braintree::Test::AmexRewards::RequestIds::CardIneligible, + :request_id => "ABC123", :points => "1000", :currency_amount => "10.00", :currency_iso_code => "USD" } } ) result.success?.should == true result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement - result.transaction.amex_rewards_response.should == "RDM2002 Card is not eligible for redemption" end + + it "succeeds even if the card's balance is insufficient" do + result = Braintree::Transaction.sale( + :amount => Braintree::Test::TransactionAmounts::Authorize, + :credit_card => { + :number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::InsufficientPoints, + :expiration_date => "05/2009" + }, + :options => { + :submit_for_settlement => true, + :amex_rewards => { + :request_id => "ABC123", + :points => "1000", + :currency_amount => "10.00", + :currency_iso_code => "USD" + } + } + ) + result.success?.should == true + result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement + end end context "submit for settlement" do - it "burns rewards points when option is set" do + it "succeeds" do result = Braintree::Transaction.sale( :amount => Braintree::Test::TransactionAmounts::Authorize, :credit_card => { - :number => Braintree::Test::CreditCardNumbers::AmExes[0], + :number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::Success, :expiration_date => "05/2009" }, :options => { :amex_rewards => { :request_id => "ABC123", @@ -2369,42 +2388,61 @@ :currency_iso_code => "USD" } } ) result.success?.should == true + + result = Braintree::Transaction.submit_for_settlement(result.transaction.id) + result.success?.should == true + result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement + end + + it "succeeds even if the card is ineligible" do + result = Braintree::Transaction.sale( + :amount => Braintree::Test::TransactionAmounts::Authorize, + :credit_card => { + :number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::IneligibleCard, + :expiration_date => "05/2009" + }, + :options => { + :amex_rewards => { + :request_id => "ABC123", + :points => "1000", + :currency_amount => "10.00", + :currency_iso_code => "USD" + } + } + ) + result.success?.should == true result.transaction.status.should == Braintree::Transaction::Status::Authorized - result.transaction.amex_rewards_response.should be_nil result = Braintree::Transaction.submit_for_settlement(result.transaction.id) result.success?.should == true result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement - result.transaction.amex_rewards_response.should == "success" end - it "returns an error if the credit card is not eligible" do + it "succeeds even if the card's balance is insufficient" do result = Braintree::Transaction.sale( :amount => Braintree::Test::TransactionAmounts::Authorize, :credit_card => { - :number => Braintree::Test::CreditCardNumbers::AmExes[0], + :number => Braintree::Test::CreditCardNumbers::AmexPayWithPoints::IneligibleCard, :expiration_date => "05/2009" }, :options => { :amex_rewards => { - :request_id => Braintree::Test::AmexRewards::RequestIds::CardIneligible, + :request_id => "ABC123", :points => "1000", :currency_amount => "10.00", :currency_iso_code => "USD" } } ) result.success?.should == true result.transaction.status.should == Braintree::Transaction::Status::Authorized - result.transaction.amex_rewards_response.should be_nil result = Braintree::Transaction.submit_for_settlement(result.transaction.id) result.success?.should == true result.transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement - result.transaction.amex_rewards_response.should == "RDM2002 Card is not eligible for redemption" end end end end