Post by danielmedo » Sat Sep 11, 2010 4:03 am

Hi,

i am creating payment module which needs to send callback url to payment gateway server as a hidden parameter.
The callback url is shown like this
http://example.com/opencart/index.php?r ... e/callback
but gateway server is refusing this url because this server is not accepting query strings and i cannot do anything about that.
What i can do is convert the route parameter to something like this
http://example.com/opencart/index/route ... e/callback
but when i do that, opencart don't recognise the route and sends me to 404 error page.

Is there anything what can be done about this? Should I write bug report about it?

Thanks for any information,
Daniel

Newbie

Posts

Joined
Sat Sep 11, 2010 3:45 am

Post by Qphoria » Sat Sep 11, 2010 4:40 am

I've run into this a few times. It is unfortunately that some payment gateways cant handle simple common http protocols.

The way I get around it is to add a callback script to the root path like "mypay_callback.php"
Put that into the root folder and set the callback url to HTTP_SERVER . 'mypay_callback.php';

Then in the mypay_callback.php file, Capture the $_REQUEST data and you have a few options

1. make a foreach to loop it into a query string and send that as a GET back to your real callback function
2. use curl to take the data and POST it to your real callback function
3. use some other redirect magic to route it back to your real callback function

I always use the first way
This is what I use:

Code: Select all

<?php
/* Redirect to the payment module page in the current directory that was requested */
$host  = $_SERVER['HTTP_HOST'];
$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$path  = 'index.php?route=payment/mypay/callback';
$query = "";
foreach($_REQUEST as $key => $value) {
    $query .= '&' . $key . '=' . urlencode($value);
}
$query = rtrim($query, '&');
header("Location: http://$host$uri/$path$query");
exit;
?>
Then in my real callback function I grab the &_GET variables

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by danielmedo » Sat Sep 11, 2010 6:01 pm

Hi Qphoria,

your solution is exactly what i needed, thanks for it.

Newbie

Posts

Joined
Sat Sep 11, 2010 3:45 am
Who is online

Users browsing this forum: No registered users and 10 guests