osCommerce payment error with realex

November 1, 2007

Came across this one yesterday – was using the Realex payment gateway with osCommerce, and after the transaction was processed was getting this message “Your transaction has been successful but there was a problem connecting back to the merchant’s web site. Please contact the merchant and advise them that you received this error message. Thank you.”.

Fixed the problem in the end by setting SESSION_FORCE_COOKIE_USE to ‘false’ in the configuration table in the database. Here’s what was wrong:

Here’s a quick rundown of how Realex works (or rather, how “Realex redirect” works, they have other services that involve xml messaging) with osCommerce – the page checkout_confirmation.php has a payment button that is a form submit, and that submits various fields by POST to the realex server. The user sees a page where they enter their credit card details, if the card validates the realex server calls a success page on the merchant’s server and displays it.

Called Realex and they told me that their application, on requesting the success page, was receiving a http 302 header (a redirect) instead of a normal http 200 header followed by a page. It doesn’t accept redirects, and so it was displaying the error message. The 302 was redirecting to a login page, which suggested that the session wasn’t being maintained – verified this with a test page.

Thought about it and realised that because the success page was being requested from realex and not from the user’s browser the session cookie wasn’t being sent. No matter, I could see in the code that the session should be restored from a session id in the http POST vars if it was there, and I could see that the session id WAS being sent in the POST vars in the request from realex. Closer inspection of the code revealed the SESSION_FORCE_COOKIE_USE config variable, which was preventing it … so I changed it in the database and hooray!

Advertisements

5 Responses to “osCommerce payment error with realex”

  1. Vladimir Says:

    Hey Cormac,
    thanks for the info. I seem to have exactly the same problem.
    It was resolved when i asked to update their records from: http://www.domainname.com/before_process.php to /before_process.php
    However, now i cant use ip since there are other website registered as default on that server.
    I am still getting exactly the same error with Realex redirect. I also tried falseing SESSION_FORCE_COOKIE_USE in mysql database, double cheded this in /admin section. I also set SESSION_FORCE_COOKIE_USE == ‘False’ at includes/ application_top.php
    still no luck.
    any suggestions?

  2. Vladimir Says:

    upss. rags are not visable. I meant to say that It was resolved when i asked to update their records from: http://www.domainname.com/before_process.php to servers_ip_address/before_process.php

    however now i cant use ip. Any ideas how to get this to work? Oh yeh. it also redirects from before_process.php to login.php when i use chrome.

    hmmmm…

    • cormacscode Says:

      Hi Vladimir

      You might check and see if SESSION_CHECK_USER_AGENT or SESSION_CHECK_IP_ADDRESS are set to true – I don’t have time right now to think about this too deeply (trying to finish something else before 6pm) but I suspect if they are osCommerce might stop the session being maintained when the http request is coming from a new user-agent or a new IP address, which they would be when it’s realex, rather than your browser, that’s sending the request.

      If that doesn’t work what I’d do (if the site isn’t live) is to make a new /before_process.php that writes the $_REQUEST array to a log file so you can see exactly what data realex is sending … the session id should be somewhere in there, and then might be able to trace through the osCommerce code to see why it isn’t being written

      Hope that helps
      Cormac

  3. Vladimir Says:

    Hi Cormac,

    Thanks again. I am far from being a php/mysql programmer however, I have changed SESSION_CHECK_USER_AGENT and SESSION_CHECK_IP_ADDRESS to false. At all website at /includes/application_top.php
    Still the same problem.

    How do i log everything that realex sends?
    Should i “echo” $_REQUEST array at before_process.php?
    I have used below code with no luck:

    foreach( var_dump($_REQUEST) as $value) {
    echo $value;
    }

    What is the easiest way to get those logs?

    • cormacscode Says:

      Just do
      var_dump($_POST);
      You can put it inside tags if you don’t want it to display on the screen (you can still see it when you view the source)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: