Magento redirect payment to a third-party gateway

I would like to be able to allow users to select a specific option when placing an order, and then they will be redirected to the bank page, where they use their credit information for payment, then redirected back to magenta and establish the order approved upon successful completion, or does not work, if not

I’ve been messing around with the magento code for several days, I was able to “hack” through one controller to redirect and then return, but I can’t change the order status to “approved” from this controller

what I basically did in the controller in the "saveorder action": - check the payment method chosen by the user - if this is the one I need, send the user the amount to be paid to the bank page - then return from this page to the php page that checks the return status, if it is possible to redirect to one page / success /, if not, to one page / failure

everything works well, but how to change the order status?

I tried that in this link, but this only works for an older version of Magento. http://blog.chapagain.com.np/magento-how-to-change-order-status-programmatically/

thanks

+4
source share
3 answers

Keep in mind that a success page does not necessarily change the payment status to approved. This is because different payment methods may approve a payment at different times. For example, Paypal will not approve a payment until it has the opportunity to process it.

Does your CC company provide callbacks that you can use to update your status? If so, I suggest using the Paypal module as a template for how to handle it (wait for the callback, update the order status). If not, maybe use cronjob and their APIs to check your payment status.

In general, do not depend on customers visiting a certain page after their payment, as there are many situations when this is not so.

Hope this helps!

Thanks Joe

+2
source

I solved this problem after a successful payment from paypal. You can change the ordering process for a downloadable product,

Go to app\code\core\Mage\paypal\controllers\StandardController.php and replace the code after payment, send the mail success and order status with my code.

 public function successAction() { $session = Mage::getSingleton('checkout/session'); $session->setQuoteId($session->getPaypalStandardQuoteId(true)); Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save(); $session->setPaypalStandardQuoteId($session->getQuoteId()); $order = Mage::getModel('sales/order'); $order->load(Mage::getSingleton('checkout/session')->getLastOrderId()); $state = Mage_Sales_Model_Order::STATE_PROCESSING; $order->setState($state); $order->setStatus('processing'); $order->sendNewOrderEmail(); $order->save(); $this->_redirect('checkout/onepage/success', array('_secure'=>true)); } 
+2
source

To change the state of an order (magento 1.5)

 $order->setStatus(Mage_Sales_Model_Order::STATE_COMPLETE); $order->setState(Mage_Sales_Model_Order::STATE_COMPLETE); $order->save(); 
+1
source

All Articles