You are here

function commerce_sermepa_process_callback in Commerce sermepa 7

Process callback information from Sermepa.

This can either be through a redirect after payment, or a Direct HTTP server-to-server request.

Parameters

commerce_order $order: The order object.

array $payment_method: The payment method array.

Return value

boolean TRUE if is valid, otherwise FALSE.

1 call to commerce_sermepa_process_callback()
commerce_sermepa_redirect_form_validate in ./commerce_sermepa.module
Implements hook_redirect_form_validate().

File

./commerce_sermepa.module, line 480
Provides a payment method for Drupal Commerce using Sermepa/Redsys gateway.

Code

function commerce_sermepa_process_callback($order, $payment_method) {

  // Create a sermepa instance.
  if (!($gateway = commerce_sermepa_library_initialize($payment_method['settings']))) {
    return FALSE;
  }

  // Get response data.
  if (!($feedback = $gateway
    ->getFeedback())) {
    watchdog('commerce_sermepa', "Bad feedback response data.", array(), WATCHDOG_WARNING);
    return FALSE;
  }

  // Validate feedback values.
  if (!$gateway
    ->validSignatures($feedback)) {
    watchdog('commerce_sermepa', "Bad feedback response, signatures don't match.", array(), WATCHDOG_WARNING);
    return FALSE;
  }
  $parameters = $gateway
    ->decodeMerchantParameters($feedback['Ds_MerchantParameters']);
  commerce_sermepa_process_transaction($order, $payment_method, $parameters);
  return TRUE;
}