我正在开发一个电子商务网站,我必须整合Sage Pay支付网关。除了在尝试结账时收到以下错误,一切正常。
这是我的代码:
<?php
$serverLive="https://test.sagepay.com/gateway/service/vspform-register.vsp";
$YOUR_VENDOR_LOGIN_NAME = "alpinetravelint";
$PAYMENT_CRYPT="VendorTxCode=406227821909&Amount=320.00&Currency=GBP&Description=1ACMEWidget&SuccessURL=http://salentro.com/core/snowtrax/index.php&FailureURL=http://salentro.com/core/snowtrax/login.php&BillingSurname=Smith&BillingFirstnames=John&BillingAddress1=123 Main Street&BillingCity=Anywhere&BillingPostCode=W1A 1BL&BillingCountry=GB&DeliverySurname=Smith&DeliveryFirstnames=test&DeliverAddress1=123Main Street&DeliveryCity=Anywhere&DeliveryPostCode=W1A 1BL&DeliveryCountry=GB";
function pkcs5_pad($text, $blocksize)
{
$pad = $blocksize - (strlen($text) % $blocksize);
return $text . str_repeat(chr($pad), $pad);
}
function encryptFieldData($input)
{
$key = "4bBtA2UYvZKry3tb";
$iv = $key;
$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, "", MCRYPT_MODE_CBC, "");
if (mcrypt_generic_init($cipher, $key, $iv) != -1)
{
$cipherText = mcrypt_generic($cipher,$input );
mcrypt_generic_deinit($cipher);
$enc = bin2hex($cipherText);
}
return $enc;
}
$str = $PAYMENT_CRYPT;
$datapadded = pkcs5_pad($str,16);
$cryptpadded = "@" . encryptFieldData($datapadded);
?>
<form action="<?php echo $serverLive ;?>" method="POST" id="SagePayForm" name="SagePayForm">
<input type="hidden" name="VPSProtocol" value="2.23" />
<input type="hidden" name="TxType" value="PAYMENT" />
<input type="hidden" name="Vendor" value="<?php echo $YOUR_VENDOR_LOGIN_NAME ?>" />
<input type="hidden" name="Crypt" value="<?php echo $cryptpadded ?>">
<input type="image" src="images/buynow-sagepay.png" />
</form>
现在,问题是当我尝试运行此代码时,我收到了以下错误代码:
3121:DeliveryFirstnames值太长。
如何解决这个问题?
答案 0 :(得分:0)
正在生成错误,因为您正在发送
DeliveryFirstnames=test&DeliverAddress1=123Main Street
由于DeliveryAddress拼写错误,因此DeliveryFirstNames将第一个名称取为test&DeliverAddress1=123Main Street
而不是test
将上述内容更改为
DeliveryFirstnames=test&DeliveryAddress1=123Main Street