spec/integration/braintree/transaction_spec.rb in braintree-2.33.1 vs spec/integration/braintree/transaction_spec.rb in braintree-2.34.0

- old
+ new

@@ -1290,10 +1290,12 @@ :type => "sale", :amount => Braintree::Test::TransactionAmounts::Authorize, :payment_method_nonce => nonce ) result.success?.should == true + result.transaction.paypal_details.should_not be_nil + result.transaction.paypal_details.debug_id.should_not be_nil end it "can create a transaction with a params nonce with PayPal account params" do customer = Braintree::Customer.create! nonce = nonce_for_new_payment_method( @@ -1307,11 +1309,37 @@ :type => "sale", :amount => Braintree::Test::TransactionAmounts::Authorize, :payment_method_nonce => nonce ) result.success?.should == true + result.transaction.paypal_details.should_not be_nil + result.transaction.paypal_details.debug_id.should_not be_nil end + + it "can create a transaction with a payee email" do + customer = Braintree::Customer.create! + nonce = nonce_for_new_payment_method( + :paypal_account => { + :consent_code => "PAYPAL_CONSENT_CODE", + } + ) + nonce.should_not be_nil + + result = Braintree::Transaction.create( + :type => "sale", + :amount => Braintree::Test::TransactionAmounts::Authorize, + :payment_method_nonce => nonce, + :paypal_account => { + :payee_email => "bt_seller_us@paypal.com" + } + ) + + result.success?.should == true + result.transaction.paypal_details.should_not be_nil + result.transaction.paypal_details.debug_id.should_not be_nil + result.transaction.paypal_details.payee_email.should == "bt_seller_us@paypal.com" + end end context "three_d_secure" do it "can create a transaction with a three_d_secure token" do three_d_secure_token = SpecHelper.create_3ds_verification( @@ -1398,10 +1426,12 @@ :payment_method_token => payment_method_result.payment_method.token ) result.should be_success result.transaction.payment_instrument_type.should == Braintree::PaymentInstrumentType::PayPalAccount + result.transaction.paypal_details.should_not be_nil + result.transaction.paypal_details.debug_id.should_not be_nil end end context "future" do it "can create a paypal transaction with a nonce without vaulting" do @@ -1416,10 +1446,12 @@ :amount => Braintree::Test::TransactionAmounts::Authorize, :payment_method_nonce => nonce ) result.should be_success + result.transaction.paypal_details.should_not be_nil + result.transaction.paypal_details.debug_id.should_not be_nil expect do Braintree::PaymentMethod.find(payment_method_token) end.to raise_error(Braintree::NotFoundError, "payment method with token \"#{payment_method_token}\" not found") end @@ -1437,10 +1469,12 @@ :payment_method_nonce => nonce, :options => {:store_in_vault => true} ) result.success?.should == true + result.transaction.paypal_details.should_not be_nil + result.transaction.paypal_details.debug_id.should_not be_nil found_paypal_account = Braintree::PaymentMethod.find(payment_method_token) found_paypal_account.should be_a(Braintree::PayPalAccount) found_paypal_account.token.should == payment_method_token end @@ -1453,10 +1487,12 @@ :amount => Braintree::Test::TransactionAmounts::Authorize, :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment ) result.should be_success + result.transaction.paypal_details.should_not be_nil + result.transaction.paypal_details.debug_id.should_not be_nil end it "can create a paypal transaction and does not vault even if asked to" do payment_method_token = rand(36**3).to_s(36) nonce = nonce_for_paypal_account( @@ -1470,10 +1506,12 @@ :payment_method_nonce => nonce, :options => {:store_in_vault => true} ) result.success?.should == true + result.transaction.paypal_details.should_not be_nil + result.transaction.paypal_details.debug_id.should_not be_nil expect do Braintree::PaymentMethod.find(payment_method_token) end.to raise_error(Braintree::NotFoundError, "payment method with token \"#{payment_method_token}\" not found") end @@ -1495,28 +1533,22 @@ context "void" do it "successfully voids a paypal transaction that's been authorized" do sale_transaction = Braintree::Transaction.sale!( :amount => Braintree::Test::TransactionAmounts::Authorize, - :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment, - :options => { - :submit_for_settlement => true - } + :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment ) void_transaction = Braintree::Transaction.void!(sale_transaction.id) void_transaction.should == sale_transaction void_transaction.status.should == Braintree::Transaction::Status::Voided end it "fails to void a paypal transaction that's been declined" do sale_transaction = Braintree::Transaction.sale( :amount => Braintree::Test::TransactionAmounts::Decline, - :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment, - :options => { - :submit_for_settlement => true - } + :payment_method_nonce => Braintree::Test::Nonce::PayPalOneTimePayment ).transaction expect do Braintree::Transaction.void!(sale_transaction.id) end.to raise_error(Braintree::ValidationsFailed) @@ -3235,9 +3267,41 @@ :amount => "10.00", :payment_method_nonce => nonce ) result.should_not be_success result.errors.for(:transaction).for(:paypal_account).first.code.should == Braintree::ErrorCodes::PayPalAccount::IncompletePayPalAccount + end + end + + context "inline capture" do + it "includes processor_settlement_response_code and processor_settlement_response_text for settlement declined transactions" do + result = Braintree::Transaction.sale( + :amount => "100", + :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment, + :options => { :submit_for_settlement => true } + ) + + result.should be_success + Braintree::Configuration.gateway.testing.settlement_decline(result.transaction.id) + + settlement_declined_transaction = Braintree::Transaction.find(result.transaction.id) + settlement_declined_transaction.processor_settlement_response_code.should == "4001" + settlement_declined_transaction.processor_settlement_response_text.should == "Settlement Declined" + end + + it "includes processor_settlement_response_code and processor_settlement_response_text for settlement pending transactions" do + result = Braintree::Transaction.sale( + :amount => "100", + :payment_method_nonce => Braintree::Test::Nonce::PayPalFuturePayment, + :options => { :submit_for_settlement => true } + ) + + result.should be_success + Braintree::Configuration.gateway.testing.settlement_pending(result.transaction.id) + + settlement_declined_transaction = Braintree::Transaction.find(result.transaction.id) + settlement_declined_transaction.processor_settlement_response_code.should == "4002" + settlement_declined_transaction.processor_settlement_response_text.should == "Settlement Pending" end end end end