Authorize.NET API Wrapper Class
The Authorize.Net Payment Gateway can help you accept credit card and electronic check payments quickly and affordably. More than 305,000 merchants trust them for payment processing and online fraud prevention solutions.
What can I do with it?
This class is a wrapper to the Authorize.Net API written in PHP5 that can be used to submit credit card transactions to the Authorize.net payment gateway using the AIM Web services API. The class provides functions for setting the payment details like the customer name, address, phone number, shipping address, charge amount, credit card number and expiry date.
A function is also provided to add additional custom fields to the API call.
How do I use it?
First you'll need to have an account with Authorize.Net if you don't already have one. Fork the class and plugin in the information that you want to submit. An example is shown below:
<?php
require_once('Class.AuthNet.php');
/**
* Create new Regular Transaction.
*/
$Auth = new AuthNet('YOUR_LOGIN_ID', 'YOUR_TRANS_KEY');
$Auth->setEnvironment('test');
$Auth->setTransactionType('AUTH_CAPTURE');
$Auth->setPaymentMethod('CC');
$Auth->setAmount('160.25', TRUE);
$Auth->setCCNumber('378282246310005');
$Auth->setCVV('4685');
$Auth->setExpiration('11/12');
$Auth->setPaymentDescription('New Sale on Product 232');
$Auth->setCustomerFirstName('Richard');
$Auth->setCustomerLastName('Castera');
$Auth->setCustomerCompany('SankyNet');
$Auth->setCustomerAddress('589 8th Ave Suite 10');
$Auth->setCustomerCity('New York');
$Auth->setCustomerState('NY');
$Auth->setCustomerZip('10018');
$Auth->setCustomerCountry('United States');
$Auth->setCustomerPhone('212-123-1234');
$Auth->setCustomerFax('212-123-4567');
$Auth->setCustomerEmail('richard.castera@gmail.com');
$Auth->sendCustomerReceipt(FALSE);
$Auth->setShippingFirstName('Richard');
$Auth->setShippingLastName('Castera');
$Auth->setShippingCompany('SankyNet');
$Auth->setShippingAddress('589 8th Ave. Suite 10');
$Auth->setShippingCity('New York');
$Auth->setShippingState('NY');
$Auth->setShippingZip('10018');
$Auth->setShippingCountry('United States');
if($Auth->processTransaction()):
echo('Transaction Processed Successfully!');
else:
echo('Transaction could not be processed at this time.');
endif;
echo('<h2>Name Value Pair String:</h2>');
echo('<pre>');
print_r($Auth->debugNVP('array'));
echo('</pre>');
echo('<h2>Response From Authorize:</h2>');
echo('<pre>');
print_r($Auth->getResponse());
echo('</pre>');
unset($Auth);
?>
