Payment Gateway – Custom Payment Gateway Return URL

paymentpayment-gateway

I am trying to port a Woo-commerce Payment Gateway over to Magento 1.9

The payment system redirects the user to an online processing form, the user enters their info on that site, then based on success or failure, the user is redirected back to the magento site.

The payment processor requires me to make one last api call from the magento site to complete the order (can be run for both success or failure). In Woo-commerce I run the api call on a static return page, then redirect the user to the woo-commerce success of failure pages based on the results of the api call.

I am having a little trouble trying to figure out how to run a function on return or how to set/make a success page.

Any help would be appreciated!

Best Answer

Here you can call the api within the action when the user is redirected back to the magento site. Then you can redirected to success page according to payment status. For example if return url is http://yoursite.com/payment/index/success, the success action looks like as shown below :

public function  successAction()
{
    $response = $this->getRequest()->getPost();//get response

   //make another api call here by using curl or whatever

    $this->_redirect('checkout/onepage/success');// redirect success page
}