问题
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;
}
}
回答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();
回答2:
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
}
来源:https://stackoverflow.com/questions/18450602/authorize-net-verify-credit-card-aim-and-arb