尝试使用 SagePay Server 时出现以下错误(来自打印响应):
["data":protected]=>array(3) {
["VPSProtocol"]=>
string(4) "2.23"
["Status"]=>
string(7) "INVALID"
["StatusDetail"]=>
string(107) "The data in the BillingCountry field you supplied is an invalid length. Must be an ISO 3166-1 country code."
}
但我将值“GB”作为正确的 billingCountry 传递(SagePay 期望 billingCountry 是按字母顺序排列的,最多 2 个字符)
["card"]=>
object(Omnipay\Common\CreditCard)#46 (1) {
["parameters":protected]=>
object(Symfony\Component\HttpFoundation\ParameterBag)#48 (1) {
["parameters":protected]=>
array(11) {
["email"]=>
string(17) "test@test.com"
["billingFirstName"]=>
string(3) "Joe"
["shippingFirstName"]=>
string(3) "Joe"
["billingLastName"]=>
string(6) "Bloggs"
["shippingLastName"]=>
string(6) "Bloggs"
["billingAddress1"]=>
string(9) "Address 1"
["billingAddress2"]=>
string(9) "Address 2"
["billingCity"]=>
string(4) "City"
["billingPostcode"]=>
string(7) "AB1 1BA"
["billingCountry"]=>
string(2) "GB"
["billingPhone"]=>
string(13) "01234 567 890"
}
}
这是我的代码:
$response = $this->gateway->Purchase(array(
'description'=> 'Online order',
'currency'=> 'GBP',
'transactionId'=> mt_rand(99, 9999),
'transactionReference' => 'test order',
'amount'=> '1.00',
'returnUrl' => 'http://www.test.com/returnURL/',
'cancelUrl' => 'http://www.test.com/cancelURL/',
'card' => array(
'email' => 'test@test.com',
'clientIp' => '123.123.123.123',
'firstName' => 'Joe',
'LastName' => 'Bloggs',
'billingAddress1' => 'Address 1',
'billingAddress2' => 'Address 2',
'billingCity' => 'City',
'billingPostcode' => 'AB1 1BA',
'billingCountry' => 'GB',
'billingPhone' => '01234 567 890'
)))->send();
我无法解决它,因为它看起来都是正确的。我想我会有点生气!我错过了完全显而易见的事情吗?
28.07.2014 更新: 我一直在尝试各种事情,包括以不同格式发送数据:
$formInputData = array(
'firstName' => 'Joe',
'lastName' => 'Bloggs',
'billingAddress1' => '88',
'billingAddress2' => 'Address 2',
'billingCity' => 'City',
'billingPostcode' => '412',
'billingCountry' => 'GB',
'billingPhone' => '01234 567 890',
'email' => 'test@test.com',
'clientIp' => '123.123.123.123'
);
$card = new CreditCard($formInputData);
$transactionID = mt_rand(99, 9999);
$response = $this->gateway->purchase(['amount' => '1.00', 'returnUrl' => 'http://www.example.com/return/', 'transactionId'=> $transactionID, 'description'=> 'Online order', 'transactionReference' => 'test order', 'currency'=> 'GBP', 'card' => $card])->send();
它没有任何区别。
我还尝试将相同的数据(但在卡参数中添加了测试信用卡详细信息)发送到 SagePay Direct 和 CardSave。
使用 SagePay Direct,我得到“POST 中缺少 BillingCountry 字段”。
使用 CardSave 交易成功完成,但当我查看 CardSave 中的交易历史时,我注意到国家字段有“N/A”。