You are here

function uc_payment_uc_order in Ubercart 7.3

Implements hook_uc_order().

File

payment/uc_payment/uc_payment.module, line 136

Code

function uc_payment_uc_order($op, $order) {
  if (!isset($order->payment_method)) {
    $order->payment_method = '';
  }
  switch ($op) {
    case 'submit':
      $func = _uc_payment_method_data($order->payment_method, 'callback');
      if (function_exists($func)) {
        return $func('order-submit', $order);
      }
      break;
    case 'load':
      $func = _uc_payment_method_data($order->payment_method, 'callback');
      if (function_exists($func)) {
        $func('order-load', $order);
      }
      break;
    case 'save':
      $func = _uc_payment_method_data($order->payment_method, 'callback');
      if (function_exists($func)) {
        $func('order-save', $order);
      }
      break;
    case 'can_delete':
      if (uc_payment_load_payments($order->order_id) !== FALSE) {
        return FALSE;
      }
      break;
    case 'delete':
      db_delete('uc_payment_receipts')
        ->condition('order_id', $order->order_id)
        ->execute();

      // Call each payment method to delete method-specific data from the
      // database.
      $methods = _uc_payment_method_list();
      foreach ($methods as $method) {
        $func = $method['callback'];
        if (function_exists($func)) {
          $func('order-delete', $order);
        }
      }
      break;
  }
}