Redsys PHP 2.0 with Redirection and REST Integration

16 May 2023

Today we are releasing version 2.0 of the redsys-php library to integrate your PHP application with the Redsys payment gateway.

The new version includes the following updates:

  • All the Redsys documented parameters are available.
  • Helper functions for creating Credential-On-File (token) operations.
  • REST integration type.

These updates are added to the existing functionalities, allowing you to integrate any of the Redsys features via REST or redirection methods.

With the new version of this library, creating a CoF operation request to obtain a card token and enable recurring payments, such as a subscription, is as simple as this example:

use Creagia\Redsys\Enums\Currency;
use Creagia\Redsys\Enums\TransactionType;
use Creagia\Redsys\RedsysClient;
use Creagia\Redsys\RedsysRequest;
use Creagia\Redsys\Support\RequestParameters;

$redsysClient = new RedsysClient(
    merchantCode: env('redsys.merchantCode'),
    secretKey: env('redsys.key'),
    terminal: env('redsys.terminal'),
    environment: \Creagia\Redsys\Enums\Environment::Test,

$redsysRequest = RedsysRequest::create(
    redsysClient: $redsysClient,
    new RequestParameters(
        amountInCents: 123_45,
        orderNumber: '22013100005',
        currency: Currency::EUR,
        transactionType: TransactionType::Autorizacion,
        merchantUrl: '',
        urlOk: '',
        urlKo: '',
    cofType: CofType::Recurring

echo $redsysRequest->getRedirectFormHtml();

Integration with Laravel

If your PHP application runs on Laravel, take a look at our package laravel-redsys, which makes easier the integration of this library with the framework.