cancel
Showing results for 
Search instead for 
Did you mean: 

Submit transaction using XML

I just implemented the ARB XML/PHP sample code and it works great.  I now just need a script that wil post a one-time transaction.  I would like to use the XML/PHP code since I've already learned it and have most everything setup.  I've searched all over the website and cannot find a PDF or sample code to do this.  Does this exist?  I'm assuming I just need the Schema and fields?  Thanks for any help!

justinomaha
Member
1 REPLY 1

If you look in your SDK in the doc folder for a file called AIM.markdown, it will supply sample code you can use. Here's what I'm using myself - note that certain fields like $_POST['initial_amount'] are verified internally to make sure they're valid before sending:

 

    $authorize = new AuthorizeNetAIM(
        $GLOBALS['_authorize_id'], $GLOBALS['_authorize_key']);
    $authorize->setSandbox(false);

    $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' => "{$_POST['type']} initial fee for " . count($_POST['zips']) . " zip codes with {$population} total estimated population",
        'amount' => $_POST['initial_payment'],

        '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[] = "Initial charge declined - {$result->response_reason_text}";

 

TJPride
Expert