【发布时间】:2013-12-28 09:53:25
【问题描述】:
我已经设法让我的服务器使用带有表单集成的 PHP 与 SagePAY 服务器通信。 我的名称-值对被构建、串在一起、加密并被发布到 SagePAY 并被接受。
但是,SagePAY 服务器响应指出 BillingSurname 太长(错误 3108)。 BillingSurname 的构建和交付方式与 BillingForenames 完全相同,并且其中包含相同的数据。我尝试只发送“Smith”,但它仍然“太长”。不用说它少于指定的 20 个字符。
有什么想法吗?
编辑:添加加密代码 - 虽然我认为这不是问题 - 因为服务器现在正在读取 TXCode、货币、金额等,直到我们到达账单地址。
<?php
function pkcs5_pad($text, $blocksize)
{
$pad = $blocksize - (strlen($text) % $blocksize);
return $text . str_repeat(chr($pad), $pad);
}
function encryptFieldData($input)
{
$key = "SagePAY encryption key here";
$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 = "VendorTxCode=13362020&Currency=GBP&Description=a-url.co.uk Personalised stationery&SuccessURL=http://a-url.co.uk/success/&FailureURL=http://a-url.co.uk/problem/&VendorEmail=email@a-url.co.uk&SendEmail=1&Amount=7.95&BillingFirstnames=Albert&BillingSurname=Smith&BillingEmail=email@a-url.co.uk&BillingAddress1=4drds&BillingAddress2=deldSurrey&BillingCity=ddcd&BillingPostCode=XX7 1XX&BillingCountry=GB&BillingPhone=01342 123456&DeliveryFirstnames=Albert&DeliverySurname=Smith&DeliveryAddress1=4drds&DeliveryAddress2=deldSurrey&DeliveryCity=ddcd&DeliveryPostCode=AB7 6RF&DeliveryCountry=GB"
$datapadded = pkcs5_pad($str,16);
$cryptpadded = "@" . encryptFieldData($datapadded);
?>
【问题讨论】:
-
编码问题?另请向我们展示提交表单的代码。
-
您的标题和编辑消息说这已解决 - 您应该发布您所做的作为答案并接受它,以便将来遇到此问题的其他人可以轻松看到。
-
OP,解决方案是什么?