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 :)