Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

npm version GitHub version NPM


Redsys payment gateway compatible with ES6. It implements the new HMAC-SHA256 request signing procedure.

Install package

You can install the package with npm:

npm install --save redsys-polite

Import package using ES6:

import {RedsysBuilder, PaymentBuilder} from 'redsys-polite';

With node:

var RedsysBuilder = require('redsys-polite').RedsysBuilder;
var PaymentBuilder = require('redsys-polite').PaymentBuilder;

How to use it

Generate form parameters with the following code.

const commerce_code = "<your_commerce_code>";
const secret_code = "<your_secret_key>";

const redsys = new RedsysBuilder()
    .setTitular("Marc Pomar")

const payment = new PaymentBuilder()

const form_encoded_params = redsys.getFormData(payment);

Then form_encoded_params will have the required properties to generate a payment form. Use this object to

{ redsys_url: '',
  Ds_SignatureVersion: 'HMAC_SHA256_V1',
  Ds_MerchantParameters: '<encoded merchant parameters>',
  Ds_Signature: '<signature>' }

Form example using React:

  <form action={sign_payment.redsys_url} method="POST" ref="payform" >
    <input type="hidden" name="Ds_SignatureVersion" value={sign_payment.Ds_SignatureVersion}/>
    <input type="hidden" name="Ds_MerchantParameters" value={sign_payment.Ds_MerchantParameters}/>
    <input type="hidden" name="Ds_Signature" value={sign_payment.Ds_Signature}/>

Decode POST notification received from payment server

With initialized redsys object using RedsysBuilder call the method like this: var Ds_Signature = req.body.Ds_Signature; var Ds_MerchantParameters = req.body.Ds_MerchantParameters; redsys.decodeNotifiedMerchantParams(Ds_Signature, Ds_MerchantParameters) .then((decodedParams) => console.log(decodedParams)) .catch(e => console.log(e)); // Catch error for invalid signature

_decodeNotifiedMerchantParams returns a promise that is rejected if signature is not valid. Remember to catch it like the shown example.

Redsys server notification

Convert response DS_Code to a message string: import {codeToMessage} from 'redsys-polite'; var obj = codeToMessage('9915'); // Example Ds_Response code can be 9915, user canceled the payment; console.log(obj.message); // Prints text description for this code


Marc Pomar Torres


Use redsys payment platform wherever you want in an easy way



No packages published