Authorize.Net验证信用卡AIM和ARB

时间:2013-08-26 18:29:19

标签: php authorize.net recurring-billing authorize.net-arb authorize.net-aim

我正在使用authorize.net定期交易。 我想做的是,如果他们希望在接下来的12个月内重复捐赠,可以选择检查捐款。

所以在ARB之前 - 我想验证卡,但0.00不是有效金额。所以,如果我的金额为0.01,那么在验证卡后如何使交易无效?

此外 - 订阅时,我没有收到来自authorize.net的电子邮件,告诉我交易是在处理常规交易时进行的。

我的代码:

$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;
}
}

2 个答案:

答案 0 :(得分:3)

使用新的SDK进行授权,这将起作用

$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
}

答案 1 :(得分:1)

不仅0.00是有效金额,而且如果您只是想验证信用卡是否合法,则Visa和万事达卡需要您使用该金额。几年前,由于这个原因,他们停止允许任何真正价值的预认证。对于没有这样做的商家,我认为会有罚款。

话虽如此,如果您要采取“收费$ .01然后使交易无效”路线,以下代码应该有效:

$transaction_id = $authorization->getTransactionID();
$void = new AuthnetAIM($apilogin, $apitranskey, true);
$void->setTransactionType("VOID");
$void->setParameter('x_trans_id', $transaction_id);
$void->process();