You are here

function uc_authorizenet_charge in Ubercart 7.3

Same name and namespace in other branches
  1. 5 payment/uc_authorizenet/uc_authorizenet.module \uc_authorizenet_charge()
  2. 6.2 payment/uc_authorizenet/uc_authorizenet.module \uc_authorizenet_charge()

Main handler for processing credit card transactions.

1 string reference to 'uc_authorizenet_charge'
uc_authorizenet_uc_payment_gateway in payment/uc_authorizenet/uc_authorizenet.module
Implements hook_uc_payment_gateway().

File

payment/uc_authorizenet/uc_authorizenet.module, line 197
Processes payments using Authorize.net. Supports AIM and ARB.

Code

function uc_authorizenet_charge($order_id, $amount, $data) {

  // Load the order.
  $order = uc_order_load($order_id);

  // Perform the appropriate action based on the transaction type.
  switch ($data['txn_type']) {

    // Reference transactions are handled through Authorize.Net's CIM.
    case UC_CREDIT_REFERENCE_TXN:
      return _uc_authorizenet_cim_profile_charge($order, $amount, $data);

    // Set a reference only.
    case UC_CREDIT_REFERENCE_SET:

      // Return the error message if this failed.
      if ($message = _uc_authorizenet_cim_profile_create($order)) {
        return array(
          'success' => FALSE,
          'message' => $message,
        );
      }
      else {
        return array(
          'success' => TRUE,
          'log_payment' => FALSE,
          'message' => t('New customer profile created successfully at Authorize.Net.'),
        );
      }

    // Accommodate all other transaction types.
    default:
      return _uc_authorizenet_charge($order, $amount, $data);
  }
}