0

Im using the authorize.net recurring transaction. What Im trying to do is give the an option to check off a donation if they want it recurring for the next 12 months.

So before the ARB - I want to verify the card but 0.00 isn't a valid amount. so if i made the amount 0.01 - how can I void the transaction after the card is verified?

Also - when a subscription is made I dont get an email from authorize.net telling me a transaction was made like when a regular transaction is processed.

My code:

$authorization = new AuthnetAIM($apilogin, $apitranskey, true);
$authorization->setTransaction($creditcard, $expiration, '0.01');
$authorization->setTransactionType('AUTH_ONLY');
$authorization->process();
if ($authorization->isApproved())
{
$subscription = new AuthnetARB($apilogin, $apitranskey, AuthnetARB::USE_DEVELOPMENT_SERVER);
    // Set subscription information
    $subscription->setParameter('amount', $amount);
    $subscription->setParameter('cardNumber', $creditcard);
    $subscription->setParameter('expirationDate', $expiration);
    $subscription->setParameter('firstName', $business_firstname);
    $subscription->setParameter('lastName', $business_lastname);
    $subscription->setParameter('address', $business_address);
    $subscription->setParameter('city', $business_city);
    $subscription->setParameter('state', $business_state);
    $subscription->setParameter('zip', $business_zipcode);
    $subscription->setParameter('email', $email);

    // Set the billing cycle for every three months
    $subscription->setParameter('interval_length', 1);
    $subscription->setParameter('startDate', date("Y-m-d", strtotime("+ 1 months")));

    // Create the subscription
    $subscription->createAccount();

    // Check the results of our API call
    if ($subscription->isSuccessful())
    {
        // Get the subscription ID
        $subscription_id = $subscription->getSubscriberID();
        Send_email();
    }
    else
    {
        $transError = 'your subscription was not created';
        $hasError = true;

    }
}
else if ($authorization->isDeclined())
{
    $transError = 'This card is not valid';
        $hasError = true;
}

}
catch (AuthnetARBException $e)
{
    $transError =  'There was an error processing the transaction. Here is the error message:<br/> ';
    echo $e->__toString();
    $hasError = true;
}
}
John Conde
  • 217,595
  • 99
  • 455
  • 496
Moishy
  • 3,560
  • 3
  • 23
  • 42

2 Answers2

3

With the new SDK for authorize this would work

$authorize = new AuthorizeNetAIM(self::AUTHNET_LOGIN, self::AUTHNET_TRANSKEY);
$authorize->setFields(array(
        'amount' => '0.01',
        'card_num' => $cardNumber,
        'exp_date' => $expDate
));

$response = $authorize->authorizeOnly();
if ($response->response_code == 1) {
        // good card
}else{
     // bad card
}
Rick
  • 12,606
  • 2
  • 43
  • 41
1

Not only is 0.00 a valid amount, but if you're just trying to verify a credit card is legitimate you are required by Visa and Mastercard to use that amount. A few years ago they stopped allowing pre-auths of any real value to be done for this reason. I think there are fines for merchants who fail to do so.

Having said that, if you're going to take the "charge $.01 and then void the transaction" route, the following code should work:

$transaction_id = $authorization->getTransactionID();
$void = new AuthnetAIM($apilogin, $apitranskey, true);
$void->setTransactionType("VOID");
$void->setParameter('x_trans_id', $transaction_id);
$void->process();
John Conde
  • 217,595
  • 99
  • 455
  • 496
  • Thanks man! - im using your tutorial and when i leave the amount set to 0.00 it throws me this error: "Required information for transaction processing omitted: dollar amount" – Moishy Aug 26 '13 at 19:04
  • Interesting. Maybe things have changed as it's been a while since I've been involved in merchant account related stuff. But if you're getting that error and .01 works then definitely take that route. – John Conde Aug 26 '13 at 19:05
  • So i place the new code right after the authorization? I got an email for a receipt for 0.01 - does this mean it will void it by th eend of the day? – Moishy Aug 26 '13 at 19:14
  • Place it any time after `if ($authorization->isApproved()) {`. It will then be voided immediately and the customer will never see it on their statement. – John Conde Aug 26 '13 at 19:16
  • ok i put it in - im just not sure where it will reflect the voided transaction. Is it possible to set an end date of the subscription? - I only want it for each month for 12 months – Moishy Aug 26 '13 at 19:22
  • use `$subscription->setParameter('totalOccurrences', 12);` to have it run for only 12 months (i.e. 12 payments). The voided transaction should appear in the Authnet control panel. But that's about it for an audit trail. – John Conde Aug 26 '13 at 19:25