连接到AuthorizeNet时出错:仅在生产服务器中

时间:2012-11-26 12:23:16

标签: php joomla2.5 authorize.net

我正在Joomla使用PHPJoomla有一个组件(payplans)可用。在该组件中,他们配置了许多支付方法,包括Authorize.net。我们可以在Joomla后端选择付款方式,我们的客户使用Authorize.net,因此我们选择Authorize.net。我没有更改代码中的任何内容,它在我们当地的m / C。我只在实时服务器上收到错误,即使我已将真实帐户详细信息设置为测试帐户。

protected function _processNonRecurringRequest(PayplansPayment $payment, $data)
{

    $transactionData = array(
        'amount' => $payment->getAmount(), 
        'card_num' => $data['x_card_num'], 
        'exp_date' => $data['x_exp_date'],
        'first_name' => $data['x_first_name'],
        'last_name' => $data['x_last_name'],
        'address' => $data['x_address'],
        'city' => $data['x_city'],
        'state' => $data['x_state'],
        'country' => $data['x_country'],
        'zip' => $data['x_zip'],
        'email' => $data['x_email'],
        'card_code' => $data['x_card_code'],
    'ship_to_first_name' => $data['x_ship_to_first_name'],
    'ship_to_last_name' => $data['x_ship_to_last_name'],
    'ship_to_address' => $data['x_ship_to_address'],
    'ship_to_city' => $data['x_ship_to_city'],
    'ship_to_state' => $data['x_ship_to_state'],
    'ship_to_zip' => $data['x_ship_to_zip'],
    'ship_to_country' => $data['x_ship_to_country']
        );
    //  echo "Data \n";

    $transaction = new AuthorizeNetAIM();

    $transaction->setSandbox(true);
    $transaction->setFields($transactionData);
   // print_r($transaction); exit();
  //  echo "response";
    $response = $transaction->authorizeAndCapture();
  //    print_r($response);exit();
    $transactionArray = $response->toArray();
    // to identify it sis testing mode or not
    $transactionArray['testmode'] = $this->getAppParam('sandbox', 0);

    // save transaction notification and transaction id
    if(isset($transactionArray['transaction_id'])){
        $payment->set('txn_id', $this->getId().'_'.$transactionArray['transaction_id']);
    }

    $payment->set('transaction',PayplansHelperParam::arrayToIni($transactionArray));

    $errors   = array();
    if($response->approved){
        $payment->set('status',XiStatus::PAYMENT_COMPLETE);
    }       
    else{
        $payment->set('status',XiStatus::PAYMENT_PENDING);
        $errors['response_reason_code'] = $response->response_reason_code;
        $errors['response_code']        = $response->response_code;
        $errors['response_reason_text'] = $response->response_reason_text;
    }

    return $errors;
}

我在这一行中遇到错误

$response = $transaction->authorizeAndCapture();

请帮助

1 个答案:

答案 0 :(得分:1)

您将以下设置为True:

$transaction->setSandbox(true);

当然,对于实时服务器环境,它应设置为false。