#StackBounty: #magento-1.9 #onestepcheckout #customer-session #sagepay Customer logged out after checkout & redirected to empty sho…

Bounty: 250

I’m trying to find out why some logged in customers are being logged out of their accounts and redirected to an empty shopping cart after clicking the place order button in Magento.

I am using SagePay 4.1.3 and Idev_OnstepCheckout

I’ve been looking into the saveAfter event in sagePay to see where the session is terminated but I am not able to locate the function call but I can see where the failedPayment.log is called.

public function saveAfter($o)
{
    $order = $o->getEvent()->getOrder();

    $isSage = Mage::helper('sagepaysuite')->isSagePayMethod($order->getPayment()->getMethod());

    if (!$order->getId() || $isSage === false || $order->getIsRecurring()) {
        return $o;
    }

    $dbtrn = $this->_getTransactionsModel()->loadByParent($order->getId());

    if ($dbtrn->getId()) {
        return $o;
    }

    $rqVendorTxCode = Mage::app()->getRequest()->getParam('vtxc');
    $sessionVendor = ($rqVendorTxCode) ? $rqVendorTxCode : $this->getSession()->getLastVendorTxCode();

    if($sessionVendor == null){
        $sessionVendor = Mage::app()->getRequest()->getParam('VendorTxCode');
    }

    /**
     * Multishipping vendors
     */
    $multiShippingTxCodes = Mage::registry('sagepaysuite_ms_txcodes');
    if ($multiShippingTxCodes) {

        Mage::unregister('sagepaysuite_ms_txcodes');

        $sessionVendor = current($multiShippingTxCodes);

        array_shift($multiShippingTxCodes);
        reset($multiShippingTxCodes);

        Mage::register('sagepaysuite_ms_txcodes', $multiShippingTxCodes);
    }
    /**
     * Multishipping vendors
     */

    $reg = Mage::registry('Ebizmarts_SagePaySuite_Model_Api_Payment::recoverTransaction');
    if (!is_null($reg)) {
        $sessionVendor = $reg;
    }

    if (is_null($sessionVendor)) {


        if (!$dbtrn->getId()) {

            #For empty payments or old orders (standalone payment methods).
            if ((Mage::app()->getRequest()->getControllerModule() == 'Mage_Api') || Mage::registry('current_shipment') || Mage::registry('sales_order') || Mage::registry('current_creditmemo') || Mage::registry('current_invoice') || ($order->getPayment()->getMethod() == 'sagepayrepeat')) {
                return $o;
            }

            $logfileName = $order->getIncrementId() . '-' . time() . '_Payment_Failed.log';

            $request_data = $_REQUEST;
            if (isset($request_data['payment'])) {
                $request_data['payment']['cc_number'] = 'XXXXXXXXXXXXX';
                $request_data['payment']['cc_cid'] = 'XXX';
            }

            Sage_Log::log($order->getIncrementId(), null, $logfileName);
            Sage_Log::log(Mage::helper('core/http')->getHttpUserAgent(false), null, $logfileName);
            Sage_Log::log(print_r($request_data, true), null, $logfileName);
            Sage_Log::log('--------------------', null, $logfileName);

            Mage::throwException('Payment has failed, please reload checkout page and try again. Your card has not been charged.');
        }

        return $o;
    }

Has anyone seen this problem before and know roughly how to resolve it?

Any ideas will be welcomed.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.