Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.)

like image 376
Volomike Avatar asked Nov 22 '11 19:11

Volomike


People also ask

Can I link worldpay to my website?

Integration is very straightforward. Once you successfully send us details of an order and get an email response from us, you have integrated your website.

How do I integrate with Worldpay?

Once you've logged in to Business Manager select Setup from the left hand options menu. Business Manager is the portal which enables your website integration with Worldpay. Before carrying out the next steps you need to log on to Business Manager, to access important information on how to integrate your website.


3 Answers

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

like image 134
www.amitpatil.me Avatar answered Oct 26 '22 22:10

www.amitpatil.me


Can totally sympathise, this was a bit of a nightmare to setup for me too. I've not used the MC_success parameter before, but as far as I know you can't do a straight redirect, it has to display a Worldpay page after payment, but you can customise this page.

Once the payment is successful (or not), Worldpay shows an HTML page to the user. These HTML pages are stored in your Worldpay control panel, and if you want to customise them you have to upload a new file here. The files shown on transaction success and failure are resultY.html and resultC.html respectively.

You need to have a look at the Advanced Customising Guide, and search for resultY.html in the top right of that guide, this will give you some help.

In these files, Worldpay automatically substitues certain tags like <wpdisplay item=cartId> and <wpdisplay item=banner default=""> for actual data. I would login to your Worldpay control panel and download the files it currently uses, then customise from there.

In an installation I have I just include a line in my resultY.html page like the following...

<p><a href="http://example.com/worldpay/cartid/<wpdisplay item=cartId>">Redirect back to my shop</a></p> 

...which will take the user back to my site with their cartId in the URL, from which I pull their order details and show a success page of my own. But you can create your own tags by sending along extra post fields in your sample form above. The names of the variables must be prefixed MC_, but you can then include them in your resultY.html file. Ie.

<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_myText" value="This is my custom text">      <input type="submit" value="Click here for the secure payment form"> </form> 

And in your resultY.html file just include the tag <WPDISPLAY ITEM=MC_myText>. You need to be conscious that all your form fields are visible to a user if they view the source of your payment pages, hence putting a valid MC_downloadLink to some valuable download is a bad idea.

Check out these pages, they're the most useful ones in the customising guide:

  • Structure of the Result Pages
  • Dynamic Information Parameters
  • Custom Parameters

I hope this has been of some help, if you have any questions just add a comment. Good luck!!

like image 28
Chris Avatar answered Oct 27 '22 00:10

Chris


Editing resultY.html is not strictly necessary, you can skip using the Payment Page Editor by using the 'Payment Response' feature.

In the installation settings provide a URL for a script on your server and WorldPay will POST the following parameters to it once a payment has been authorised (or the shopper clicks Cancel on the payment page): http://www.worldpay.com/support/kb/bg/paymentresponse/pr5201.html

If you also enable the setting "Enable the shopper response" WorldPay will download any HTML the script you specified outputs and use this as the result page (hosted on their own server). (If you want any images hosted securely they'll need to be uploaded in the Payment Page Editor)

This allows you to build a dynamic results page without needing to use resultY.html (OSCommerce and may other shopping carts use this method to customise the results page)

I believe there is no problem with using a META refresh on your results page provided it is not in anyway misleading (you need to give the shopper the outcome of the payment and not immediately send them to your home page for example).

like image 25
TehInvisibleHand Avatar answered Oct 26 '22 22:10

TehInvisibleHand