Reply
New Member
Posts: 1
Registered: ‎03-02-2017

Keep Getting Transaction Failed E00003

I keep getting the following error message from the API:

 

ERROR : Transaction Failed E00003: The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:cardCode' element is invalid - The value XXXX is invalid according to its datatype 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:cardCode' - The actual length is less than the MinL

 

 

The error code resources is a bit vague on the description:

"An error occurred while parsing the XML request."

 

 

My implementation is as follow

 

// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName($this->ci->config->item('AUTHNETAPILOGINID'));
$merchantAuthentication->setTransactionKey($this->ci->config->item('AUTHNETKEY'));
$refId = 'ref' . time();

 

// Remove potential white spaces
$ccn = preg_replace( '/\s+/', '', $ccn );


// Format Date
$exp_date = DateTime::createFromFormat('m / y', $exp);

 

// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber( intval( $ccn ) );
$creditCard->setExpirationDate( $exp_date->format('Y-m') );
$creditCard->setCardCode( intval( $cvc ) );

$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
$order = new AnetAPI\OrderType();
$order->setDescription("Ticket");

 

// Create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");

 

//Assign previous info to the transactionRequest field
$transactionRequestType->setAmount( $amount );
$transactionRequestType->setOrder( $order );
$transactionRequestType->setPayment($paymentOne);
// $transactionRequestType->setBillTo($billto);

$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId( $refId );
$request->setTransactionRequest($transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
$response_api = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION);

 

Am I doing anything wrong?

 

Thanks

Highlighted
Administrator
Posts: 209
Registered: ‎11-03-2016

Re: Keep Getting Transaction Failed E00003

What value are you testing with for the card code? If you're trying something like "009", that's going to get sent as "9" because of your intval() call.

 

Try dropping the intval() call and just send it as text, and see if that will help.

-Aaron

Aaron Wright
Developer Evangelist - Authorize.Net

Follow Authorize.Net developer news on Twitter!