Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Messages Laravel Package

redsys/messages

Redsys Messages is a PHP library for building and validating Redsys payment gateway messages, including signed requests and notifications. It helps Laravel/PHP apps handle merchant parameters and HMAC SHA-256 signatures when integrating Redsys payments.

View on GitHub
Deep Wiki
Context7

Getting Started

composer require eusonlito/redsys-messages

Then open src/ before anything else — the whole package is one small class (effectively a static lookup table) with two maps:

  • Ds_Response codes — the numeric business result Redsys returns in the notification (ranges like 0000–0099 = authorised, 0101+ = denied/error, 0900+ = refund/confirmation operations).
  • Ds_ErrorCode codes — the SIS0001…SIS0999 technical error identifiers.

Verify the exact class/method in the file (older releases used a global RedsysMessages; newer ones autoload a namespaced class). Typical first use case: you already receive the Redsys server-to-server notification (Ds_Response, Ds_ErrorCode, Ds_Order, …) and you want a human-readable Spanish message instead of a raw code.

use Redsys\Messages; // confirm the class name in src/

$code    = $_POST['Ds_Response'] ?? null;
$message = Messages::get((string) $code); // or getMessage()/getResponse()

This package only maps codes to text. It does not sign requests, verify signatures, or build the TPV form — pair it with a Redsys client (e.g. eusonlito/redsys) for that.

Implementation Patterns

Split UI text from log text. Ds_Response is what the customer should see ("Pago autorizado", "Tarjeta caducada"…). Ds_ErrorCode is technical and belongs in your logs/alerting — showing SIS0051 to a shopper is noise.

Wrap it in a result object. Don't scatter lookups across controllers:

final class PaymentResult
{
    public function __construct(
        public string $code,
        public string $message,
        public ?string $errorCode,
        public bool $ok,
    ) {}

    public static function fromNotification(array $p): self
    {
        $code = (string) ($p['Ds_Response'] ?? '');
        return new self(
            code: $code,
            message: Messages::get($code) ?? "Pago no completado (código {$code})",
            errorCode: $p['Ds_ErrorCode'] ?? null,
            ok: ctype_digit($code) && (int) $code < 100,
        );
    }
}

Decide success from the code, never from the message string. Message wording is free to change; (int) $Ds_Response < 100 is the Redsys contract.

Two-step notification handler:

  1. Validate the signature (Ds_Signature / HMAC-SHA256 with your Ds_MerchantParameters) — outside this package.
  2. Persist the order with code, error_code, and the resolved message; render the result page from the stored values, not by re-calling the package on each request.

Localisation. The bundled strings are Spanish. If you ship other locales, keep the Redsys code as the translation key and use the package text as the es value/fallback — don't try to translate the returned string.

Custom wording per brand. Merge your overrides on top of the package array rather than editing vendor files (see Gotchas).

Gotchas and Tips

  • Leading zeros are significant. Ds_Response arrives as a string like "0000". Cast to int before lookup and you'll miss the key or resolve the wrong entry. Always normalise to string first.

  • Handle unknown codes. Redsys adds codes over time, and this package's last release is 2021-12-30 (10 stars, no dependents) — expect gaps. Always provide a fallback message and log the raw code so support can act on it.

  • Ds_ErrorCode is optional. It only appears on some failures. A missing error code is normal — don't treat it as an error itself.

  • 0900+ codes are not "payment OK". They cover refunds, confirmations and cancellations; if your UI blindly says "Pago correcto" for the 0000–0099 band you're fine, but don't assume every "positive" code is a sale.

  • No config, facade, translations or service provider. It's a plain array lookup; nothing to cache, nothing to publish. If you were expecting a Laravel package, you'll write the binding yourself.

  • Extension point: subclass/wrap the class and merge your own map, so you get package updates without forking:

    final class AppMessages extends Messages
    {
        public const OVERRIDES = [
            '0184' => 'Titular de la tarjeta no autenticado correctamente',
        ];
        public static function get(string $code): ?string
        {
            return self::OVERRIDES[$code] ?? parent::get($code);
        }
    }
    
  • Security reminder: never trust Ds_Response before the signature check passes. This package will happily translate a forged notification into a convincing "Pago autorizado".

  • Debugging tip: dump Messages::get($code) against a handful of known codes (0000, 0101, 0900) after install to confirm the class name and method you actually got — the API is tiny but not documented in the README.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource