stymiee / authorize.net-xml Goto Github PK
View Code? Open in Web Editor NEWA PHP class for handling Authorize.Net's AIM, ARB, CIM, and Reporting APIs
License: MIT License
A PHP class for handling Authorize.Net's AIM, ARB, CIM, and Reporting APIs
License: MIT License
Thanks for the great class.
Authorize.net SDK explains a way that stored payment information can be managed via an iframe that can be placed on a website. I was just wondering if it'd be possible to add this functionality to this class as well so we don't have to switch to the sdk to accomplish it.
Hi John,
I've identified an issue associated with the sample code associated with the createCustomerProfileTransactionRequest
method in conjunction with profileTransAuthCapture
. I've elaborated here in an edit to my original question on the topic:
http://stackoverflow.com/questions/12011971/authorize-net-xml-adding-line-items/12678455#12678455
Love the class, it's working out great for a project I'm working on!
Jason
The problem is that you can't have duplicate keys at the same level in an array. If you do the last one entered wins and the rest are overwritten.
So you need a way to represent repeating items from XML in and array. I decide to use the JSON methods to keep it simple. A quick wat to convert Simple XML to and array is to pass it through JSON.
$array = json_decode( json_encode( $simpleXML), true);
That will convert XML like this:
<transactionSettings> <setting> <settingName>allowPartialAuth</settingName> <settingValue>false</settingValue> </setting> <setting> <settingName>duplicateWindow</settingName> <settingValue>0</settingValue> </setting> <setting> <settingName>emailCustomer</settingName> <settingValue>false</settingValue> </setting> <setting> <settingName>recurringBilling</settingName> <settingValue>false</settingValue> </setting> <setting> <settingName>testRequest</settingName> <settingValue>false</settingValue> </setting> </transactionSettings>
To an array like this:
array( 'transactionSettings' => array( 'setting' => array( 0 => array('settingName' =>'allowPartialAuth' , 'settingValue' => 'false',), 1 => array('settingName' => 'duplicateWindow', 'settingValue' => '0', ), 2 => array('settingName' => 'emailCustomer', 'settingValue' => 'false', ), 3 => array('settingName' => 'recurringBilling', 'settingValue' => 'false',), 4 => array( 'settingName' => 'testRequest', false, ), ) );
So you need to modify AuthNetXML.class to recognize this format. Just replace your setParameters() method with:
private function setParameters($xml, $array) { if (is_array($array)) { $first = true; ``` foreach ($array as $key => $value) { if (is_array($value)) { if( is_numeric($key) ) { if($first){ $xmlx = $xml; $first = false; } else { $parent = $xml->xpath('parent::*'); $xmlx = $parent[0]->addChild($xml->getName()); } } else { $xmlx = $xml->addChild($key); } $this->setParameters($xmlx, $value); } else { $xml->$key = $value; } } } ``` }
I'm receiving the following error message when testing in Authorize.net sandbox. I'm not sure the exact issue but I'm assuming it has to do with SSL verification:
Access Denied
You don't have permission to access "http://apitest.authorize.net/xml/v1/request.api" on this server.
Reference #18.162f0660.1451338826.3f12ff2
It is in fact hitting the HTTPS API url: https://apitest.authorize.net/xml/v1/request.api
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /var/www/vhosts/recurring.givewp.com/recurring3.givewp.com/wp-content/plugins/Give-Recurring-Donations/lib/AuthnetXML/AuthnetXML.class.php:203 Stack trace: #0 /var/www/vhosts/recurring.givewp.com/recurring3.givewp.com/wp-content/plugins/Give-Recurring-Donations/lib/AuthnetXML/AuthnetXML.class.php(203): SimpleXMLElement->__construct('<HTML><HEAD>?<T...') #1 /var/www/vhosts/recurring.givewp.com/recurring3.givewp.com/wp-content/plugins/Give-Recurring-Donations/lib/AuthnetXML/AuthnetXML.class.php(149): AuthnetXML->process() #2 /var/www/vhosts/recurring.givewp.com/recurring3.givewp.com/wp-content/plugins/Give-Recurring-Donations/includes/gateways/give-recurring-authorize.php(124): AuthnetXML->__call('ARBCreateSubscr...', Array) #3 /var/www/vhosts/recurring.givewp.com/recurring3.givewp.com/wp-content/plugins/Give-Recurring-Donations/includes/gateways/give-recurring-authorize.php(124): AuthnetXML->ARBCreateSubscriptionRequest(Array) # in /var/www/vhosts/recurring.givewp.com/recurring3.givewp.com/wp-content/plugins/Give-Recurring-Donations/lib/AuthnetXML/AuthnetXML.class.php on line 203
I'm not sure if it's an error with the server setup, this script, or something else? Any insight is appreciated...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.