You are here

function pay_load_object in Pay 7

API Function: Load a payment class.

This function was renamed in D7 as to not collide with hook_load().

10 calls to pay_load_object()
pay_activity_load in ./pay.module
API Function: Load a payment activity object.
pay_form in ./pay.module
A simple form any type of pay element. If you want to build a module with a standalone payment form, you would do so by passing this function to the drupal_get_form page handler in your hook_menu() funcion.
pay_form_callback in ./pay.module
A helper function for FAPI validate/submit callbacks. Locates any pay elements in a form and calls thier handler code.
pay_form_load in ./pay.module
API Function: Load a payment form object.
pay_handler_field_handler::render in includes/views/pay_handler_field_handler.inc
Render the field.

... See full list

File

./pay.module, line 249
Pay module allows for accepting payments using pluggable payment backends.

Code

function pay_load_object($type, $values = NULL) {
  if (is_scalar($values)) {
    if (is_numeric($values)) {
      if ($type == 'pay_form') {
        $key = 'pfid';
      }
      if ($type == 'pay_method') {
        $key = 'pmid';
      }
      if ($type == 'pay_item') {
        $key = 'piid';
      }
      if ($type == 'pay_transaction') {
        $key = 'pxid';
      }
      if ($type == 'pay_activity') {
        $key = 'paid';
      }
      $result = db_select($type, 't')
        ->fields('t')
        ->condition($key, $values)
        ->execute();
      if ($values = $result
        ->fetchObject()) {
        $handler = isset($values->handler) ? $values->handler : $type;
      }
      else {
        return FALSE;
      }
    }
    else {

      // It's just the name of a handler. Load it with defaults.
      $handler = $values;
      $values = NULL;
    }
  }
  else {
    $values = (object) $values;
    if (isset($values->handler)) {
      $handler = $values->handler;
    }
    elseif (isset($values->pmid)) {
      $handler_values = pay_load_object($type, $values->pmid);
      $handler = get_class($handler_values);
      $values = array_merge((array) $handler_values, (array) $values);
    }
    else {

      // Allow return of a generic object of the type requested.
      $handler = $type;
    }
  }
  if (pay_load_handler($type, $handler)) {
    return new $handler($values);
  }
}