Magento redirect checkout payment to a 3rd party gateway

gatewaymagentopaymentredirect

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

Best Answer

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

Related Topic