You are here

function uc_authorizenet_charge in Ubercart 5

Same name and namespace in other branches
  1. 6.2 payment/uc_authorizenet/uc_authorizenet.module \uc_authorizenet_charge()
  2. 7.3 payment/uc_authorizenet/uc_authorizenet.module \uc_authorizenet_charge()
1 string reference to 'uc_authorizenet_charge'
uc_authorizenet_payment_gateway in payment/uc_authorizenet/uc_authorizenet.module
Implementation of hook_payment_gateway().

File

payment/uc_authorizenet/uc_authorizenet.module, line 232
Process payments using Authorize.net. Supports AIM and ARB.

Code

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

  // Check for cURL support.
  if (!_uc_authorizenet_curl_check()) {
    return array(
      'success' => FALSE,
    );
  }

  // 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,
          'message' => t('New customer profile created successfully at Authorize.Net.'),
        );
      }

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