jpk
jpk

Reputation: 510

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 ?

Upvotes: 0

Views: 225

Answers (1)

Djimmr
Djimmr

Reputation: 84

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.

Upvotes: 0

Related Questions