magento redirect checkout payment to a 3rd party gateway

孤者浪人 提交于 2019-12-12 12:34:58

问题


I would like to be able to allow users to select a certain option on checkout, and then they will be redirected to the bank page where they use their credit info to pay, then redirected back to magento and set order as approved on success or fail if not

I have been messing around with magento's code for a couple of days, I was able to 'hack' through the onepage controller to do the redirect and then come back, but I am not able to change the status of the order to 'approved' from that controller

what I basically did in the controller in the 'saveorder action' is: - check the payment method selected by the user - if it is the one I need, send user to bank page with the amount to be paid - then return back from that page to a php page that checks the status returned, if successful redirects to onepage/success/ , if not, to onepage/failure

it all works nicely BUT how can I change the order state ?

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

thanks


回答1:


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

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

Overall, do not depend on customers visiting a certain page after they have paid, as there are plenty of situations where this will not be the case.

Hope that helps!

Thanks, Joe




回答2:


I solved this problem after payment success from paypal. You can change order staus process to downloadable product,

Go to app\code\core\Mage\paypal\controllers\StandardController.php and replace the code after payment send 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)); 
} 



回答3:


To change the order state (magento 1.5)

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


来源:https://stackoverflow.com/questions/5728654/magento-redirect-checkout-payment-to-a-3rd-party-gateway

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!