phpe-commerceworldpay

How Do I Create Returning Page Setting with WorldPay?


The docs for WorldPay are really difficult for me to understand after reading and re-reading them for hours. (In fact, many of the docs gave me the wrong Live URL and I had to look around on the web and try things with trial/error in order to find the Live URL, for instance.)

How do I create a returning page setting with WorldPay? By this, I mean when someone posts the payment and then pays on the WorldPay site, WorldPay would then automatically redirect the shopper back to a page on my site if successful. I want to know how to do this. I think I guessed it below, but am not certain if it works?

<?php ?>
<html><head><title></title></head><body>
<form action="https://secure.wp3.rbsworldpay.com/wcc/purchase" method="post">
    <input type="hidden" name="testMode" value="0">
    <input type="hidden" name="instId" value="<?= $this->INST_ID ?>">
    <input type="hidden" name="cartId" value="<?= $this->CART_ID ?>">
    <input type="hidden" name="amount" value="<?= $this->AMOUNT ?>">
    <input type="hidden" name="currency" value="<?= $this->CURRENCY_CODE ?>">
    <input type="hidden" name="desc" value="Photos">
    <input type="hidden" name="MC_success" value="<?= $this->RETURNING_PAGE_ON_MY_SITE ?>">
    <input type="submit" value="Click here for the secure payment form">
</form>
</body></html>

EDIT: WorldPay tech support said that the action must now be "https://secure.worldpay.com/wcc/purchase" and the MC_success parameter won't work. He advised me to use a wpdisplay parameter in the form post so that we tell the result page to swap header and do a meta redirect back to a page on our site. I asked for an example and he said there was none. All he could do was point me at this confusing documentation that doesn't really describe this at all. (I don't fault the tech support guy -- he's just doing his job with the weak tools he's given.)


Solution

  • After spending 3-4 days and reading all the confusing and poor documentation of Worldpay, somehow I found how to return to some page and process the response returned by Worldpay. I wanted to insert a record in a database with transaction details. So I was looking for solution. Well, here is the solution that worked for me:

    1. login to Worldpay, open desired installation to edit
    2. Tick on "Payment Response enabled?"
    3. Provide "Payment Response URL" to the page which will be receiving/processing the POST data from worldpay.
    4. Enter same url in "Shopper redirect url"
    5. Tick on "Shopper Redirect button enabled"
    6. Tick on "Enable the Shopper Response"
    7. If you use print_r($_POST) (For php users) on url entered in "Payment Response URL" you can see all the details returned by Worldpay.
    8. After processing you can use meta refresh technique to redirect user to some other page or you can print "thank you" message to the user on same page.

    I know this thread is 1+ year old but in case if someone finds this helpful I am posting my solution here.

    Edit : "WorldPay Payment Response Guide" documentation

    Edit : Here is a screenshot of my settings that worked for me screenshot of my settings