1

We have just moved to Stackpath and now our payments are failing. I can see the requests hitting the server:

[08/Aug/2019:09:27:41 +0000] "POST/worldpay/processing/response...

I have enabled the debug logs and can see the error message below:

Worldpay response error: Domain can't be validated as WorldPay-Domain.
2

I think this will be because magento is failing to determine the "remote address"
app/code/community/Phoenix/Worldpay/controllers/ProcessingController.php:165

// validate request ip coming from WorldPay/RBS subnet
        $helper = Mage::helper('core/http');
        if (method_exists($helper, 'getRemoteAddr')) {
            $remoteAddr = $helper->getRemoteAddr();
        } else {
            $request = $this->getRequest()->getServer();
            $remoteAddr = $request['REMOTE_ADDR'];
        }
        if (!preg_match('/\.worldpay\.com$/', gethostbyaddr($remoteAddr))) {
            Mage::throwException('Domain can\'t be validated as WorldPay-Domain.');
        }

This can be fixed by adding the stackpath "REAL ID" header into your config.
If you edit the file app/etc/local.xml and add:

<remote_addr_headers>
    <header1>HTTP_X_SP_FORWARDED_IP</header1>
</remote_addr_headers>

Inside config->global Then refresh your cache "remote address" should now be correct.

You can test this by placing the file test-remote-address.php

define('MAGENTO_ROOT', getcwd());
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require MAGENTO_ROOT . '/app/bootstrap.php';
require_once $mageFilename;

Mage::app('admin');
print_r($_SERVER);
echo 'address: '.Mage::helper('core/http')->getRemoteAddr();

In your web root then requesting it with your browser. You will notice that after updating app/etc/local.xml it will be correct.
Be sure to remove this file once you are happy

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.