Integration and Testing

Authorize.Net API questions and help with your payment integration.

Reply
Member
Posts: 1
Registered: ‎09-27-2011

How to use AUTH_ONLY with CC method

Hello,

 

Is it necessarly that if x_type is "AUTH_ONLY" then x_method must be "ECHECK", if yes then how to implement AUTH_ONLY (x_type) with CC (x_method)

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: How to use AUTH_ONLY with CC method

Posts: 1,609
Topics: 15
Kudos: 209
Solutions: 121
Registered: ‎06-23-2011

Re: How to use AUTH_ONLY with CC method

Maybe something like this (untested since it's adapted from my authorize and capture implementation):

 

$authorize = new AuthorizeNetAIM(
    $GLOBALS['_authorize_id'], $GLOBALS['_authorize_key']);
$authorize->setSandbox(true);
// Set to false if using production 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' => "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);

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

else
    // do something with transaction ID so it can be captured later

 Or you can just call the authorizeOnly function directly:

 

$authorize = new AuthorizeNetAIM(
    $GLOBALS['_authorize_id'], $GLOBALS['_authorize_key']);
$authorize->setSandbox(true);
// Set to false if using production account

$result = $authorize->authorizeOnly($amount, $card_num, $exp_date);

// Process results