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.)
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.
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.
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:
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
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:
I hope this has been of some help, if you have any questions just add a comment. Good luck!!
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With