Welcome Guest, Not a member yet? Register   Sign In
Query string
#1

[eluser]Philo01[/eluser]
Hi there!

I have a problem.
I am currently building a webshop using CodeIgniter and the payment gateway returns a query string on successful payment like:

(Using mod_rewrite for .html)
Code:
http://www.mydomain.com/order/paid.html?transaction_id=a1b2c3

I would like it to be like:
Code:
http://www.mydomain.com/order/paid/a1b2c3.html

This is an invalid url for CI, and I don't want to enable the query string option.
Does anyone know a solution for this? Maybe with .htaccess?

Thanks!
#2

[eluser]mddd[/eluser]
You could make a simple script:
Code:
// redirection from payment gateway
$transaction_id = $_GET['transaction_id'];
header('Location: http://www.mydomain.com/order/paid/' . $transaction_id . '.html');
Put this script in a location outside CI, for instance in a /scripts folder in your web root.
Set your payment gateway to refer to this script (e.g. www.mydomain.com/scripts/paid.php).
That's it. The simple php script redirects to your CI script.

Also, it is not very difficult to let CI accept $_GET variables and then you could just have the payment gateway send their response directly to your CI page.
#3

[eluser]Philo01[/eluser]
[quote author="mddd" date="1281990497"]You could make a simple script:
Code:
// redirection from payment gateway
$transaction_id = $_GET['transaction_id'];
header('Location: http://www.mydomain.com/order/paid/' . $transaction_id . '.html');
Put this script in a location outside CI, for instance in a /scripts folder in your web root.
Set your payment gateway to refer to this script (e.g. www.mydomain.com/scripts/paid.php).
That's it. The simple php script redirects to your CI script.

Also, it is not very difficult to let CI accept $_GET variables and then you could just have the payment gateway send their response directly to your CI page.[/quote]

Nice one! Thanks! Smile
#4

[eluser]mddd[/eluser]
You're welcome.
It's not the most elegant solution (as would be keeping everything inside CI) but sometimes it's just easy to build a very simple thing, I think.
#5

[eluser]WanWizard[/eluser]
Why not
Code:
<?php
/**
* This extension ensures GET data is not erased
*/
class MY_Input extends CI_Input
{
    function _sanitize_globals()
    {
        $this->allow_get_array = TRUE;
        parent::_sanitize_globals();
    }
}

Which allows you to use $_GET['transaction_id'], and it saves you a redirect.




Theme © iAndrew 2016 - Forum software by © MyBB