In a custom payement gateway, where the store redirects to third party website for payment. To request i have options to send either in POST/GET. I'm requesting with POST method. But the response they give is in get method.
The response url according to their documentation is http://yoursite.com/success?q=su&oid=XYZ1234&amt=100&refId=000AE01
And in my case i have captured response at http://yoursite.com/cgateway/payment/response with responseAction method of PaymentController.php controller.
The result i obtained is http://yoursite.com/cgateway/payment/response?q=su&oid=XYZ1234&amt=100&refId=000AE01
Now the problem is how should i get those data in responseAction in PaymentController ?
2 Answers 2
To get params in a controller you can use:
$this->getRequest()->getParam('paramName');
or
$this->getRequest()->getParams();
Magento's default routing algorithm uses three part URLs.
http://example.com/front-name/controller-name/action-method
So when you call
http://example.com/path/action/id/123
The word path is your front name, action is your controller name, and id is your action method. After these three methods, you can use getParam to grab a key/value pair
http://yoursite.com/cgateway/payment/response?q=su&oid=XYZ1234&amt=100&refId=000AE01
//in a controller
var_dump($this->getRequest()->getParams('q'));
You may also use the getParams method to grab an array of parameters
$this->getRequest()->getParams();
Hope this helps