You are here

function pay_activity::do_activity in Pay 7

Same name and namespace in other branches
  1. 6 includes/handlers/pay_activity.inc \pay_activity::do_activity()

Effect a payment action using the currently-selected payment method.

The action must be defined in valid_actions() and the that action's callback must exist for this payment method. Empty actions use a pseudo- action of 'pending'.

File

includes/handlers/pay_activity.inc, line 68
A base class for payment activities.

Class

pay_activity
@file A base class for payment activities.

Code

function do_activity($action = NULL, $values = array()) {

  // No action defined: Ensure that this transaction gets logged as 'pending'
  if (!$action || $action == 'pending') {
    $action = 'pending';
    $func = 'pending_action';
  }
  else {
    $info = $this
      ->pay_transaction()
      ->valid_actions($action);
    $func = $info['callback'];
  }
  $this
    ->set_action($action);

  // If the payment method has a function to handle this action, call it!
  if (method_exists($this
    ->pay_method(), $func)) {
    $this
      ->pay_method()->activity = $this;
    $state = $this
      ->pay_method()
      ->{$func}($values);
  }

  // Save any new/changed data for this activity.
  $this
    ->save();

  // Update this activity's transaction.
  $this
    ->pay_transaction()
    ->update_status($state, $this->timestamp);

  // Return boolean result.
  return $this->result;
}