PHPackages                             ferotres/redsys-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. ferotres/redsys-bundle

ActiveSymfony-bundle[Payment Processing](/categories/payments)

ferotres/redsys-bundle
======================

The FerotresRedsysBundle adds support for manage payments in redsys platform for Symfony4.

v1.0.2(7y ago)4801[1 issues](https://github.com/ferotres/redsys-bundle/issues)MITPHPPHP ^7.1.3

Since Jan 6Pushed 7y agoCompare

[ Source](https://github.com/ferotres/redsys-bundle)[ Packagist](https://packagist.org/packages/ferotres/redsys-bundle)[ RSS](/packages/ferotres-redsys-bundle/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (7)Versions (4)Used By (0)

FerotresRedsysBundle Documentation
==================================

[](#ferotresredsysbundle-documentation)

The FerotresRedsysBundle adds support for manage payments in redsys platform for Symfony4.

**Features include**:

- Multi currency | Language
- Multi shops
- Create Payment
- Create Payment Authorization
- Confirm Payment Authorization
- Cancel Payment Authorization
- Payment response validators
- OpenSSL
- HMAC\_SHA256\_V1
- Unit tested

**Note:** This bundle does *not* provide entities for manage payments.

[![Build Status](https://camo.githubusercontent.com/be63e4807f39324bd7bc6bc12fce01097b78e8199dc0213db73092a48eab0262/68747470733a2f2f7472617669732d63692e6f72672f6665726f747265732f7265647379732d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ferotres/redsys-bundle) [![Latest Stable Version](https://camo.githubusercontent.com/3cbd412fcbb0379efc6d863c18ec2705924fac9b72ea23921a94207b90287c01/68747470733a2f2f706f7365722e707567782e6f72672f6665726f747265732f7265647379732d62756e646c652f762f737461626c65)](https://packagist.org/packages/ferotres/redsys-bundle) [![Total Downloads](https://camo.githubusercontent.com/831f3cbc46c5c690d8112260aa5c8283438fa2603a53c5a7a2bcf0dd0cccb415/68747470733a2f2f706f7365722e707567782e6f72672f6665726f747265732f7265647379732d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/ferotres/redsys-bundle) [![Latest Unstable Version](https://camo.githubusercontent.com/4002044162a60bccd67287a168019a5f88c85044e8565a4d5709112469ff8303/68747470733a2f2f706f7365722e707567782e6f72672f6665726f747265732f7265647379732d62756e646c652f762f756e737461626c65)](https://packagist.org/packages/ferotres/redsys-bundle) [![License](https://camo.githubusercontent.com/e2889056385a308b8001561e7d81ce8bad917a965d01ea24ebcf011e16501fde/68747470733a2f2f706f7365722e707567782e6f72672f6665726f747265732f7265647379732d62756e646c652f6c6963656e7365)](https://packagist.org/packages/ferotres/redsys-bundle)

Installation
------------

[](#installation)

**Download FerotresRedsysBundle**.

```
$ composer require ferotres/redsys-bundle
```

**Add routing resource**.

```
# config/routes/ferotres_redsys.yaml
_ferotres_redsys:
    resource: "@FerotresRedsysBundle/Resources/config/routes.xml"
```

**Configure the FerotresRedsysBundle**.

You can configure the bundle for each environment.

```
# config/packages/ferotres_redsys.yaml
ferotres_redsys:
    url: 'https://sis-t.redsys.es:25443/sis/realizarPago' # this is a test url
    shops:
        sample1:
           merchant_name: 'sample1'
           merchant_code: '45677897'
           success: 'payment-success' # route for payment succes redirection
           error:   'payment-serror'  # route for payment error redirection
           terminals: # One terminal is mandatory
              - { secret: 'sq7HjrUOBfKmC344354fvv0gJ7', ces: true,  num: 1, iso_currency: 'EUR' }
              - { secret: 'sq7Hvfrty676LgskD5srU870g7', ces: false, num: 2, iso_currency: 'EUR' }
              - { secret: 'sq7HjrUOBfKmC576ILyythU870', ces: false, num: 4, iso_currency: 'USD' }

        # Is posible add more shops, but almost one is needed.
```

Configuration
-------------

[](#configuration)

Terminal configuration (All params is mandatory)

- **secret**: is a key provided by redsys.
- **ces**: set to true if terminal is configured for secure payments.
- **num**: Is a terminal number provided by redsys.
- **iso\_currency**: ISO Currency code with 3 digits.

**Valid ISO Currencies**

- EUR: Euro
- USD: Dollar
- AUD: Australian Dollar
- GBP: Pound
- JPY: Yen
- CAD: Canada Dollar
- ARS: Peso Argentino
- INR: Rupia
- MXN: Peso Mexicano
- PEN: Sol Peruano
- CHF: Franco suizo
- BRL: Real Brasileño
- VEF: Bolivar Venezolano
- TRY: Lira Turca

Create Payment
--------------

[](#create-payment)

Transaction type 0

**Create a action method**.

```
class PaymentController extends AbstractController
{

    /** @var RedsysRedirection  */
    private $redsysRedirection;

    /**
     * DefaultController constructor.
     * @param RedsysRedirection $redsysRedirection
     */
    public function __construct(RedsysRedirection $redsysRedirection)
    {
        $this->redsysRedirection = $redsysRedirection;
    }

    public function pay(int $optionalIdOffer)
    {
        $paymentOrder = PaymentOrderBuilder::create()
            ->toApp('sample1')
            ->withAmount(1000)
            ->withCurrency('EUR')
            ->withLocale('ES')
            ->withPaymentHolder('Juan Alvarez')
            ->withDescription('Product Test description')
            ->withOrder('201901015001')
            // This params is used for success/error callbacks and notification response
            ->addUserParams(['optionalIdOffer' => $optionalIdOffer])
            // For use a secure terminal
            ->usingCes(true)
            ->build();

         /** @var RedsysOrder $redsysOrder */
         $redsysOrder = $this->redsysRedirection->createPayment($paymentOrder);

         return $this->render('Acme/pay.html.twig', ['redsysOrder' => $redsysOrder]);
    }

}
```

**Create a template for autosubmited form (This is a sample, the required part is include payment form)**

```
# templates/Acme/pay.html.twig

{% extends "Acme::layout.html.twig" %}

{% block body %}

     {{ include('@FerotresRedsys/pay-form.html.twig') }}

{% endblock %}

```

**Manage autosubmit of form in js.**

```
# assets/js/app.js
// this submit trigger the redirecton to redsys form for credit card
document.querySelector('#redsys_pay_form').submit();

```

Create Payment Authorization
----------------------------

[](#create-payment-authorization)

Is equals to payment only change the method executed. For use this payment method, the terminals must be allow transaction type **O**.

```
/** @var RedsysOrder $redsysOrder */
$redsysOrder = $this->redsysRedirection->createAuthorization($paymentOrder);
```

Create Payment Confirmation
---------------------------

[](#create-payment-confirmation)

Is similar to payment, all params must be the same as authorization. For use this payment method, the terminals must be allow transaction type **P**.

```
$paymentOrder = PaymentOrderBuilder::create()
    ->toApp('sample1')
    ->withAmount(1000)
    ->withCurrency('EUR')
    ->withLocale('ES')
    ->withPaymentHolder('Juan Alvarez')
    ->withDescription('Product Test description')
    ->withOrder('201901015001')
    // For this transaction authCode is mandatory
    ->withAuthCode('236055')h
    // This params is used for success/error callbacks and notification response
    ->addUserParams(['optionalIdOffer' => $optionalIdOffer])
    // For use a secure terminal
    ->usingCes(true)
    ->build();
// The confirmAuthorization do a curl to redsys, template is not needed.
/** @var RedsysOrder $redsysOrder */
$redsysOrder = $this->redsysRedirection->confirmAuthorization($paymentOrder);
```

Create Payment Cancellation
---------------------------

[](#create-payment-cancellation)

Is similar to confirmation, all params must be the same as authorization. For use this payment method, the terminals must be allow transaction type **Q**.

```
// The cancelAuthorization do a curl to redsys, template is not needed.
/** @var RedsysOrder $redsysOrder */
$redsysOrder = $this->redsysRedirection->cancelAuthorization($paymentOrder);
```

Handle success and error callbacks
----------------------------------

[](#handle-success-and-error-callbacks)

```
class PaymentController extends AbstractController
{
    /**
    * with sample config, this is a payment-success route
    * $optionalIdOffer is passed to paymentOrder with addUserParams
    */
    public function success(int $optionalIdOffer)
    {
        // TODO
    }

    /**
     * with sample config, this is a payment-error route
     * $optionalIdOffer is passed to paymentOrder with addUserParams
     */
    public function error(int $optionalIdOffer)
    {
        // TODO
    }
}
```

Handle redsys notification response
-----------------------------------

[](#handle-redsys-notification-response)

For handle the notification you can use event listener or a eventSubscriber, in this case i use a event listener.

**Event Listener**

```
// src/EventListener/PaymentResponseHandler.php
class PaymentResponseHandler
{
    /**
     * @param RedsysResponseSuccessEvent $redsysResponseEvent
     */
    public function onPaymentSuccess(RedsysResponseSuccessEvent $redsysResponseEvent)
    {
        $redsysResponse = $redsysResponseEvent->redsysResponse();

        $order = $redsysResponse->order();
        $authCode = $redsysResponse->authCode();
        // This use __call magic method
        $optionalIdOffer = $redsysResponseEvent->getOptionalIdOffer()

        $valid = $redsysResponseEvent->isValidated();

        // TODO: Yout bussines logic

        // By default, If in this function something throw and exception, RedsysResponseFailedEvent will be triggered.

    }

    /**
     * @param RedsysResponseFailedEvent $responseFailedEvent
     */
    public function onPaymentError(RedsysResponseFailedEvent $responseFailedEvent)
    {
       $redsysResponse = $redsysResponseEvent->redsysResponse();

       // This use __call magic method
       $optionalIdOffer = $redsysResponseEvent->getOptionalIdOffer();

       $exception = $responseFailedEvent->exception();

       $valid = $redsysResponseEvent->isValidated();

       // TODO: Yout bussines logic
    }
}
```

**Config event Listener**

```
# config/services.yaml
app.payment_response_listener:
    class: App\EventListener\PaymentResponseHandler
    tags:
        - { name: kernel.event_listener, event: ferotres_redsys.redsys_response_success, method: onPaymentSuccess }
        - { name: kernel.event_listener, event: ferotres_redsys.redsys_response_failed, method: onPaymentError }
```

License
-------

[](#license)

This bundle is under the MIT license.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

3

Last Release

2731d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/24589816?v=4)[Toni](/maintainers/ferotres)[@ferotres](https://github.com/ferotres)

---

Top Contributors

[![ferotres](https://avatars.githubusercontent.com/u/24589816?v=4)](https://github.com/ferotres "ferotres (7 commits)")

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/ferotres-redsys-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/ferotres-redsys-bundle/health.svg)](https://phpackages.com/packages/ferotres-redsys-bundle)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
