You are here

function pay_method_direct::form_submit in Pay 7

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

Overrides pay::form_submit

File

includes/handlers/pay_method_direct.inc, line 153
The base class for 'direct' payment activities, where payments are collected on third-party sites such as PayPal, and the responses are returned to Drupal on a URL callback.

Class

pay_method_direct
@file The base class for 'direct' payment activities, where payments are collected on third-party sites such as PayPal, and the responses are returned to Drupal on a URL callback.

Code

function form_submit(&$form, &$form_state) {

  // Find our transaction object provided by pay_form::form_submit().
  if (isset($form_state['pay_activity']) && $form_state['pay_activity']) {
    foreach ($form_state['pay_activity'] as $key => $activity) {
      if ($activity->pmid == $this->pmid) {

        // Load the activity as the 'current' one.
        $this->activity = pay_activity_load($activity->paid);
        $this
          ->__construct($this->activity->data);
        $this->activity->action = $this->pay_form_action;

        // Effect a redirect to the direct payment gateway.
        if ($this->activity->action && $this->activity->action != 'pending') {
          unset($form_state['storage']);
          $form_state['rebuild'] = FALSE;
          $form_state['redirect'] = $this
            ->direct_request();
          break;
        }
      }
    }
  }
}