0

我正在使用 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;
}
}
4

2 回答 2

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
}
于 2014-06-07T03:31:31.887 回答
1

0.00 不仅是有效金额,而且如果您只是想验证信用卡是否合法,Visa 和 Mastercard 要求您使用该金额。几年前,出于这个原因,他们停止允许进行任何实际价值的预授权。我认为对不这样做的商人会处以罚款。

话虽如此,如果您要采用“收取 0.01 美元,然后使交易无效”的路线,以下代码应该可以工作:

$transaction_id = $authorization->getTransactionID();
$void = new AuthnetAIM($apilogin, $apitranskey, true);
$void->setTransactionType("VOID");
$void->setParameter('x_trans_id', $transaction_id);
$void->process();
于 2013-08-26T18:59:38.407 回答