Integration and Testing

Authorize.Net API questions and help with your payment integration.

Posts: 2
Registered: ‎12-01-2015

API Reference Charge A Card Sample Code Error

I'm trying to run the sample code for Charge A Card from the API Reference but am getting an Uncaught Exception error for JMS\Serializer\Exception\RuntimeException.  The long error message ends with "YamlDriver.php on line 38".


I've played around with it and have found that it's the CustomerDataType that is causing the problem.  If I remove the lines of code for setId and setEmail then it works fine.


Has anyone else seen this?


Posts: 1
Registered: ‎11-17-2015

Re: API Reference Charge A Card Sample Code Error

Hello @awtech,


Can you please provide the full error message? It will be really helpful in rectifying the issue.


Also, from the error I am guessing that your development environment is not setup completely. There are some dependencies that need to be installed locally before using sample codes. Look into with installation instructions. You will need composer for installation of all dependencies. 


Hope it helps.

Posts: 3
Registered: ‎11-01-2015

Re: API Reference Charge A Card Sample Code Error

Thanks for the reply.  Yes, I did run the composer.json file in order to pull in the over 2,000 dependency files - otherwise none of the example code would run.  I have to say that I'm surprised that requires all this 3rd party cody for something a security related as processing credit cards.  Seems a big risk to be pulling in that many 3rd party files that they have no control over... and is all that really necessary to just process some credit cards?  Seems like a bunch of overkill to me and it's been a really frustrating process trying to work with this API.


In any case, the problem is when I run the sample code I have to comment out 3 lines of code for setting the customerID.  It runs fine with these 3 lines commented out, but if they're left in, it throws the error below.


$customer = new AnetAPI\CustomerDataType();





Error displayed:


Fatal error: Uncaught exception 'JMS\Serializer\Exception\RuntimeException' with message 'Expected metadata for class net\authorize\api\contract\v1\CustomerDataType to be defined in /home/awtechho/public_html/helios/chase/lib/net/authorize/api/controller/base/../../yml/v1/CustomerDataType.yml.' in /home/awtechho/public_html/helios/chase/vendor/jms/serializer/src/JMS/Serializer/Metadata/Driver/YamlDriver.php:38 Stack trace: #0 /home/awtechho/public_html/helios/chase/vendor/jms/metadata/src/Metadata/Driver/AbstractFileDriver.php(28): JMS\Serializer\Metadata\Driver\YamlDriver->loadMetadataFromFile(Object(ReflectionClass), '/home/awtechho/...') #1 /home/awtechho/public_html/helios/chase/vendor/jms/metadata/src/Metadata/Driver/DriverChain.php(38): Metadata\Driver\AbstractFileDriver->loadMetadataForClass(Object(ReflectionClass)) #2 /home/awtechho/public_html/helios/chase/vendor/jms/metadata/src/Metadata/MetadataFactory.php(103): Metadata\Driver\DriverChain->loadMetadataForClass(Object(ReflectionClass)) #3 /home/awtechho/public_ in /home/awtechho/public_html/helios/chase/vendor/jms/serializer/src/JMS/Serializer/Metadata/Driver/YamlDriver.php on line 38