WordPress.org

Ready to get started?Download WordPress

Forums

404 ERROR ON WORLDPAY CALLBACK (4 posts)

  1. adrianmmorgan
    Member
    Posted 3 years ago #

    I am getting a 404 error when Worldpay is doing a callback request to one of my Shopperpress pages. The page works fine as I have tested it with a Javascript webpage using the Worldpay request, which is:

    POST /callback/?installation=239267&msgType=authResult HTTP/1.0
    Content-Type: application/x-www-form-urlencoded; charset=UTF-8
    Host: www.greenfrogdesigns.co.uk
    Content-Length: 806
    User-Agent: WJHRO/1.0 (WorldPay Java HTTP Request Object)
    
    authAmountString=%26%23163%3B289.00&_SP.charEnc=UTF-8&desc=Cart+Order...etc...etc...

    Worldpay think it might be a data encoding issue as the content type for their payment response (callback) is as follows:

    Content-Type: application/x-www-form-urlencoded

    They suggest that the server needs to recognize the data type. Tried setting up a new user-defined MIME TYPE "application/x-www-form-urlencoded" with Extension "x-www-form-urlencoded" but this didn't work - so I may have set the wrong extension.

    Research on the web, meanwhile, showed it might be due to security on the webserver, and the fix is suggested as editing .htaccess to include the lines:

    <IfModule mod_security.c>
        SecFilterInheritance Off
    </IfModule>

    So I looked at my .htaccess file and it currently reads:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress
    AddType application/x-www-form-urlencoded x-www-form-urlencoded

    The last line is interesting - I didn't put it there! Anyone got any clues as to what is the real problem and what the likely fix is? Help greatly appreciated.

    rgds
    Adrian

  2. lunaman
    Member
    Posted 3 years ago #

    Hi, sorry, I can't help, but I just wondered if you'd got to the bottom of your problem?
    I've just set up the WorldPay Payment Response on a new WordPress install and am having the same problem - a 404 message.
    I doubt it's to do with the Content-Type or security restrictions in my case as the same response detection page was previously working on the same server, on a previous non-Wordpress site. Worldpay suggested also checking charset and charEnc, but both are the same on the request and in the WordPress page.

    Thanks,

    Alun

  3. adrianmmorgan
    Member
    Posted 3 years ago #

    Here is an updata fter several weeks of frustration.

    WORLDPAY CALLBACK TO SHOPPERPRESS

    ISSUE: Worldpay callback to Shopperpress callback page was returning 404 "Page not found" errors. The callback uses the POST method.

    DIAGNOSIS: The POST data (application/x-www-form-urlencoded) sent from Worldpay to ANY WordPress page with a value field "name" where the value content is not null, throws a 404 error. This is because "name" is a reserved word in WordPress. Note: It is very misleading that WordPress returns 404.

    SOLUTION

    We have 'sort of' solved the problem by writing a very short piece of php code that takes the POST from Worldpay, renames the field "name" to a non-reserved word, and then POSTs to our 'normal' callback URL. Details are:

    Our 'normal' callback URL is http://www.greenfrogdesigns.co.uk/callback/ (http://www.greenfrogdesigns.co.uk/callback/)

    RBS WORLDPAY CALLBACK IS SET TO
    http://www.greenfrogdesigns.co.uk/worldpaycallback.php (http://www.greenfrogdesigns.co.uk/worldpaycallback.php)

    FILE worldpaycallback.php CONTAINS THIS CODE AND IS IN public_html

    # clear a variable to hold the POSTed data
    $datafields = "";
    while (list($name, $value) = each($_POST)) {
    if ( $name == "name" ) {
    $name="wpnm";
    }
    $datafields.=$name."=".$value."&";
    }
    $ch = curl_init('http://www.greenfrogdesigns.co.uk/callback/' (http://www.greenfrogdesigns.co.uk/callback/&#039;) );
    curl_setopt ($ch, CURLOPT_POST, 1);
    curl_setopt ($ch, CURLOPT_POSTFIELDS, $datafields);
    curl_exec ($ch);
    curl_close ($ch);
    ?>

    Unfortunately, when last we chacked, the Shopperpress callback page was not formatting correctly. I have found Shopperpress tech support to be responsive but not terribly helpful in resolving the issue. We are seriously considering changing the way we handle callbacks by implementing a custom page to be used by Worldpay rather than letting Shopprepress handle it.

  4. lunaman
    Member
    Posted 3 years ago #

    Thanks so much for posting your findings Adrian - I think you've saved the day!

    I really should have guessed the answer, as I spent a day just last week figuring out a 404 error in WordPress, which ended up being due to the WP reserved terms $day and $year!
    http://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms

    I haven't used Shopperpress, as this is a fairly simple site with a single booking form. Good luck with that!

Topic Closed

This topic has been closed to new replies.

About this Topic