cancel
Showing results for 
Search instead for 
Did you mean: 

API Variables

Can someone point me to where I can find a complete list of API variables? I found the FORM variables in the Docs and have been trying to guess what the API variables would be based on those, but it's a little bit like throwing darts at a board :-)

jwcarlton
Contributor
1 ACCEPTED SOLUTION

Accepted Solutions

Heh, the "quick integration" code is sadly next to useless. Download the API for your favorite programming language (PHP?), and look in the subfolders for doc (AIM.markdown) and lib (AuthorizeNnetAIM.php - if you scroll down, it gives a complete list of fields). AIM is really fairly straightforward from there, for the most part - let me know if you have further questions.

View solution in original post

6 REPLIES 6

Which API and integration method are you using?

TJPride
Expert

I'm using AIM, but as for which API... I didn't know there was more than one option? I'm strictly going by the demo on the "15-minute integration" page, which uses API variables, but then I can't find anything in the Docs to help me expand on it.

 

$response = $transaction->authorizeAndCapture();

$transaction =newAuthorizeNetAIM('YOUR_API_LOGIN_ID','YOUR_TRANSACTION_KEY');
$transaction
->amount ='9.99';
$transaction
->card_num ='4007000000027';
$transaction
->exp_date ='10/16';


if($response->approved){
  echo
"<h1>Success! The test credit card has been charged!</h1>";
  echo
"Transaction ID: ". $response->transaction_id;
}

 

else echo $response->error_message;

Heh, the "quick integration" code is sadly next to useless. Download the API for your favorite programming language (PHP?), and look in the subfolders for doc (AIM.markdown) and lib (AuthorizeNnetAIM.php - if you scroll down, it gives a complete list of fields). AIM is really fairly straightforward from there, for the most part - let me know if you have further questions.

Here's an example of some code you can use to charge using AIM:

 

    $authorize = new AuthorizeNetAIM(
        $GLOBALS['_authorize_id'], $GLOBALS['_authorize_key']);
    $authorize->setSandbox(false);
    // SET TO TRUE IF USING SANDBOX ACCOUNT

    $fields = array(
        'first_name' => $_POST['first'],
        'last_name' => $_POST['last'],
        'company' => $_POST['company'],
        'address' => $_POST['address'],
        'city' => $_POST['city'],
        'state' => $_POST['state'],
        'zip' => $_POST['zip'],
        'country' => 'US',

        'phone' => $_POST['phone'],
        'email' => $_POST['email'],

        'customer_ip' => $_SERVER['REMOTE_ADDR'],

        'description' => 'order description here',
        'amount' => $amount,

        'card_num' => $_POST['card_number'],
        'exp_date' => sprintf('%02d%02d', $_POST['card_exp_month'], ($_POST['card_exp_year'] % 1000)),
        'card_code' => $_POST['card_ccv']
    );
    $authorize->setFields($fields);

    $result = $authorize->authorizeAndCapture();

    if ($result->error || $result->{'response_code'} != 1)
        $errors[] = "Charge declined - {$result->response_reason_text}";

 

Thanks a lot for that; especially the pointer to the Doc files in the SDK (I didn't even think to look there; I was looking at the PDFs on the site).

 

It LOOKS like the sample code isn't too much different from the sample; it just skips out on setting the $fields() array, and sets the variables like so:

 

$authorize->first_name = $_POST['first'];

$authorize->last_name = $_POST['last'];

 

And so on. But still, without the list of variables that could be set, I don't see how anyone could have figured that out on their own. The example you posted here would be much better on the "15-minute integration" page than what is currently there.

 

I tried the PDF's first as well, but had to give up because they were focused around the XML interface and not the PHP one layered on top and didn't give specific code. I did use the PDF to reference a few things, but this is mostly a mash-up of the markdown examples and what I learned in the forum (after some weeks, response often isn't forthcoming).