I am implementing a payment gateway in my e-commerce application. On success/failure, it returns a JSON response on a given URL(for both success and failure). Depending on the state, I have to redirect it to success and failure URLs with POST data. I need two different URLs(success & failure) for analytic reasons.
My project is on Symfony 2.0
Now I know Symfony has a way to redirect.
$this->redirect($this->generateUrl('pg_success'));
But I cannot send POST data this way.
Also, there is a way to call another action using forward and send arguments
$this->forward('DemoBundle:Checkout:pgsuccess', $_POST);
But this does not change the URL in the address bar.
Is there a way to perform a URL redirect through which I can send arguments? Or some similar solution?
It's not possible to redirect with POST data. You have following options to solve your problem:
Redirect with GET parameters.
$this->redirect($this->generateUrl('pg_success', $_POST));
Use forward with arguments.
$this->forward('DemoBundle:Checkout:pgsuccess', $_POST);
http://symfony.com/doc/current/book/controller.html#forwarding-to-another-controller
Before redirect:
$session = $this->getRequest()->getSession();
$session->set('data' => $_POST);
After redirect:
$session = $this->getRequest()->getSession();
$data = $session->get('data');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With