Worldpay 302 Error

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 年 前
There has been quite a lot of discussion on the forums over the past couple of years concerning issues with Worldpay payment response, and there doesn't really seem to have been much resolution to these issues. With Worldpay being a pretty popular payment method, surely some people have got this working properly?

Anyway, firstly the version of NOP being used is 2.20 and the issue I am having is that upon successful payment, instead of being redirected back to the website, I am being shown the standard Worldpay payment response page. The error message I am receiving in the response.txt file within the Callback Failure Alert email is as follows:


HTTP/1.1 302 Found
Connection: close
Date: Fri, 01 Mar 2013 08:29:49 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
X-AspNetMvc-Version: 3.0
Location: /checkout/completed
Set-Cookie: Nop.customer=530cc48c-70a4-497f-ab00-4e79c1da3822; expires=Sat, 01-Mar-2014 08:29:49 GMT; path=/
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 136

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/checkout/completed">here</a>.</h2>
</body></html>


The reason I need this to work is that we have eCommerce tracking enabled on the Completed page of the site.
I have trawled through the code and can't see any obvious reason as to what the issue is. If anyone can help me with this it would be appreciated.

Graham
11 年 前
Has anyone come across this before?
11 年 前
For anyone else who has this problem (it does not seem to be resolved from the threads I found, some of which are quite old), after going round in circles I found the solution here:

http://www.kartris.com/Knowledgebase.aspx?kb=48

It's a web forms .net cart, but the issue described is identical and their fix works.
11 年 前
Thank you so much for this information. Can I ask a question though, you said you managed to fix the issue with this resolution, however what did you specify in the location tag or did you omit this? For example:

  <location path="WHAT GOES HERE!!">
    <system.web>
      <pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode="Always" />
      <httpRuntime requestValidationMode="2.0" />
    </system.web>
  </location>


In the code snippet above, what should be put in the location path?
11 年 前
Okay, lets do a bit of knowledge sharing and see if we can't get this resolved. Everything below is in relation to nop2.65.

Based on the errors we've been seeing from Worldpay, this is what I've just tried in the <location path> field:

<location path="Plugins/PaymentWorldPay/Return">
  <system.web>
  <pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode="Always" />
  <httpRuntime requestValidationMode="2.0" />
  </system.web>
</location>


I'm not entirely sure its working properly. We are still getting a callback failure error from Worldpay, however with the above code in the web.config file WP only sent us a request.txt file, there was no response.txt.

I should point out , we are getting successful transactions, its just WP that doesn't like Nop's behavior once its sent the details to Nop. I'd have thought Nop would save the transaction id that WP generates, but it doesn't. The Paypal payment plugin for example saves the payment details to an order note.

One other thing we have changed in WP is a custom resultY.html file, which handles the redirect back to the site using a meta http-equiv="refresh" tag. This is due to some of the comments on this other forum post here referencing the WP shopper response option.

This is the contents of our resultY.html file

<html>
<head>
<title>Company - thank you for your payment</title>
<meta http-equiv="refresh" content="2;url=https://domain/checkout/completed/" />
</head>
<WPDISPLAY FILE=header.html>
<h2>company name</h2>
<p><WPDISPLAY ITEM=name>, thank you for your payment of &nbsp;<WPDISPLAY
ITEM=amountString> for <WPDISPLAY ITEM=desc>.</p>

<p>Redirecting...</p>
<WPDISPLAY ITEM=banner>
<WPDISPLAY FILE=footer.html>
</html>


For clarity and comparison, here is a screengrab of the live Worldpay config options:
http://www.visitframe.co.uk/userfiles/images/useful/worldpay-config.jpg

These options work for us in that we can get a successful round-trip transaction with the user returning to the website, but we still get the callback errors from Worldpay. The <location path> option in the web.config file didn't do much for us.
11 年 前
Thanks for all of the information. The issue I have and the reason I can't use the custom resultY.htm file is that I have ecommerce tracking code setup on the checkout completed page, and if I simply redirect back using the htm file then no order id is passed and the ecommerce tracking errors.

I wasn't sure what the location path should be set to however I did set it to:

<location path="Plugins/PaymentWorldPay/Return">

but this didn't seem to do much, and can't really see if it has done much. The version of nop the site is running on is 2.20 so not sure if the web.config change applies to this version of nop. If bpyr can tell me if there is anything missing or if the location is set incorrectly that would be great as he/she mentions they got it working successfully.
11 年 前
I am also using worldpay and the page redirects to website after payment through meta refresh but there are two issues

1. Payment status is pending in Nop
2. User is asked to log in again after payment to see the thank you page (/checkout/completed)

Any suggestion please?
10 年 前
I too have the problem of the payment being set to pending when i know the payment went through...anyone get to the bottom of this?
10 年 前
Any luck with resolving the issue? I have the very same problem in NOP3.10 &WP Plugin 1.03.
10 年 前
OK. It seems I managed to resolve it. I had to change the plugin's controller: PaymentWorldPayController.cs


//public ActionResult Return(FormCollection form)
public string Return(FormCollection form)
        {
            var processor = _paymentService.LoadPaymentMethodBySystemName("Payments.WorldPay") as WorldPayPaymentProcessor;
            if (processor == null || !processor.IsPaymentMethodActive(_paymentSettings) || !processor.PluginDescriptor.Installed)
                throw new NopException("WorldPay module cannot be loaded");

            string transStatus = CommonHelper.EnsureNotNull(form["transStatus"]);
            string returnedcallbackPw = CommonHelper.EnsureNotNull(form["callbackPW"]);
            string orderId = CommonHelper.EnsureNotNull(form["cartId"]);
            string returnedInstanceId = CommonHelper.EnsureNotNull(form["instId"]);
            string callbackPassword = _worldPayPaymentSettings.CallbackPassword;
            string transId = CommonHelper.EnsureNotNull(form["transId"]);
            string transResult = _webHelper.QueryString<string>("msg");
            string instanceId = _worldPayPaymentSettings.InstanceId;

            var order = _orderService.GetOrderById(Convert.ToInt32(orderId));
            if (order == null)
                throw new NopException(string.Format("The order ID {0} doesn't exists", orderId));

            if (string.IsNullOrEmpty(instanceId))
                throw new NopException("Worldpay Instance ID is not set");

            if (string.IsNullOrEmpty(returnedInstanceId))
                throw new NopException("Returned Worldpay Instance ID is not set");
            
            if (instanceId.Trim() != returnedInstanceId.Trim())
                throw new NopException(string.Format("The Instance ID ({0}) received for order {1} does not match the WorldPay Instance ID stored in the database ({2})",returnedInstanceId, orderId, instanceId));

            if (returnedcallbackPw.Trim() != callbackPassword.Trim())
                throw new NopException(string.Format("The callback password ({0}) received within the Worldpay Callback for the order {1} does not match that stored in your database.",returnedcallbackPw, orderId));

            /*if (transStatus.ToLower() != "y")
                return  Content(string.Format("The transaction status received from WorldPay ({0}) for the order {1} was declined.", transStatus, orderId));
            */


            if (_orderProcessingService.CanMarkOrderAsPaid(order))
            {
                _orderProcessingService.MarkOrderAsPaid(order);
            }

            //return RedirectToRoute("CheckoutCompleted", new { orderId = order.Id });
            string html = "<html><head><meta http-equiv=\"refresh\" content=\"0; url=" + _webHelper.GetStoreLocation(false) + "/checkout/completed/" + order.Id + "\"><title>Some title here</title></head><body><h2><WPDISPLAY ITEM=banner></h2><br /><h2>Object moved to <a href=\"" + _webHelper.GetStoreLocation(false) + "/checkout/completed/" + order.Id + "\">here</a>.</h2></body></html>";
            return html;
        }



On the WorldPay Installation Administration site set the following fields to:
Payment Response URL - <wpdisplay item=MC_callback>
Payment Response enabled? - ticked
Enable the Shopper Response - ticked

Enjoy :)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.