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?
Best Answer
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' );