在SagePay API中处理退款

时间:2014-01-03 09:39:54

标签: php api curl sagepay

我正在尝试测试退款处理,所有参数似乎都是正确的,但我收到此错误

VPSProtocol=2.23 Status=ERROR StatusDetail=3046 : The VPSTxId field is missing. VPSTxId={8642C32C-8743-93A5-8C3C-3C5D24E2E845}

根据他们的文档,退款没有字段VPSTxId

以下是我尝试过的代码:

$url = 'https://test.sagepay.com/gateway/service/refund.vsp';
$params = array();
$params['VPSProtocol'] = '2.23';
$params['TxType'] = 'REFUND';
$params['Vendor'] = 'VENDORNAME';
$params['VendorTxCode'] = 'Txn-abc123';            //Sample value given by me
$params['Amount'] = '3.00';
$params['Currency'] = 'GBP';
$params['Description'] = 'Testing Refunds';
$params['RelatedVPSTxId'] = 'ADE97B30-93DB-96EA-1D5F-FE1D5BJY456E2A';     //VPSTxId of main transaction
$params['RelatedVendorTxCode'] = 'VENDOR-131210115229-184';         //VendorTxCode of main transaction
$params['RelatedSecurityKey'] = 'JQFXUICCKO';       //securitykey of main transaction
$params['RelatedTxAuthNo'] = '81068219';            //vpsauthcode of main transaction

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,urlencode(http_build_query($params)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, $curlTimeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
echo $response;

我错过了什么?任何帮助。

由于

3 个答案:

答案 0 :(得分:0)

3046错误意味着: 如果您未在VPSTxId字段中向我们提供正确的值,您将收到此系统消息。 VPSTxId值唯一标识Sage Pay系统的事务,如果此值尚未完整提交或者格式化不正确,则当Sage Pay系统尝试验证时,将向您提供此错误消息。

关于示例 - 正在提交所有必需信息。

为Refund和RelatedVPSTxId提供实际的VPSTxID,Sage Pay可以在72小时内为您检查日志。

答案 1 :(得分:0)

我改变了我的代码并且它有效:)

$url = 'https://test.sagepay.com/gateway/service/refund.vsp';
$params = array();
$params['VPSProtocol'] = urlencode('2.23');
$params['TxType'] = urlencode('REFUND');
$params['Vendor'] = urlencode('VENDORNAME');
$params['VendorTxCode'] = urlencode('Txn-abc123');            //Sample value given by me
$params['Amount'] = urlencode('3.00');
$params['Currency'] = urlencode('GBP');
$params['Description'] = urlencode('Testing Refunds');
$params['RelatedVPSTxId'] = urlencode('ADE97B30-93DB-96EA-1D5F-FE1D5BJY456E2A');     //VPSTxId of main transaction
$params['RelatedVendorTxCode'] = urlencode('VENDOR-131210115229-184');         //VendorTxCode of main transaction
$params['RelatedSecurityKey'] = urlencode('JQFXUICCKO');       //securitykey of main transaction
$params['RelatedTxAuthNo'] = urlencode('81068219');            //vpsa

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);  
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, $curlTimeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);

var_dump( $response );

答案 2 :(得分:-2)

strConnectTo<>"SIMULATOR" then
                                                                Session("Redirected")=true
                                                                response.Clear()
                                                                'response.redirect(strNextURL)
                                                                response.write "<iframe src=" & strNextURL & " width=500 height=600 align=center></frame>"
                                                                response.End()
                                                                                                                                                                                                                                                                end if