2

尝试使用 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”。

4

5 回答 5

1

当前版本的omnipay/sagepay 错误地将美国州设置为非美国账单地址。

如果地址在美国境外,则 SagePay 拒绝的状态为 NULL。不幸的是,SagePay 的错误消息通常指的是相邻字段而不是实际错误。因此,当它实际上意味着尚未设置状态时,它会抱怨未设置 BillingCountry。

Git 存储库中有针对此错误的修复,但它不在主要版本中,因此 Composer 错过了它。

同时,您可以手动将状态设置为空字符串$data['card']['state'] = ''

于 2014-08-13T14:56:42.967 回答
0

为了响应 Jason 的评论/答案,Omnipay 处理多个支付网关,因此将传递的字段转换为特定网关所期望的正确字段名称。在 SagePay 的情况下,这是:

protected function getBaseAuthorizeData()
{
    $this->validate('amount', 'card', 'transactionId');
    $card = $this->getCard();

    $data = $this->getBaseData();
    $data['Description'] = $this->getDescription();
    $data['Amount'] = $this->getAmount();
    $data['Currency'] = $this->getCurrency();
    $data['VendorTxCode'] = $this->getTransactionId();
    $data['ClientIPAddress'] = $this->getClientIp();
    $data['ApplyAVSCV2'] = $this->getApplyAVSCV2() ?: 0;
    $data['Apply3DSecure'] = $this->getApply3DSecure() ?: 0;

    // billing details
    $data['BillingFirstnames'] = $card->getFirstName();
    $data['BillingSurname'] = $card->getLastName();
    $data['BillingAddress1'] = $card->getBillingAddress1();
    $data['BillingAddress2'] = $card->getBillingAddress2();
    $data['BillingCity'] = $card->getBillingCity();
    $data['BillingPostCode'] = $card->getBillingPostcode();
    $data['BillingState'] = $card->getBillingCountry() === 'US' ? $card->getBillingState() : null;
    $data['BillingCountry'] = $card->getBillingCountry();
    $data['BillingPhone'] = $card->getBillingPhone();

    // shipping details
    $data['DeliveryFirstnames'] = $card->getFirstName();
    $data['DeliverySurname'] = $card->getLastName();
    $data['DeliveryAddress1'] = $card->getShippingAddress1();
    $data['DeliveryAddress2'] = $card->getShippingAddress2();
    $data['DeliveryCity'] = $card->getShippingCity();
    $data['DeliveryPostCode'] = $card->getShippingPostcode();
    $data['DeliveryState'] = $card->getShippingCountry() === 'US' ? $card->getShippingState() : null;
    $data['DeliveryCountry'] = $card->getShippingCountry();
    $data['DeliveryPhone'] = $card->getShippingPhone();
    $data['CustomerEMail'] = $card->getEmail();

    return $data;
}
于 2014-08-08T12:53:22.580 回答
0

firstName 和 lastName 字段 - 它们应该是:

  • BillingFirstNames(是的,复数)
  • 计费姓氏

我去年写的一个网关包中总结了所有字段的属性:

https://github.com/academe/SagePay/blob/master/src/Academe/SagePay/Metadata/Transaction.php

这包括字段名称、长度、强制状态、允许的字符以及这些字段用于哪些事务类型。这些细节很难从文档中提取,而且许多根本没有文档记录,是通过试用和发现的。 -错误。

编辑:如果 Omnipay 翻译字段名称,这可能是一个愚蠢的答案,所以请随意忽略它。我的头在 SagePay 而不是 Omnipay。

于 2014-08-08T12:42:30.750 回答
0

这可能是一个区分大小写的问题吗?将其更改为“BillingCountry”有什么不同吗?

于 2014-07-31T05:19:51.700 回答
0

由于此错误已修复,因此我也遇到了错误。然而,上面提到的错误现在已经得到修复。

在我的情况下,问题源于使用“DeliveryXXXX”而不是“ShippingXXXX”。一旦我将 Delivery 的所有实例更改为 Shipping,我就停止接收错误。

于 2016-05-27T08:24:09.647 回答