Developer Portal

PrestaShop Redsys Hooks 18 hooks

Hooks to customize payment processing, token management, and payment capabilities in Redsys for PrestaShop.

PrestaShop 8+ · PHP 8.1+ REST API reference View plugin
0 hooks shown

Payment flow 3

actionRedsysBeforePaymentAction

Fires immediately before the module prepares the Redsys parameters and builds the payment form, after the cart and customer have been validated. Use it to run pre-payment logic such as fraud checks, logging, or last-minute cart adjustments.

This hook is dispatched from two controllers. The Bizum controller adds a bizum_phone key.

Source: - controllers/front/payment.php:105 - controllers/front/bizumpayment.php:261 (adds bizum_phone)

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionRedsysBeforePayment');
}

public function hookActionRedsysBeforePayment(array $params)
{
    /** @var Cart $cart */
    $cart = $params['cart'];
    /** @var Customer $customer */
    $customer = $params['customer'];
    $gateway = $params['gateway'];

    // Bizum context exposes the phone number.
    if ($gateway === 'bizum' && isset($params['bizum_phone'])) {
        PrestaShopLogger::addLog(
            'Bizum payment starting for ' . $params['bizum_phone']
        );
    }

    PrestaShopLogger::addLog(sprintf(
        'Redsys payment starting: cart %d, customer %d, gateway %s',
        $cart->id,
        $customer->id,
        $gateway
    ));
}
actionRedsysModifyParametersAction

Fires after the module has assembled the DS_MERCHANT_* parameter array but before it is signed and sent to Redsys. Use it to add, override, or remove gateway parameters (for example to inject a custom DS_MERCHANT_* field, change the merchant data, or adjust 3DS values).

The module reads the chained return value: if a listener returns an array containing a params key, that array replaces the parameters used for the transaction.

This hook is dispatched from two controllers. The Bizum controller adds a gateway key.

Source: - controllers/front/payment.php:289 - controllers/front/bizumpayment.php:935 (adds gateway)

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionRedsysModifyParameters');
}

public function hookActionRedsysModifyParameters(array $params)
{
    $merchantParams = $params['params'];

    // Add or override a Redsys merchant parameter.
    $merchantParams['DS_MERCHANT_MERCHANTDATA'] = 'custom-ref-' . $params['cart']->id;

    // Returning the params key replaces the transaction parameters.
    return ['params' => $merchantParams];
}
actionRedsysAfterPaymentAction

Fires after a successful in-site (InSite) payment has been processed and the order created, and after any card token has been saved. Use it for post-payment side effects such as syncing with an ERP, granting rewards, or sending custom notifications.

Source: - controllers/front/insitepayment.php:652

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionRedsysAfterPayment');
}

public function hookActionRedsysAfterPayment(array $params)
{
    $orderId = (int) $params['order_id'];
    $dsOrder = $params['ds_order'];

    PrestaShopLogger::addLog(sprintf(
        'Redsys InSite payment completed: order %d, Ds_Order %s',
        $orderId,
        $dsOrder
    ));
}

IPN / notifications 4

actionRedsysBeforeIPNProcessAction

Fires inside the IPN front controller after the incoming merchant parameters and signature have been validated for presence, but before the IPN payload is processed. Use it to log, audit, or inspect raw IPN data before the module acts on it.

Source: - controllers/front/ipn.php:349

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionRedsysBeforeIPNProcess');
}

public function hookActionRedsysBeforeIPNProcess(array $params)
{
    PrestaShopLogger::addLog(
        'Incoming Redsys IPN, signature length: ' . strlen($params['signature'])
    );
}
actionRedsysAfterIPNProcessAction

Fires after the IPN payload has been processed successfully (before the success response is returned to Redsys). Use it to react to the processing outcome, for example to trigger downstream fulfilment once an order is confirmed.

Source: - controllers/front/ipn.php:359

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionRedsysAfterIPNProcess');
}

public function hookActionRedsysAfterIPNProcess(array $params)
{
    if (!empty($params['order_id'])) {
        PrestaShopLogger::addLog(
            'Redsys IPN processed for order ' . (int) $params['order_id']
        );
    }
}
actionRedsysPaymentSuccessAction

Fires when a payment is confirmed successful during IPN processing and the order has been validated. Use it to perform business logic that depends on a confirmed, paid order.

Source: - controllers/front/ipn.php:865

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionRedsysPaymentSuccess');
}

public function hookActionRedsysPaymentSuccess(array $params)
{
    $orderId = (int) $params['order_id'];
    $authCode = $params['response']['Ds_AuthorisationCode'] ?? null;

    PrestaShopLogger::addLog(sprintf(
        'Redsys payment success: order %d, auth code %s',
        $orderId,
        (string) $authCode
    ));
}
actionRedsysPaymentErrorAction

Fires when a payment fails during IPN processing, after any pending order has been cancelled and the failed transaction recorded. Use it for failed-payment handling such as alerting, retry logic, or analytics.

Source: - controllers/front/ipn.php:996

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionRedsysPaymentError');
}

public function hookActionRedsysPaymentError(array $params)
{
    PrestaShopLogger::addLog(sprintf(
        'Redsys payment error %s: %s (cart %d)',
        $params['error_code'],
        $params['error_message'],
        (int) $params['cart']->id
    ), 3);
}

Parameter & order-number modifiers 1

actionRedsysModifyOrderNumberAction

Fires when the module generates the 12-character Redsys order number, after the module has built and sanitized it (including the protection that prevents numbers from starting with 000, which is reserved for "add payment method" transactions). This is the PrestaShop equivalent of the WordPress order-number filter. Use it to enforce a custom numbering scheme.

The module reads the chained return values: the first listener that returns a non-empty order_number wins. The returned value is then re-validated through the reserved-prefix protection before use.

Source: - src/Service/RedsysOrderNumberService.php:78

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionRedsysModifyOrderNumber');
}

public function hookActionRedsysModifyOrderNumber(array $params)
{
    // Build a custom 12-char number prefixed per gateway.
    $prefix = $params['gateway'] === 'bizum' ? 'BZ' : 'RS';
    $custom = $prefix . str_pad((string) $params['cart_id'], 10, '0', STR_PAD_LEFT);

    return ['order_number' => substr($custom, 0, 12)];
}

Tokenization 1

actionRedsysTokenCreatedAction

Fires after a card token (merchant identifier) has been stored for a customer following a successful tokenized payment. Use it to mirror the token in an external vault, send a "card saved" notification, or update a CRM.

Source: - controllers/front/insitepayment.php:785

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionRedsysTokenCreated');
}

public function hookActionRedsysTokenCreated(array $params)
{
    PrestaShopLogger::addLog(sprintf(
        'Redsys token created for customer %d (%s)',
        (int) $params['customer_id'],
        $params['card_brand']
    ));
}

Express checkout / Paygold 3

actionRedsysExpressCustomFieldsAction

Fires while the express-checkout flow collects additional custom fields from installed modules. Use it to inject extra data into the express-checkout payload (for example a loyalty number or a gift message).

The module merges every array returned by listeners into the additional-fields set: for each chained result that is an array, it is merged via array_merge.

Source: - src/Service/ExpressCustomFieldsService.php:553

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionRedsysExpressCustomFields');
}

public function hookActionRedsysExpressCustomFields(array $params)
{
    $fields = [];

    if (!empty($params['customer_id'])) {
        $fields['loyalty_ref'] = 'LOY-' . (int) $params['customer_id'];
    }

    // The returned array is merged into the express-checkout fields.
    return $fields;
}
actionRedsysExpressOrderCreatedAction

Fires after an order has been successfully created through the express-checkout flow. Use it for post-order side effects specific to express checkout (such as tagging the order or notifying fulfilment).

Source: - src/Service/ExpressCheckoutService.php:1316

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionRedsysExpressOrderCreated');
}

public function hookActionRedsysExpressOrderCreated(array $params)
{
    /** @var Order $order */
    $order = $params['order'];

    PrestaShopLogger::addLog(sprintf(
        'Express order created: %s via %s (txn %s)',
        $order->reference,
        $params['payment_method'],
        $params['transaction_id']
    ));
}
actionPaygoldOrderPaidAction

Fires when an order paid through Paygold (a pay-by-link flow) has been marked as paid and the payment recorded against the order. Use it to extend Paygold post-payment behaviour.

Source: - src/Service/PaygoldService.php:944

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionPaygoldOrderPaid');
}

public function hookActionPaygoldOrderPaid(array $params)
{
    /** @var Order $order */
    $order = $params['order'];

    PrestaShopLogger::addLog(sprintf(
        'Paygold order %s paid: %.2f, auth %s',
        $order->reference,
        (float) $params['amount'],
        $params['auth_code']
    ));
}

Payment capabilities 5

actionRedsysGatewayAvailabilityAction

Fires at the end of building the list of Redsys payment options for the cart, just before that list is returned to PrestaShop's checkout. The payment_options array is passed by reference, so listeners can add, remove, or reorder payment options in place. This hook is not chained (null, true is not used); modification is done via the reference, not via the return value.

Source: - ps_redsys_gateway.php:1607

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionRedsysGatewayAvailability');
}

public function hookActionRedsysGatewayAvailability(array &$params)
{
    // Remove a Redsys option for carts under a threshold.
    if ($params['cart']->getOrderTotal() < 5.0) {
        foreach ($params['payment_options'] as $i => $option) {
            if (strpos($option->getModuleName() ?? '', 'redsys') !== false) {
                unset($params['payment_options'][$i]);
            }
        }
        $params['payment_options'] = array_values($params['payment_options']);
    }
}
actionCheckPaymentCapabilityAction

Fires when the capability registry checks whether a given gateway module supports a given capability. Use it to dynamically declare that a gateway supports a capability that is not in the static registry. If any listener returns true, the gateway is treated as supporting the capability.

Source: - src/Registry/CapabilityRegistry.php:182

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionCheckPaymentCapability');
}

public function hookActionCheckPaymentCapability(array $params)
{
    // Declare that our gateway supports recurring payments.
    if ($params['module_name'] === 'mygateway'
        && $params['capability'] === 'recurring'
    ) {
        return true;
    }

    return $params['default_supported'];
}
actionRegisterPaymentCapabilitiesAction

Fires once when the capability registry initializes, after it has loaded capabilities from the database. The registry instance itself is passed so listeners can register additional capabilities or gateway-capability mappings programmatically.

Source: - src/Registry/CapabilityRegistry.php:252

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionRegisterPaymentCapabilities');
}

public function hookActionRegisterPaymentCapabilities(array $params)
{
    $registry = $params['registry'];

    // Register additional capabilities/mappings on the registry instance.
    // (See CapabilityRegistry for the available registration methods.)
    if (method_exists($registry, 'registerGatewayCapability')) {
        $registry->registerGatewayCapability('mygateway', 'recurring');
    }
}
actionBeforeCapabilityFilterAction

Fires before the payment-options list is filtered by required cart capabilities (only when the cart actually has required capabilities). The payment_options array is passed by reference, so listeners can adjust the candidate set before filtering occurs.

Source: - src/Service/PaymentFilterService.php:76

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionBeforeCapabilityFilter');
}

public function hookActionBeforeCapabilityFilter(array &$params)
{
    PrestaShopLogger::addLog(
        'Capability filter starting; required: '
        . implode(',', $params['required_capabilities'])
    );

    // Optionally remove a module before filtering.
    unset($params['payment_options']['some_module']);
}
actionAfterCapabilityFilterAction

Fires after the payment-options list has been filtered by required cart capabilities. The filtered options are passed by reference as payment_options, and the list of removed modules is provided for inspection. Use it to re-add an option, log removals, or otherwise post-process the filtered set.

Source: - src/Service/PaymentFilterService.php:115

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionAfterCapabilityFilter');
}

public function hookActionAfterCapabilityFilter(array &$params)
{
    foreach ($params['removed_modules'] as $removed) {
        PrestaShopLogger::addLog(sprintf(
            'Module %s removed: missing capability %s',
            $removed['module'],
            $removed['missing_capability']
        ));
    }
}

Configuration 1

actionRedsysConfigSaveAction

Fires after the module's back-office configuration form has been saved (all configuration values persisted, Apple Pay certificates handled, tab visibility updated). Use it to react to configuration changes, for example to invalidate a cache or sync settings to an external system.

Source: - ps_redsys_gateway.php:5843

PHP
public function install()
{
    return parent::install()
        && $this->registerHook('actionRedsysConfigSave');
}

public function hookActionRedsysConfigSave(array $params)
{
    $module = $params['module'];

    PrestaShopLogger::addLog(
        'Redsys configuration saved (module ' . $module->name . ')'
    );
}

Get the full hooks library

Every action and filter shown here ships with Redsys for PrestaShop Premium.