Today, we release a package called creagia/laravel-redsys and a library called creagia/redsys-php. Not only a new Laravel package but also a PHP library to better integrate your app with the Redsys payments platform. The lead payment processor in Spain.
When working for our clients, we often find ourselves integrating applications with services like Stripe or Paddle that have modern libraries and packages for PHP and Laravel that allow us to do it quickly and elegantly. But when we need to do it with a Spanish bank, we do not have this modern and updated code to work with the standards we are used to.
This is why we created this package for Laravel loaded with some extra features. More details below. Along with this, we publish the PHP library that powers this (https://github.com/creagia/laravel-redsys) package internally.
Laravel Redsys is a package that tries to make it easy to integrate your Laravel app with this payment platform. It's loaded with features like an easier relationship with your Eloquent models, automatic management of Redsys notifications, default confirmation views, and a helpful local payment gateway to test in your local environment.
You can read in the documentation how easily it is integrated with your Eloquent models and how Redsys notification is automatically handled once the client has authorised payment.
One of our favourites features is the local payment gateway. It is a fake gateway that only runs on your local development environment and allows you to simulate a Redsys response without using its test or production environment, which requires you to expose your site on the internet.
You can find many other libraries and packages that allow you to integrate with Redsys, yet we decided to create a new one. In fact, we have been using eusonlito/redsys-TPV for a long time in our projects (thank you!). Still, while PHP is going forward with new advanced features that allow us to write more modern, secure and robust code, we found that existing solutions had not been modernised in the same way.
If you read the creagia/redsys-php documentation and browse the code, you'll see that we used enums, named properties, DTOs and other strategies typical of modern PHP.
While developing the Laravel package, we found that we also needed all this in the Redsys library, so it led us to this development.
With the payment creation example, you can see what we mean by this:
use Creagia\Redsys\Enums\Currency; use Creagia\Redsys\Enums\TransactionType; use Creagia\Redsys\RedsysClient; use Creagia\Redsys\RedsysRequest; $redsysClient = new RedsysClient( merchantCode: env('redsys.merchantCode'), secretKey: env('redsys.key'), terminal: env('redsys.terminal'), environment: \Creagia\Redsys\Enums\Environment::Test, ); $redsysRequest = new RedsysRequest($redsysClient); $redsysRequest->createPaymentRequest( amount: 123.45, orderNumber: '22013100005', currency: Currency::EUR, transactionType: TransactionType::Autorizacion, );
These two releases result from developments adapted to our needs and use cases, but we hope they can also serve many other developers.
We've limited the scope to simple redirect payments for these first releases, but we'd like to consider all the other payments types that Redsys allows in future releases. Feel free to collaborate, discuss or request any new features on Github.