1

I'm in the process of implementing Netbanx as a payment gateway using the Omnipay PHP library, but I'm having an issues with errors relating to "Node: state" and "Node: country" strings being less than the minLength facet.

Note: I'm using the test credentials provided to me when registering for a developer account at Netbanx, and test CC details listed in their documentation here: docs.

Here is a code snippet from my Payment class:

class NetbanxPayment
{
    /**
     * Initialize payment gateway.
     *
     * @param string $accountNumber
     * @param string $storeId
     * @param string $storePassword
     * @param bool   $testMode
     */
    public function __construct($accountNumber, $storeId, $storePassword, $testMode = false)
    {
        $omnipay = new Omnipay;

        $this->gateway = $omnipay->create('NetBanx');

        $this->gateway->setAccountNumber($accountNumber);
        $this->gateway->setStoreId($storeId);
        $this->gateway->setStorePassword($storePassword);
        $this->gateway->setTestMode($testMode);
    }

    /**
     * Handle making the purchase
     *
     * @param       $amount
     * @param array $data
     *
     * @return \AwardForce\Modules\Payments\Contracts\Response
     */
    public function purchase($amount, $data = [])
    {
        $card = new CreditCard();

        $card->setNumber(array_get($data, 'cardNumber', ''));
        $card->setExpiryMonth(array_get($data, 'expiryMonth', ''));
        $card->setExpiryYear(array_get($data, 'expiryYear', ''));
        $card->setCvv(array_get($data, 'cvv', null));
        $card->setBillingAddress1(array_get($data, 'street', ''));
        $card->setBillingCity(array_get($data, 'city', ''));
        $card->setBillingPostcode(array_get($data, 'postcode', ''));
        if (array_get($data, 'country', '') == 'US') {
            $card->setBillingState(array_get($data, 'region', ''));
        }
        $card->setBillingCountry(array_get($data, 'country', ''));

        $response = $this->gateway->purchase([
            'amount'   => $amount,
            'currency' => $this->getCurrency(),
            'card'     => $card
        ])->send();

        dd($response);
     }
}

Here is the dumped response with the errors I'm seeing:

Response {#1404 ▼
  #data: SimpleXMLElement {#1405 ▼
    +"confirmationNumber": "329008300"
    +"decision": "ERROR"
    +"code": "5023"
    +"actionCode": "M"
    +"description": "You submitted a request that is not parseable."
    +"detail": array:4 [▼
      0 => SimpleXMLElement {#1400 ▼
        +"tag": "InternalResponseCode"
        +"value": "24"
      }
      1 => SimpleXMLElement {#1399 ▶}
      2 => SimpleXMLElement {#1398 ▶}
      3 => SimpleXMLElement {#1395 ▼
        +"tag": "ErrorDetail"
        +"value": """
          \n
          Errors: \n
            Node: state, Detail: string length (0) is less than minLength facet (2) for StateV1 in namespace http://www.optimalpayments.com/creditcard/xmlschema/v1\n
            Node: state, Detail: string length (0) is less than minLength facet (2) for StateV1 in namespace http://www.optimalpayments.com/creditcard/xmlschema/v1\n
            Node: country, Detail: string length (0) is less than minLength facet (2) for CountryV1 in namespace http://www.optimalpayments.com/creditcard/xmlschema/v1\n
          """
      }
    ]
    +"txnTime": "2015-10-12T21:20:59.661-04:00"
    +"duplicateFound": "false"
  }
}

Here's the formatted XML data being sent to Netbanx:

<?xml version="1.0" encoding="UTF-8"?>
<ccAuthRequestV1 xmlns="http://www.optimalpayments.com/creditcard/xmlschema/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.optimalpayments.com/creditcard/xmlschema/v1">
    <merchantAccount>
        <accountNum>********</accountNum>
        <storeID>********</storeID>
        <storePwd />
    </merchantAccount>
    <merchantRefNum>********</merchantRefNum>
    <amount>1.10</amount>
    <card>
        <cardNum>4111111111111111</cardNum>
        <cardExpiry>
            <month>11</month>
            <year>2019</year>
        </cardExpiry>
        <cardType>VI</cardType>
        <cvdIndicator>1</cvdIndicator>
        <cvd>123</cvd>
    </card>
    <billingDetails>
        <cardPayMethod>WEB</cardPayMethod>
        <firstName />
        <lastName />
        <street>123 Some St</street>
        <street2 />
        <city>City</city>
        <state />
        <country>GB</country>
        <zip>1234</zip>
        <phone />
        <email />
    </billingDetails>
</ccAuthRequestV1>

Any help, advice or pointers in the right direction as to what might be causing these issues would be greatly appreciated :)

4

1 回答 1

1

因此,在查看了 Netbanx 的开发人员文档之后,似乎并不期望计费状态和国家/地区成为卡对象的一部分。

    "card" => CreditCard {#1094 ▼
      #parameters: ParameterBag {#1342 ▼
        #parameters: array:7 [▼
          "number" => "4530910000012345"
          "expiryMonth" => 11
          "expiryYear" => 2019
          "cvv" => "123"
          "billingPostcode" => "1234"
          "billingState" => "London"
          "billingCountry" => "GB"
        ]
      }

https://developer.optimalpayments.com/en/documentation/card-payments-api/card-object/

API 期待这样的请求:

     "merchantRefNum" : "demo-1",
     "amount" : 10098,
     "settleWithAuth":true,
     "card" : {
       "cardNum" : "4111111111111111",
       "cardExpiry":{
         "month":2,
         "year":2017
        },
        "cvv":123
      },
      "billingDetails":{
         "street":"100 Queen Street West",
         "city":"Toronto",
         "state":"ON",              
         "country":"CA",
         "zip":"M5H 2N2"
      }
    } '

这可能是 Omnipay 插件的问题,但您必须对其进行修改,以便将帐单详细信息发送到正确的对象中。

于 2015-10-13T02:06:53.683 回答