Skip to content
CakePHP plugin for Redsýs online TPV system
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Redsýs plugin for CakePHP

Build Status codecov

This plugin enables online payments using the Redsýs TPV service.


  • CakePHP 3.4


You can install this plugin into your CakePHP application using composer:

composer require berarma/cakephp-redsys


Load the component and configure:

$this->loadComponent('Berarma/Redsys.Redsys', [
    // Use '' for the real environment
    'url' => '', // Testing
    'secretKey' => 'QWERTYASDF0123456789',
    'defaults' => [
        'DS_MERCHANT_MERCHANTCODE' => '000000001',
        'DS_MERCHANT_CURRENCY' => '978',
        'DS_MERCHANT_TERMINAL' => '001',
        'DS_MERCHANT_URLOK' => '',
        'DS_MERCHANT_URLKO' => '',

This is a basic configuration example. The defaults array will be merged with any parameters passed in the requests. Please, read the Redsýs documentation to learn about all the optional parameters that can be used.

Load the helper:


Initiating a transaction in the Controller:

    'DS_MERCHANT_ORDER' => time(),
    'DS_MERCHANT_AMOUNT' => '100',

Rendering the form that sends the user to the TPV in the View:

<?php echo $this->Redsys->renderForm(['id' => 'redsys-form']); ?>
<?php echo $this->Html->scriptBlock('document.getElementById("redsys-form").submit();'); ?>

Getting the response in the Controller:

$response = $this->Redsys->response();

The parameters from the response can then be accessed with:


Case sensitivity of parameters

The specification states that parameter names should use upper case or a mixed style of CamelCase and underline characters. Since the mixed CamelCase/underline style is confusing to say the least, and having 2 different naming styles adds to the confusion, I've decided to use the upper case style everywhere. That means all parameter names feeded to this plugin are converted to upper case, it doesn't matter how they were.


This plugin is a work in progress. You should expect compatibility breaking changes.


This plugin is licensed under the GPL v2 license. Most common uses of this plugin won't constitute a derived work, thus, you may use it and include it in your app independently of the license you've choosen for your code as long as the plugin itself is still distributed with its original license. But using this plugin from another plugin that provides modified or improved functionality may constitute a derived work and thus require you to use the same license for your plugin.

You can’t perform that action at this time.