How Do I Create Returning Page Setting with WorldPay?
Asked Answered
E

8

24

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

Eatage answered 22/11, 2011 at 19:29 Comment(1)
those guides are pathetically structured and formatted!Cutwater
F
34

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

Fecula answered 9/10, 2012 at 12:14 Comment(7)
It's thoroughly depressing that this is one of the few options that keeps the user on the same server for the thank you page; but, nonetheless, it is an option that works well.Hypallage
But what does the "Shopper Redirect button enabled" do? I imagined that it would show a button "Return to the merchant" on the standard WorldPay payment confirmation page, but no luck. I still have to "Enable the Shopper Response" which ignores the "Shopper redirect url" but extracts and displays the HTML from the "Payment Response URL" instead. How do I make the shopper be redirected to the "Shopper redirect url" ?Underpinnings
This is what the "Integration setup - page description" says (at support.worldpay.com/support/kb/bg/customisingadvanced/… ) : Shopper Redirect URL: Specific to mobile payment pages. The web address URL that shoppers are sent to when they click the Shopper Redirect button. If you enable the button, this URL must be supplied. For more information, see the Customising Mobile Guide. ...Cutwater
I've now set this as the best answer. This is because you can do a meta-refresh now in a customized response page up at WorldPay so that you can refresh to your own page on your own server. Your screenshot and extra links also made this the best answer.Eatage
I have tried your solution. it works in mobile payment, but in desktop. its showing my return page on their site itself like cached copy of my site.Falconer
Hello @Fecula I have followed all the same step. and I am using this in woocommerce but still it not redirect to my site page back it stuck at worldpay thank you page only. can you please help me.Mehetabel
I followed the steps but for some weird reasons, I'm getting this error "This data cannot be amended from the test environment. Please make any changes you wish to save in the production environment of the Merchant Admin Interface." Do you guys have any idea why I can't change the value of callback url?Add
C
16

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!!

Contrapose answered 22/11, 2011 at 22:11 Comment(4)
I called WorldPay.com (800-661-7079). They said there's no easy way to build a return into my form. I would have to have my customer revise their result pages with an editor, which is convoluted and I asked for another option. The other option is to have the form pass what's called a wpdisplay tag that lets me swap the header and have it do a meta redirect. Unfortunately he could provide no examples and said to look here: worldpay.com/support/kb/bg/paymentresponse/pr5402.htmlEatage
Don't you agree that it's convoluted to expect my customer to have to edit their result pages on the WorldPay site? I mean, we're making a shopping cart here and it's definitely not plug-and-play on the gateway to WorldPay.Eatage
Absolutely it's convoluted. I've used Worldpay, Barclays ePDQ, Sagepay/Protx and Google Checkout/Wallet, and Worldpay is the worst of the bunch. They really need to improve this as it must be hurting their business. As a developer I'd always recommend other providers before using Worldpay. And fewer integrations means less business, surely?Contrapose
But what do I know - we all trust banks to do the right thing don't we...(!)Contrapose
C
8

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

Comment answered 23/11, 2011 at 10:0 Comment(2)
One problem with this method is that as a software product company, I have to require my customer change their WorldPay settings a certain way in order to integrate with my product. The other problem is that once someone does this, it always works this way -- but what if they want to use one WorldPay account with more than one site? Basically with WorldPay, it doesn't integrate as smooth as its competition. It's convoluted.Eatage
However, you are right in that it is an alternative, and I thank you for providing the link and the time to post this response.Eatage
M
6

As of 2020 This is still very undocumented and many links are now broken :(

After doing the accepted answers by @www.amitpatil.me it still did not work for me.

I have made it work by adding this extra form field into the form post, I found this after many seeming unrelated google tabs.

<input type="hidden" name="successURL" value="https://www.example.com/thanks/">

I hope it helps someone else.

Molech answered 1/4, 2020 at 14:54 Comment(1)
Wow - this works! It needs to be voted towards the top of the page. The only problem is that the URL contains a whole slew of additional query string fields (the one I just used was 289 characters long). The additional fields I got were: orderKey, paymentStatus, paymentAmount, paymentCurrency, mac, mac2.Coppage
C
3

I'm adding to an answer from Joe below - initially I just commented on it, but now have too much to fit into the comments box.

You don't have to do any fiddling around with ResultY files any more - just specify a hidden field in your submit page with name set to successUrl, like this:

enter image description here

This can include any fields you like in the query string. After successfully submitting a payment, you get taken back to this URL. A couple of caveats:

  1. WorldPay won't take you back to a different URL. So if (like me) you're developing a site on your local computer, you'll have to publish your changes to your live site to test this.
  2. You get lots of other arguments in the query string - some useful (the payment amount and response), some less so (a couple of very long arguments called mac and mac2, whose meaning I know not).

I think you may be able to pass failureURL and cancelURL too, but I couldn't get these too work.

Coppage answered 25/4, 2020 at 14:44 Comment(1)
This still works as of 2023, though it's not documented anywhere that I can find (I figured it out by trial and error before coming across this answer). You can add your order ID to the success URL if you want a very basic way of knowing whether the order has been paid.Eyra
F
1

I think worldpay eventually allow Shopper Response redirect back to your site, through Meta refresh .

All you have to do is to generate the Html response from your server-side callback.

Fant answered 8/12, 2015 at 10:0 Comment(0)
E
0

@Chris really answered this question, but here's what I ended up doing. I did indeed use the MC_success parameter, but set it like so:

<input type="hidden" name="MC_success" value="Click here to return to the merchant: <?= $this->RETURNING_PAGE_ON_MY_SITE ?>">

Then, this requires the merchant to edit their resultY.html page on WorldPay and insert this parameter somewhere in the body section of it:

<div><strong><WPDISPLAY ITEM=success></strong></div>

This will then display something like the following in their successful payment response page hosted on WorldPay:

Click here to return to the merchant: http://example.com/my-success-return-link-here

Now, not every customer is going to know how to do this. Therefore, in my payment gateway that I was building, I made it email the admin that someone paid by WorldPay and that they should manually send the photos to the customer via the Admin interface of our product.

Additionally, one must post this to the proper action URL, which I corrected in my original post in the EDIT section above.

Last but not least, note that we cannot do an automatic redirection. In fact, WorldPay has a policy strictly prohibiting it, which is in red on this page:

http://www.worldpay.com/support/kb/bg/paymentresponse/pr5402.html

"Warning: Automatic redirection using the shopper response feature is prohibited and will result in a failure being logged and a possible suspension of the feature."

Eatage answered 22/11, 2011 at 23:39 Comment(2)
This is no longer the case - WorldPay have removed the policy prohibiting automatic redirection and now include a message saying you can include it... but it doesn't work well. WorldPay continue to be convoluted and costly (time) to work with in most cases. Avoid if you can is my advice.Contrapose
Except if you can't avoid it because it's from work. And you end up screaming to a screen because all documentation is self-contradictory.Linolinocut
D
-1

Worldpay return URL

it is very simple.

login to Worldpay, open desired installation to edit.

Tick on "Payment Response enabled?"

Provide "Payment Response URL" like http://yourdomain.com/responce.php

Enter same url in "Shopper redirect url" http://yourdomain.com/responce.php

Tick on "Shopper Redirect button enabled"

And put responce.php in root directory

create test.txt file in root

file_get_contents('test.txt',$_Post);

you can get post data array to test.txt

Deicide answered 4/6, 2014 at 7:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.