You are here

function pay_method_gateway::execute in Pay 7

Same name and namespace in other branches
  1. 6 includes/handlers/pay_method_gateway.inc \pay_method_gateway::execute()
2 calls to pay_method_gateway::execute()
pay_method_gateway::authorize_action in includes/handlers/pay_method_gateway.inc
Effect an 'authorize' gateway transaction. If successful, the transaction state will be set to 'active' and the authorization history will be stored in our records.
pay_method_gateway::complete_action in includes/handlers/pay_method_gateway.inc
Complete a transaction. For new transactions, this means creating an AUTH_CAPTURE request. For existing ones, capture a preauthorization.

File

includes/handlers/pay_method_gateway.inc, line 130
The base class for credit card payment activities.

Class

pay_method_gateway
@file The base class for credit card payment activities.

Code

function execute($activity) {
  if ($request = $this
    ->gateway_request()) {
    $ret = drupal_http_request($this
      ->gateway_url(), array(
      'headers' => $this
        ->gateway_headers(),
      'method' => 'POST',
      'data' => $request,
    ));
    if (isset($ret->error)) {
      watchdog('payment', "Gateway Error: @err Payment NOT processed.", array(
        '@err' => $ret->error,
      ));
      drupal_set_message(t('We were unable to process your credit card payment. Please verify your card details and try again. If the problem persists, contact us to complete your order.'), 'error');
      $this->activity->data = (array) $ret;
      $this->activity->result = FALSE;
    }
    else {
      $this->activity->result = $this
        ->gateway_response($ret->data);
    }

    // Return TRUE or FALSE on success/failure.
    return $this->activity->result == 1;
  }
}