Skip navigation
Help

hook_uc_payment_method_callback

7 uc_payment.api.php hook_uc_payment_method_callback($op, &$order, $form = NULL, &$form_state = NULL)

Callback function to perform various operations for a payment method.

Possible operations are as follows:

  • "cart-details": The payment method has been selected at checkout. Return a form or render array to be displayed in the payment method pane.
  • "cart-process": Called when the user submits the checkout form with this payment method selected, used to process any form elements output by the 'cart-details' op. Return FALSE to abort the checkout process, or NULL or TRUE to continue with checkout.
  • "cart-review": Called when the checkout review page is being displayed. Return an array of data to be displayed below the payment method title on the checkout review page.
  • "customer-view": Called when the order is being displayed to a customer. Return a render array to be displayed to customers.
  • "order-delete": Called when an order is being deleted. Payment methods should clean up any extra data they stored related to the order.
  • "order-details": Called when an order is being edited by an administrator. Return a string or a form array to be displayed to the administator.
  • "order-load": Called from hook_uc_order('load') when this payment method is selected for the order.
  • "order-process": Called when an order has been edited by an administrator. Process any form elements returned by the "order-details" op.
  • "order-save": Called from hook_uc_order('save') when this payment method is selected for the order.
  • "order-submit": Called from hook_uc_order('submit') when this payment method is selected for the order.
  • "order-view": Called when the order is being displayed on the order admin pages. Return a render array to be displayed to administrators.
  • "settings": Called when the payment methods page is being displayed. Return a system settings form array to configure the payment method.

Parameters

$op: The operation being performed.

&$order: The order object that relates to this operation.

$form: Where applicable, the form object that relates to this operation.

&$form_state: Where applicable, the form state that relates to this operation.

Return value

Dependent on $op.

See also

hook_uc_payment_method()

Related topics

File

ubercart/payment/uc_payment/uc_payment.api.php, line 198
Hooks provided by the Payment module.

Code

function hook_uc_payment_method_callback($op, &$order, $form = NULL, &$form_state = NULL) {
  switch ($op) {
    case 'cart-details':
      return array('#markup' => t('Continue with checkout to complete payment.'));

    case 'settings':
      $form['uc_payment_method_account_number'] = array(
        '#type' => 'textfield', 
        '#title' => t('Payment gateway account number'), 
        '#default_value' => variable_get('uc_payment_method_account_number', ''),
      );
      return $form;
  }
}