Can anyone tell me where I might have gotten this setup? I can't find it anywhere in the authorize.net community. It's not part of the "php_aim/sample.php" or the SDK, but I got it from somewhere and it's the ONLY WAY I can process a transaction using AIM. I'd like to read up on this method, but can't find where it came from. Please help!
Thanks.
<?php
require('anet/AuthnetAIM.class.php');
try
{
$creditcard = $_REQUEST['ccnumber'];
$expiration = $_REQUEST['expdate'];
$total = $_REQUEST['amt_paid'];
$first = $_REQUEST['first_name'];
$last = $_REQUEST['last_name'];
$addr = $_REQUEST['address'];
$city = $_REQUEST['city'];
$state = $_REQUEST['state'];
$zip = $_REQUEST['zip'];
$member_id = $_REQUEST['member_id'];
$description = "Young Voices Uniform, Fees and Tuition";
$email = $_REQUEST['email'];
$payment = new AuthnetAIM('xxxxxxxxx', 'xxxxxxxxxxxxxx');
$payment->setTransaction($creditcard, $expiration, $total);
$payment->setParameter("x_card_num", $creditcard);
$payment->setParameter("x_exp_date", $expiration);
$payment->setParameter("x_amount", $total);
$payment->setParameter("x_first_name", $first);
$payment->setParameter("x_last_name", $last);
08-27-2013 06:56 PM
Never mind. I found it at http://www.johnconde.net/blog/tutorial-integrating-the-authorizenet-aim-api-with-php/
08-27-2013 07:48 PM
That code was written in 2008, don't know how up to date it is. The sample code for AIM is here:
http://developer.authorize.net/integration/fifteenminutes/#custom
I would think that that would be pretty easy to adapt to your uses. Just add a few fields. Note - you should always use $_POST, since $_REQUEST is an amalgam of $_GET, $_POST, and $_COOKIE, and it is therefore easier for people to insert values into with a minimum of effort. Also check to make sure the amount (in this case $total) is within some reasonable minimum / maximum range before you process the transaction. Wouldn't hurt to run a Luhn on the credit card number, either.
08-27-2013 09:19 PM
The link you provided gave me a successful transaction, as have other basic aim and dmp test done. What I'm really trying to do is use John Conde's payment-form setup, but I can't ever get the form to work properly. It's just never happy. I want to get it to run in test mode... I've inserted my test credentials just like I did in the form you suggested, and I've gotten a MD5Hash to generate through a custom form I'm trying to incorporate, so adding that information to the "AuthorizeNet_Test_Config.php" file should work for me. Right?
I'm confused about what supposed to be included in the payment-form.php file. It says to use this:
// Include the SDK
require_once('./config.php');
But I'm thinking it should be:
require_once('../anet_php_sdk/AuthorizeNet_Test_Config.php');
Maybe payment-form.php should require:
require_once{'AuthorizeNetAIM_Test.php');
because that page then requires the AuthorizeNet_Test_Config.php file. Maybe AuthnetAIM.class.php and AuthorizeNet.php should also be added there, because they aren't being required anywhere.
There is also hard-coded test info in the AuthorizeNetAIM_Test.php file for amount, card number and exp_date, but the payment-form.php has fields for those and they need to be filled in, so it's hard to get this form working properly.
Any help you could give me on these question would be very much appreciated. I've tried so many different versions of what might be required where and am getting nowhere.
Thanks,
08-27-2013 09:48 PM