cian1991ferrari Posted June 14, 2010 Share Posted June 14, 2010 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 More sharing options...
yodapt Posted June 15, 2010 Share Posted June 15, 2010 Just to clarify, what is that you don't know, how to work with the API or how to make Prestashop read the responses from the API? Link to comment Share on other sites More sharing options...
cian1991ferrari Posted June 15, 2010 Author Share Posted June 15, 2010 The thing i don't know is how to handle the response that is posted back and how to validate the order on the given response? Link to comment Share on other sites More sharing options...
yodapt Posted June 15, 2010 Share Posted June 15, 2010 how do you work with the API? through XML or something? Link to comment Share on other sites More sharing options...
cian1991ferrari Posted June 15, 2010 Author Share Posted June 15, 2010 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 More sharing options...
yodapt Posted June 15, 2010 Share Posted June 15, 2010 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 More sharing options...
cian1991ferrari Posted June 16, 2010 Author Share Posted June 16, 2010 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 More sharing options...
yodapt Posted June 16, 2010 Share Posted June 16, 2010 Is any of those fields defined by you before send the request to the API? Link to comment Share on other sites More sharing options...
cian1991ferrari Posted June 17, 2010 Author Share Posted June 17, 2010 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 More sharing options...
yodapt Posted June 17, 2010 Share Posted June 17, 2010 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 More sharing options...
cian1991ferrari Posted June 17, 2010 Author Share Posted June 17, 2010 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 More sharing options...
yodapt Posted June 17, 2010 Share Posted June 17, 2010 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 More sharing options...
cian1991ferrari Posted June 17, 2010 Author Share Posted June 17, 2010 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 More sharing options...
yodapt Posted June 17, 2010 Share Posted June 17, 2010 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 More sharing options...
cian1991ferrari Posted June 17, 2010 Author Share Posted June 17, 2010 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|VChoose Realex method (sends all order info to realex (order info sent can be specified))|VRedirected to Realex and they process order and send back all details sent to them as well as some extra ones|VSent 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 More sharing options...
yodapt Posted June 17, 2010 Share Posted June 17, 2010 it's up to you how to do it, there's many ways actually Link to comment Share on other sites More sharing options...
cian1991ferrari Posted June 17, 2010 Author Share Posted June 17, 2010 Thanks man. I have it all working now!I have made a fully functional Realex Redirect Payment Module!! Link to comment Share on other sites More sharing options...
myindoma Posted June 18, 2010 Share Posted June 18, 2010 Nice.... It will be great...Could you upload your file and provided the Download LinkThanks in advanced... Link to comment Share on other sites More sharing options...
cian1991ferrari Posted June 18, 2010 Author Share Posted June 18, 2010 I'm not too sure if I can man. Developing it in a company that i'm working for in an internship so can't really upload but if I get permission I'll have it straight up! Link to comment Share on other sites More sharing options...
Michal T Posted December 27, 2010 Share Posted December 27, 2010 Hi,Any chances of getting this module from you? Please PM me. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now