2
votes

I have been trying to implement sage pay's form integration. Every time i submit a form i keep getting error code:5080 (Error description: transaction registration failed). I tried searching for error code in sagepays website (https://www.sagepay.co.uk/support/error-codes) but apparently this error code doesn't exist. If i type in the error description in sagepay's error code page, rather than the error code then i get the following result screenshot

However both my success url and failure url are present.

What is going on here?

Edit:

 VendorTxCode=16-07-20-12-43-55-145161808&ReferrerID=&Amount=3,500.00&Currency=GBP&Description=Clarice Cliff SUNRAY LOTUS JUG C.1930&SuccessURL=http://test.co.uk/baskets/sagepay_success&FailureURL=http://test.co.uk/baskets/sagepay_failure&CustomerName=&CustomerEMail=&VendorEMail=&SendEMail=&eMailMessage=&BillingSurname=Tester&BillingFirstnames=Tester&BillingAddress1=Test Street&BillingAddress2=&BillingCity=London&BillingPostCode=TE14 1EE&BillingCountry=UNITED KINGDOM&BillingState=&BillingPhone=&DeliverySurname=Tester&DeliveryFirstnames=Tester&DeliveryAddress1=Test Street&DeliveryAddress2=&DeliveryCity=London&DeliveryPostCode=TE14 1EE&DeliveryCountry=UNITED KINGDOM&DeliveryState=&DeliveryPhone=&Basket=&AllowGiftAid=&ApplyAVSCV2=&Apply3DSecure=&BillingAgreement=&BasketXML=&CustomerXML=&SurchargeXML=&VendorData=&ReferrerID=&Language=&Website=
9
5080 is the new generic error message which covers all potential failures (I know, it's a pain). If you can supply me the raw, unencrypted Crypt string, I should be able to troubleshoot it for you....Rik Blacow
@RikBlacow Hi have added the unencrypted crypt string above! ThanksS.Simkhada
Just for other people with this error, I found I got this because my VendorTxCode was not unique per order. I was using an auto-incremented field in my orders table for the VendorTxCode, I'd made a load of test transactions, then deleted the test orders before going live, then when live I started getting this error. It turned out to be because it was using VendorTxCode values from the id field that I'd used during testing. This was a pain to debug as the error just started occurring even though no code had changed.AndyGaskell

9 Answers

3
votes

It was your BillingCountry and DeliveryCountry fields - you should use ISO 2 character values. You had 'UNITED KINGDOM' in there - should be 'GB'.

3
votes

I have finally figured it out. I was sending the crypt field across but not the other data like txt type.

It was me being silly, although it would have been nice to get a error from Sagepay which actually was relevant to the issue rather than something so general you start looking in irrelevant places to solve the issue.

2
votes

Login to your Sagepay account & go to the invalid transactions, click a transaction & you will see the exact error that is causing the 5080 error.

0
votes

Sample PHP code:

function addPKCS5Padding($input)
{
     $blockSize = 16;
     $padd = "";
     $length = $blockSize - (strlen($input) % $blockSize);
     for ($i = 1; $i <= $length; $i++)
{
     $padd .= chr($length);
}
     return $input . $padd;
}

function removePKCS5Padding($input)
{
    $blockSize = 16;
    $padChar = ord($input[strlen($input) - 1]);
    $unpadded = substr($input, 0, (-1) * $padChar);
    return $unpadded;
}


function encryptAes($string, $key)
{
    $string = addPKCS5Padding($string);
    $crypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $string, MCRYPT_MODE_CBC, $key);
    return  strtoupper(bin2hex($crypt));
}


function decryptAes($strIn, $myEncryptionPassword)
{

#Sagepay specific - remove the '@'
$strIn = substr($strIn,1);

    $strInitVector = $myEncryptionPassword;
    $strIn = pack('H*', $hex);
    $string = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $myEncryptionPassword, $strIn, MCRYPT_MODE_CBC,$strInitVector);
    return removePKCS5Padding($string);
}
0
votes

Check your encryption key!

I had exactly the same issue this morning. I have been using the test Sage Pay gateway for development but wanted to check that my crypt string worked on the live gateway. An error 5080 was reported. I realised that I was using my test encryption key instead of the live key!

0
votes

I had this exact problem and thought I would add my problem/solution to this. I had this error in test and found that the DNS entry for our test site had been removed. I got this error because SagePay could not get to the return URL I gave it.

Once I put the DNS entry back, SagePay could get to the site and the error went away.

0
votes

I had the same problem and the reason was I had accidentally left out one of the address fields that I was sure was included.

Check what you are posting to Sage, via var_dump($_POST)

Failing that, speak to SagePay customer support on 0845 111 4466 (I think it costs to call that number) and tell them the problem. They may ask you to post your form to https://test.sagepay.com/showpost/showpost.asp, and they can watch on their end to see what data you're POSTing and verify if something is missing on their end.

0
votes

I had this very same issue. Turns out one of my variables was blank due to a database retrieval error - so check you're actually filling in every field by stepping through your form generation code (I dynamically built mine in the server side script, so was easy enough to identify).

In my case, the "billingaddress" was actually feeding a string value of "", which errored when it was posted to SagePay.

0
votes

On Woocomerce go to setting for Sagepay - make sure "select shipping address" is put to billing address instead of auto - simple fix.