Jump to content

[SOLVED] Payment Module Response HELP


cian1991ferrari

Recommended Posts

Hi everyone. I'm developing 2 payment modules for a Realex payment gateway (Their 2 methods: redirect & remote).

In the redirect method, I have everything working except for the validation in prestashop. Realex sends back the verification of the order and that it was succesful but I don't know how to validate the order given the responses from realex. In other words when I go back to the site and the dummy payments are received in realex, the items are still in the prestashop cart even though they have been paid for. Can someone shed some light on this??? What is it i need to do??

Link to comment
Share on other sites

Prestashop module sends XML to Realex in the remote method or in redirect method it simply sends PHP variables to Realex. Realex then processes the data and sends it back as well as response codes etc.

The thing I do not know how to do is to use the response to validate the order so it is no longer in the cart when we return to the site, but instead is a validated order in the customers order records.

Link to comment
Share on other sites

Can you provide an example of a response? I'm sure Realex API has a method to validate it ..

Probably (without any specs) you'll need to add an extra field to the database in order to use it as a validation field.

Link to comment
Share on other sites

These are fields posted back by Realex:

$timestamp = $_POST['TIMESTAMP'];
$result = $_POST['RESULT'];
$orderid = $_POST['ORDER_ID'];
$message = $_POST['MESSAGE'];
$authcode = $_POST['AUTHCODE'];
$pasref = $_POST['PASREF'];
$realexmd5 = $_POST['MD5HASH'];

I just do not know how to validate the order in PrestaShop from these fields. Anything else can be posted to Realex as a hidden field and should be sent back like above.

Link to comment
Share on other sites

From the above list, only the following are defined and sent to Realex and sent back:

$timestamp = $_POST[‘TIMESTAMP’];
$orderid = $_POST[‘ORDER_ID’];

This is the form that is originally sent to Realex:

<form action="{$realex_url}" method="post" id="realex_form" class="hidden">
           <input type="hidden" name="MERCHANT_ID" value="{$merchant}">
           <input type="hidden" name="ORDER_ID" value="{$order_id}">
           <input type="hidden" name="ACCOUNT" value="{$account}">
           <input type="hidden" name="AMOUNT" value="{$amount}">
           <input type="hidden" name="CURRENCY" value="{$currency_module->iso_code}">
           <input type="hidden" name="TIMESTAMP" value="{$timestamp}">
           <input type="hidden" name="MD5HASH" value="{$hashcode}">
           <input type="hidden" name="AUTO_SETTLE_FLAG" value="1">
       </form>

Link to comment
Share on other sites

Try to check if any of those values is an unique ID for the order. If they return one, you can add an extra field to ps_cart table and check the status. If the proccess shows up a bit more complex, you can create a table just for that API.

Link to comment
Share on other sites

The ORDER_ID field is the id of the order we need to validate. What I am trying to do is use the ORDER_ID posted back, as well as the RESULT of the transaction to validate the order in the PS database. For example, if payment went through and all is well, RESULT returned will be '00' so if that is the case I need to validate the order in the database so that it shows as paid and is no longer in the cart. This is my main problem..

What table is the order validated in and status read from?

Link to comment
Share on other sites

ps_order_state table is where the status of each order is updated. You should change the table to have some extra field, or create an extra table just for realex, relating her to the PS default order state table.

Link to comment
Share on other sites

But would it not be possible just to say something like if the result back from Realex = 00 which is positive or success, update the order state to be successful or completed etc in the original ps order_state table just using the functions in place from the PayPal module?

Link to comment
Share on other sites

If the response is retrieved at the time of the request, yes, you could just update that table to confirm the payment. I'm not aware of that payment method, so I didn't supposed something that could lead you into error.

Link to comment
Share on other sites

Yeah I think I can adapt it someway i'm just not sure how. I've come up with what I think is the sequence of events:

Do the shopping and put items in cart
|
V
Choose Realex method (sends all order info to realex (order info sent can be specified))
|
V
Redirected to Realex and they process order and send back all details sent to them as well as some extra ones
|
V
Sent to response script on server
|
V
?????

This is where I just need to get help on.

My thinking is, if I send the correct fields to a script such as validation.php in the PayPal module, this should pass variables to that page and use the ValidateOrder() function.. Just quite unsure.

Link to comment
Share on other sites

  • 6 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...