Magento Forum

   
Page 1 of 5
Shopping cart empty after canceling external payment provider (like paypal)
 
Nijhof Internet Media
Member
 
Avatar
Total Posts:  32
Joined:  2008-07-04
Netherlands
 

Magento version: 1.4.1.0 + pre 1.4.1.1 fix = 1.4.x-devel-71052
Clean install

Case:
- Customer checks out with a payment method like paypal or other payment service provider (redirect)
- On the external page customer decides to cancel the transaction because he wants to use a different payment method
- Customer is returned by the PSP to Magento checkout
- checkout is redirected to shopping cart -> “your shopping cart is empty”

Customer is correctly returned to checkout but his shopping cart is empty and a redirect to shopping cart happens.

In Magento 1.4.0.1 the shopping cart is not emptied when canceling a transaction so he’s returned to checkout and can choose an other payment method or whatever he wants to change. This is correct behaviour.

Anyone experiencing same behaviour and solved it grin ?

See also bug report: http://www.magentocommerce.com/bug-tracking/issue?issue=9431

 
Magento Community Magento Community
Magento Community
Magento Community
 
quickfoxz
Jr. Member
 
Total Posts:  7
Joined:  2009-10-26
 

Same problem here.

I noticed that the follwing does the trick, but i’m not sure if its the right way to do.

On r163 in app/code/core/Mage/Sales/Model/Service/Quote.php change
$quote->setIsActive(false); to $quote->setIsActive(true);

This works fine with a cancel or failure action, but for the succes action you need to set it back to false.

Can someone tell me if this solution is OK?

 
Magento Community Magento Community
Magento Community
Magento Community
 
zyguy
Jr. Member
 
Avatar
Total Posts:  6
Joined:  2008-12-09
 

Quickfoxz where you able to resolve this issue?  Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
Nijhof Internet Media
Member
 
Avatar
Total Posts:  32
Joined:  2008-07-04
Netherlands
 

I did some investigation, looked at app/code/core/Mage/Sales/Model/Service/Quote.php

Version 1.4.0.1 does not have this problem and if you compare these 2 versions you\’ll see that the 1.4.1.0 version is very different.
Function submit is now submitOrder and the only difference between the two is the new call \"$this->_deleteNominalItems();\" at the top of submitOrder.

It has something to do with the new recurring profiles feature I think.
Furder investigation is needed....

 
Magento Community Magento Community
Magento Community
Magento Community
 
sandboxthreads
Jr. Member
 
Avatar
Total Posts:  12
Joined:  2009-06-05
 
quickfoxz - 14 July 2010 02:49 AM

Same problem here.

I noticed that the follwing does the trick, but i’m not sure if its the right way to do.

On r163 in app/code/core/Mage/Sales/Model/Service/Quote.php change
$quote->setIsActive(false); to $quote->setIsActive(true);

This works fine with a cancel or failure action, but for the succes action you need to set it back to false.

Can someone tell me if this solution is OK?

This works for me, but did you ever find out if this is the “right” way to solve the issue?

 
Magento Community Magento Community
Magento Community
Magento Community
 
hedge007
Jr. Member
 
Total Posts:  4
Joined:  2008-11-27
 

It helps for me.. But last few days I’m checking my exception log file and still have the same exceptions: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails for FK - FK_SALES_QUOTE_PAYMENT_SALES_QUOTE.

So there is something else there. Not sure how to reproduce it as well.

Any thoughts? I guess it is real bug of 1.4.1.0.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

I have ver 1.4.1.1 and have the same issue of having an empty cart after payment is canceled. For this version, I change a core file to get back the cart:

file /app/code/core/Mage/Sales/Model/Service/Quote.php line 72:

line 72: protected $_shouldInactivateQuote false//original is set to true

That seems to fix the problem in my case but I am not able to test this completely and I do not know what happen when the payment is successful (some problem with the payment module I am developing currently).

 
Magento Community Magento Community
Magento Community
Magento Community
 
Nijhof Internet Media
Member
 
Avatar
Total Posts:  32
Joined:  2008-07-04
Netherlands
 

An upgrade to version 1.4.1.1 fixed it for me. I use PayPal and a module from a Dutch PSP (multisafepay) and in both cases when a transaction is cancelled the shopping cart is NOT emptied.
So for me this is solved with 1.4.1.1

 
Magento Community Magento Community
Magento Community
Magento Community
 
hidonet
Member
 
Avatar
Total Posts:  52
Joined:  2008-03-25
Istanbul
 

On r163 in app/code/core/Mage/Sales/Model/Service/Quote.php change
$quote->setIsActive(false); to $quote->setIsActive(true);

Thanks for that. This solved my problem… wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
timpea
Member
 
Total Posts:  68
Joined:  2007-09-03
 

app/code/core/Mage/Sales/Model/Service/Quote.php change
$quote->setIsActive(false); to $quote->setIsActive(true);

Changing this allows you to keep the items in the basket after Cancel but also keeps them in the basket after a successful order which isn’t idea.

Has anyone found a way for this to work?

Nijhof you said that 1.4.1.1 fixed it for you, I am running 1.4.1.1 and have this problem.  Going to try a fresh install and see if the problem is still there.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Nijhof Internet Media
Member
 
Avatar
Total Posts:  32
Joined:  2008-07-04
Netherlands
 

You’re right, Timpea.
The reason I thought it was fixed was because I use OneStepCheckout extension.

I did some tests with the native Onepage checkout and unfortunately it turns out that the problem is still there: the onepage checkout is always emptying the card nomatter it is an external payment gateway or not.
And yes, like you said, changing app/code/core/Mage/Sales/Model/Service/Quote.php is not a good idea…

But the good news is that I think I got it fixed. (only tested with Magento version 1.4.1.1)
Just make the following change (better to make a local copy) in file: app/code/core/Mage/Checkout/controllers/OnepageController.php
line 484 - 491 ORIGINAL:

$this->getOnepage()->getQuote()->save();
        
/**
         * when there is redirect to third party, we don't want to save order yet.
         * we will save the order in return action.
         */
        
if (isset($redirectUrl)) {
            $result[
'redirect'$redirectUrl;
        
}

CHANGE TO

//$this->getOnepage()->getQuote()->save();
        /**
         * when there is redirect to third party, we don't want to save order yet.
         * we will save the order in return action.
         */
        if (isset($redirectUrl)) {
            $result[
'redirect'$redirectUrl;
        
}
        
else {
            $this
->getOnepage()->getQuote()->save();
        
}

As you can see, in the original code the quote is always saved (this was modified in version 1.4.1.0, before that this was not the case) thus emptying the cart.
But we don’t want that to happen if there is a redirect to an external payment method.

I tested this with checkout as Guest and the following payment methods:
- native check / money order: cart is emptied (=ok)
- native PayPal, transaction OK: cart is emptied (=ok)
- native PayPal, transaction Cancelled: cart is NOT emptied (=ok)
- third party PSP module (dutch multisafepay): transaction OK: cart is emptied (=ok)
- third party PSP module (dutch multisafepay): transaction Cancelled: cart is NOT emptied (=ok)

I didn’t test it yet with a logged in account or “make account” but I guess this will be ok too.

Please let e know if this works for you too.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

@Hijhof, Thanks for your workaround and test report. I checked earlier version of OnepageController, the $quote object is saved when there is an exception:

catch (Mage_Core_Exception $e{
            Mage
::logException($e);
            
Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
            
$result['success'false;
            
$result['error'true;
            
$result['error_messages'$e->getMessage();
            
$this->getOnepage()->getQuote()->save();
        
}
        
catch (Exception $e{
            Mage
::logException($e);
            
Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
            
$result['success']  false;
            
$result['error']    true;
            
$result['error_messages'$this->__('There was an error processing your order. Please contact us or try again later.');
            
$this->getOnepage()->getQuote()->save();
        
}

        
/**
         * when there is redirect to third party, we don't want to save order yet.
         * we will save the order in return action.
         */
        
if (isset($redirectUrl)) {
            $result[
'redirect'$redirectUrl;
        
}

And your work around is correct since when there is an exception, $redirectUrl is unlikely to be set and the $quote object will be saved.

It seems that when the save statement is moved from the exception in ver 1.4, a bug may have been created.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

It turns out that the issue has been reported:  http://www.magentocommerce.com/bug-tracking/issue/?issue=9711

 
Magento Community Magento Community
Magento Community
Magento Community
 
Nijhof Internet Media
Member
 
Avatar
Total Posts:  32
Joined:  2008-07-04
Netherlands
 

Thanks kiatng.

I read the bug report and it’s strange that the magento development team isn’t able to reproduce the faulty behaviour since it is also happening with the native PayPal payment method.

Anyway, this workaround will be sufficient for now for most people.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Swil
Jr. Member
 
Total Posts:  17
Joined:  2009-06-19
 

@Nijhof,

thanks for the solution - I tried it with a registered user and indeed it works as well.

 
Magento Community Magento Community
Magento Community
Magento Community
 
timpea
Member
 
Total Posts:  68
Joined:  2007-09-03
 

@Nijhof, its working for me.  Thankyou.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 1 of 5