I was wondering whether anybody could help me please?

I have a small ecommerce site, which uses WorldPay for its payment method.

When a user click 'proceed to payment' on the checkout page, it submits the form calling itself.

This validates the delivery address, etc and if there is an error the checkout page is shown again highlighting the errors. This all works fine.

If the order is valid it processes the order and then builds and sends an XML file to WorldPay. WorldPay send an URL back which is stored in a variable. I log the contents of the variable (the returned URL) and then use response.redirect to direct the user to the WorldPay URL. It usually takes around 10 seconds from the point the user clicks the button to the WorldPay page loading.

95% of the time it redirects to the worldpay page without any problems. However I've had a lot of reports that for certain people it just stays on the checkout page and doesn't redirect. (the 'Proceed to Payment' button is disabled with js after its first clicked). Checking the logs I can see that the URL they're being forwarded to looks ok. Also it seems like for some people it fails on the first attempt, they manually refresh the page and it then succeeds on the second attempt or sometimes the 3rd, 4th or even 5th attempt. This is concurs with the reports that I've had, some of which have contacted us to report the issue, others I've contacted after I've noticed them having a problem in the logs.

There is no other coding between the log being taken (which works) and the redirect (which sometimes work). Directly after this I perform another log which is never hit (which is right as it should of redirected). There is error checking around the whole process and an error is never thrown.

I'm completely stumped by this and its causing us to lost 5-10% of our trade, so any help would be greatly apprecriated.