sageapy中需要RelatedSecurityKey

时间:2014-10-31 10:31:40

标签: php payment sagepay

我已经计算了事务,然后sagepay服务器返回以下值的响应。

    [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

我将上述参数传递给" REFUND TRANSACTION ",当我点击" 退款"按钮sagepay服务器抛出错误。

错误:

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

实际代码:

 <?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>";
    ?>

如何传递&#34; RelatedSecurityKey&#34;?有人可以帮助我,如何修复它?....

1 个答案:

答案 0 :(得分:0)

根据this Sagepay API documentation中记录的请求对象,您需要传递一个名为“RelatedSecurityKey”的字段。

当您第一次注册交易时,您将获得此值作为Sagepay响应的一部分(同时您获得重定向/ iframe的“NextUrl”) - 此时它被称为“ SecurityKey“ - 您应该将此值存储在数据库中以便以后重用。