You are here

function pay_method_direct::complete_action in Pay 6

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

Create a stub method to ensure that do_action('complete') is executed. If your subclass wants to change, store, or fixup data before it's sent to the gateway, do it by overriding this method.

The 'real' work will be done in the form_submit() function.

File

includes/handlers/pay_method_direct.inc, line 58
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 complete_action($values = array()) {
  $this
    ->set_direct_pending($values);

  // Look for an 'authorize' action in this activity's history.
  foreach ($this->activity
    ->history() as $previous) {

    // If there was a successful authorization, copy its details.
    if ($previous->action == 'authorize' && $previous->result) {
      $this->activity->identifier = $previous->identifier;
      $this->activity->data = $previous->data;
      $this->activity->total = $previous->total;
      $this->payment_type = $previous->payment_type;
      $this->activity->action = 'complete';
    }
  }
}