2

I'm owner of little e-shop. Platform - magento 1.9. For integration with my acquiring provider i copy-past another's code and modified for me. It's work, except this part:

public function responseAction() {
    if($this->getRequest()->isPost()) {

        $result = $_POST['RESULT'];

        if ( $result == "0") {

            $order = Mage::getModel( 'sales/order' );
            $order->loadByIncrementId( $order_id );
            $order->setState( Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Платеж ОДОБРЕН банком' );

        //  $order->sendNewOrderEmail();
        //  $order->setEmailSent( true );

            $order->save();

            Mage::getSingleton('checkout/session')->unsQuoteId();

            Mage_Core_Controller_Varien_Action::_redirect( 'checkout/onepage/success' );
        }
        else {
            $this->cancelAction();
            Mage_Core_Controller_Varien_Action::_redirect( 'checkout/onepage/failure' );
        }
    }
    else
        Mage_Core_Controller_Varien_Action::_redirect( 'vakavaka' );    
}

Gateway of my acquiring provider sending POST to /payment/response if payment verified and accept or declined: result=0 for verified and accept, result=1(2 or 3) if declined or another reason. With "result" param gateway send's many other's parameters.

Work situation:

When payment accepted by gateway and He's sent result=0 (via POST) to http://blahblah.blah/modulename/payment/response, then order is marked as PROCCESSING (with comment), magento sends email to shopper, but shopper redirects to http://blahblah.blah/vakavaka.

If gateway decline payment - order marked as canceled, and shopper redirecting to checkout/onepage/failure (code is work).

I specially mark bold "vakavaka" to attract attention. In my code no this (Mage_Core_Controller_Varien_Action::_redirect( '' );)

What wrong in code?

1
  • WOW! Is my gateway sends data twice: fitrt, gateway redirect me out of his page to modulename/payment/response without POST, then next his sends POST to modulename/payment/response. – Alexander Sep 9 '14 at 15:31
1

It's weird how you're facing this problem. Your code looks fine. Try this though:

Mage_Core_Controller_Varien_Action::_redirect( 'checkout/onepage/success' ); return $this;

instead of

Mage_Core_Controller_Varien_Action::_redirect( 'checkout/onepage/success' );

4
  • This solution is not work - redirecting to main page instead checkout/onepage/success – Alexander Aug 26 '14 at 0:26
  • 1
    This is still relevant. Any ideas? – Alexander Sep 8 '14 at 19:19
  • So after using the above code you are directing to main page and not vakavaka? That is an improvement. Let me check – Paras Sood Sep 8 '14 at 19:26
  • No idea, this code works just fine on my machine! – Paras Sood Sep 8 '14 at 19:39
1

is "Require Customer To Be Logged In To Checkout" in System > configuration > checkout > Checkout options set to YES?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.