开发者

magento redirect checkout payment to a 3rd party gateway

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 thei开发者_运维问答r 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


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


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)); 
} 


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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜