'Sagepay Error The Vendor failed to provide a RedirectionURL
Integrating the Sagepay payment in PHP.
I am getting logs in notification URL and getting response data including transaction details.
From there passing the response like below without any additional HTML header or tags.
$strResponse = 'Status=INVALID'."\r\n";
$strResponse .= 'RedirectURL='https://website.com/return/'."\r\n";
$strResponse .= 'StatusDetail=Transaction ABORTED successfully'."\r\n";
But still showing a message like below in sagepay url
Server error 5006: Unable to redirect to Vendor's web site. The Vendor failed to provide a RedirectionURL.
Any idea whats wrong ?
Solution 1:[1]
Be really careful mixing double and single quotes. Try replacing your example code with:
$strResponse = 'Status=INVALID'.PHP_EOL;
$strResponse .= 'RedirectURL=https://website.com/return/'.PHP_EOL;
$strResponse .= 'StatusDetail=Transaction ABORTED successfully'.PHP_EOL;
Note that, in your version the redirect URL has a single quote after the equals and before the https - that will be causing a parse error.
PHP_EOL is a constant defined as the correct end of line symbol for the system PHP is running on. I use it my Opayo/SagePay integration without issue, however YMMV depending on what platform you use. Primarily, I use it because it makes my code cleaner and eliminates the possibility of typos when adding \r\n.
Be aware that any response that does not match the format defined by Opayo/SagePay will cause that 5006 error - this includes any error messages your script outputs. Opayo/SagePay give you zero help bugfixing so my advice would to catch and log errors some other way than echoing out, at least so you have a starting point to work from.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | DharmanBot |