cancel
Showing results for 
Search instead for 
Did you mean: 

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

YohannM
Member
1 REPLY 1

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
All Star