You are here

function pay_transaction::valid_actions in Pay 7

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

Return an array of valid actions for this payment transaction. This list describes every type of general activity that might be possible, based on this transaction's payment form, and in turn, that form's payment methods.

Parameters

$name: The name of an action. If this is defined, only info for that action wil be returned.

2 calls to pay_transaction::valid_actions()
pay_transaction::available_actions in includes/handlers/pay_transaction.inc
Return an array of actions that are available for this transaction in its current state.
pay_transaction::valid_action in includes/handlers/pay_transaction.inc
Determine whether an action is valid and appropriate for this transaction.

File

includes/handlers/pay_transaction.inc, line 101
A base class for payment transactions.

Class

pay_transaction
@file A base class for payment transactions.

Code

function valid_actions($name = NULL) {

  // Create a default list of potential payment actions.
  $actions = array(
    'authorize' => array(
      'title' => t('Authorize'),
      'callback' => 'authorize_action',
      'valid states' => array(
        'pending',
      ),
    ),
    'complete' => array(
      'title' => t('Complete'),
      'message' => t('Transaction completed'),
      'callback' => 'complete_action',
      'valid states' => array(
        'pending',
        'active',
      ),
    ),
    'cancel' => array(
      'title' => t('Cancel'),
      'message' => t('Transaction cancelled'),
      'callback' => 'cancel_action',
      'valid states' => array(
        'pending',
        'active',
      ),
    ),
    'refund' => array(
      'title' => t('Refund'),
      'message' => t('Transaction has been refunded'),
      'callback' => 'refund_action',
      'valid states' => array(
        'complete',
      ),
    ),
    'delete' => array(
      'title' => t('Delete'),
      'message' => t('Transaction has been deleted'),
    ),
  );

  // Allow my pay_form to alter or augment this list of actions.
  // The pay_form handler also calls set_valid_actions for each pay_method.
  $this
    ->pay_form()
    ->set_valid_actions($this, $actions);
  if ($name) {
    return $actions[$name];
  }
  return $actions;
}