The RelatedSecurityKey is required in sageapy

2019-03-06 14:32发布

问题:

I have complected transactions then the sagepay server return the response of following values.

    [VendorTxCode] => 14-10-31-10-49-36-196489754
    [VPSTxId] => {AADB57CA-B7BF-1A70-682F-60303C2AF7E2}
    [Status] => OK
    [StatusDetail] => 0000 : The Authorisation was Successful.
    [TxAuthNo] => 145552
    [AVSCV2] => SECURITY CODE MATCH ONLY
    [AddressResult] => NOTMATCHED
    [PostCodeResult] => NOTMATCHED
    [CV2Result] => MATCHED
    [GiftAid] => 0
    [3DSecureStatus] => OK
    [CAVV] => AAABARR5kwAAAAAAAAAAAAAAAAA=
    [CardType] => VISA
    [Last4Digits] => 0006
    [DeclineCode] => 00
    [Amount] => 10.00
    [BankAuthCode] => 999777

I pass the above parameters are input to the "REFUND TRANSACTION",When I click the "REFUND"button the sagepay server throw an error.

ERROR:

VPSProtocol=3.00
Status=INVALID
StatusDetail=3033 : The RelatedSecurityKey is required.
VPSTxId={B67E6F2C-1E84-4C36-1E49-0AF89DD8B200}

Actual Code:

 <?php
$responseArray = decode($_REQUEST['crypt']); //call to the decode method it return the human readable format
$relatedVendorTxCode = $responseArray['VendorTxCode'];
$amout = $responseArray['Amount'];
$relatedVPSTxId = $responseArray['VPSTxId'];
$relatedTxAuthNo = $responseArray['TxAuthNo'];
$vendorTxCode = 'REF'.$responseArray['VendorTxCode'];
echo "  
    <form method='POST' id='SagePayForm' action='https://test.sagepay.com/gateway/service/refund.vsp'>
        <input type='hidden' name='VPSProtocol' value= '3.00'>
        <input type='hidden' name='TxType' value= 'REFUND'>
        <input type='hidden' name='Vendor' value= 'protxross'>
        <input type='hidden' name='Currency' value= 'GBP'>
        <input type='hidden' name='Description' value= 'Description'>
        <input type='hidden' name='RelatedVendorTxCode' value= '{$relatedVendorTxCode}'>
        <input type='hidden' name='RelatedVPSTxId' value= '{$relatedVPSTxId}'>
        <input type='hidden' name='Amount' value= '{$amout}'>
        <input type='hidden' name='VendorTxCode' value= '{$vendorTxCode}'>          
        <input type='submit' value='REFUND'>
        </form>";
    ?>

How to pass the "RelatedSecurityKey"?Some one can help me,How to fix it?....

回答1:

Based on the request object documented in this Sagepay API documentation, you need to pass a field named "RelatedSecurityKey".

You would have been given the value for this as part of the Sagepay response when you first registered the transaction (at the same point you get the "NextUrl" for your redirect/iframe) - at which point it is just called "SecurityKey" - you should store this value in the database for reuse later.