0
votes

Im trying to integrate sagepay with my shopping cart. After I post my basket to the sage pay server, it doesn't seem to accept my RedirectURL. It seems that I am able to authenticate ok; but when I'm trying to send back my RedirectURL, I keep getting the following in the browser:

Error Code :    5006
Error Description :     Unable to redirect to Vendor's web site. The Vendor failed to provide a RedirectionURL.

Here is my post from my shopping cart to sagepay to initiate the payment.

\sagepay request[ VPSProtocol ]               => 3.00
\sagepay request[ TxType ]                    => PAYMENT
\sagepay request[ Vendor ]                    => myVendorName
\sagepay request[ VendorTxCode ]              => 49
\sagepay request[ Amount ]                    => 9,215.00
\sagepay request[ Currency ]                  => GBP
\sagepay request[ Description ]               => Our shopping cart
\sagepay request[ NotificationURL ]           => http://www.example.com/path/to/notification-url/index.php
\sagepay request[ CustomerEMail ]             => [email protected]
\sagepay request[ BillingFirstnames ]         => Daithi
\sagepay request[ BillingSurname ]            => Coombes
\sagepay request[ BillingAddress1 ]           => Somewhere
\sagepay request[ BillingAddress2 ]           => That place
\sagepay request[ BillingCity ]               => Sheffield
\sagepay request[ BillingPostCode ]           => xxxx
\sagepay request[ BillingCountry ]            => GB
\sagepay request[ BillingState ]              => 
\sagepay request[ BillingPhone ]              => 0000
\sagepay request[ DeliveryFirstnames ]        => Daithi
\sagepay request[ DeliverySurname ]           => Coombes
\sagepay request[ DeliveryAddress1 ]          => Somewhere
\sagepay request[ DeliveryAddress2 ]          => That place
\sagepay request[ DeliveryCity ]              => Sheffield
\sagepay request[ DeliveryPostCode ]          => xxxx
\sagepay request[ DeliveryCountry ]           => GB
\sagepay request[ DeliveryState ]             => 
\sagepay request[ DeliveryPhone ]             => 0000

Here is the response to my notificationURL from sagepay (notice VendorTxCode is same as above, this is the actual response):

\sagepay response[ VPSProtocol ]              => 3.00
\sagepay response[ TxType ]                   => PAYMENT
\sagepay response[ VendorTxCode ]             => 49
\sagepay response[ VPSTxId ]                  => {376BBFA1-5895-AB53-37CD-D932BE1F9019}
\sagepay response[ Status ]                   => OK
\sagepay response[ StatusDetail ]             => 0000 : The Authorisation was Successful.
\sagepay response[ TxAuthNo ]                 => 7605576
\sagepay response[ AVSCV2 ]                   => SECURITY CODE MATCH ONLY
\sagepay response[ AddressResult ]            => NOTMATCHED
\sagepay response[ PostCodeResult ]           => NOTMATCHED
\sagepay response[ CV2Result ]                => MATCHED
\sagepay response[ GiftAid ]                  => 0
\sagepay response[ 3DSecureStatus ]           => NOTCHECKED
\sagepay response[ CardType ]                 => VISA
\sagepay response[ Last4Digits ]              => 0006
\sagepay response[ VPSSignature ]             => 02251363205725C79A58DD175E6F96DC
\sagepay response[ DeclineCode ]              => 00
\sagepay response[ ExpiryDate ]               => 0519
\sagepay response[ BankAuthCode ]             => 999777

But when my NotificationURL echo's the following: \sagepay request[ Status ] => OK \sagepay request[ RedirectURL ] => http://www.example.com/path/to/redirection-url/redirect.php

the user's screen shows the error above (code: 5006 description: Unable to redirect to Vendor's web site. The Vendor failed to provide a RedirectionURL.) After a few attempts from sagepay to my notificationURL, it then sends the following:

\sagepay response[ VPSProtocol ]    => 3.00
\sagepay response[ TxType ]         => PAYMENT
\sagepay response[ VendorTxCode ]   => 49
\sagepay response[ VPSTxId ]        => {63D68B7D-5503-7695-B208-01FE14C668B4}
\sagepay response[ Status ]         => ABORT
\sagepay response[ StatusDetail ]   => 2008 : The Transaction timed-out.
\sagepay response[ AVSCV2 ]         => DATA NOT CHECKED
\sagepay response[ AddressResult ]  => NOTPROVIDED
\sagepay response[ PostCodeResult ] => NOTPROVIDED
\sagepay response[ CV2Result ]      => NOTPROVIDED
\sagepay response[ GiftAid ]        => 0
\sagepay response[ 3DSecureStatus ] => NOTCHECKED
\sagepay response[ VPSSignature ]   => 683B1004A0A6385D48C6D7D797C3FBC8

Im going around in circles with the documentation and I am lost as what to do. Any help is appreciated.

2

2 Answers

0
votes

I have solved it. My response in my notificationURL was not encoded correctly, I was using http_build_query() to output the response. The documentation specifically states:

This is the plain text response part of the POST originated by the Server in the step above. Encoding must be as Name=Value fields separated by carriage-return-linefeeds (CRLF).

So my notificationURL now prints something like:

<?php
echo "Status={$_REQUEST['Status']}
RedirectURL=http://www.example.com/path/to/RedirectURL/redirect.php";
die();
0
votes

Success url:

 $request['SuccessURL']=>'http://www.example.com/path/to/notification-url/index.php';