Coder Social home page Coder Social logo

node-redsys-api's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-redsys-api's Issues

Using redsys with Node

Hi

I have just installed this module to connect to my VPO in my Meteor JS app but I am getting problems. In my server code I have created a new method called from the client. The code in the server looks like this:

`var redsys = new Redsys({
"merchant": {
"code": "MERCHANT_CODE",
"terminal": "1",
"titular": "TITULAR",
"name": "NAME",
"secret": "qwertyasdf0123456789"
},
"language": "auto",
"test": true
});

form_data = redsys.create_payment({
total: ORDER_TOTAL,
currency: "EUR",
order: "ORDER ID",
description: "ORDER DESCRIPTION",
data: "CART DATA",
transaction_type: 0,
redirect_urls: {
callback: "CALLBACK URL",
return_url: "OK URL",
cancel_url: "KO URL"
}
});`

I got an error from the server saying that Redsys is not defined. I guess I have to put and import somewhere to make it works but do not know where.

Neither I know where I should put the URL where the form is sent, https://sis-t.redsys.es:25443/sis/realizarPago

I hope someone can help me

Error International currencies operations

When the payment is made in international currencies gives error:

URIError: URI malformed
I20230421-11:26:58.465(2)? at decodeURIComponent ()
I20230421-11:26:58.465(2)? at Redsys.decodeMerchantParameters (.../node_modules/node-redsys-api/src/api-redsys.js:42:39)

This error ocurrs because the parameter Ds_Markup_DCC has the character '%'

Problem Generating Signature

Hi, I had some problems generating the signature, as it seems to be wrong.

I've compared the result of the Ds_Signature and Ds_MerchantParams with a PHP Redsys Api which was working correctly. Finally I found the problem is how the signature is generate, in particular in the 3Des encryption step.

In the PHP API the result of the encryption is cropped by a multiplier (I don't know why).

protected static function encrypt3DESOpenSSL($message, $key)
{
        $l = ceil(strlen($message) / 8) * 8;
        $message = $message.str_repeat("\0", $l - strlen($message));

        return substr(openssl_encrypt($message, 'des-ede3-cbc', $key, OPENSSL_RAW_DATA, "\0\0\0\0\0\0\0\0"), 0, $l);
}

Changing the 3Des encyption method in the node api finanly I get redsys working.

encrypt3DES(str, key) {
    const secretKey = Buffer.from(key, 'base64');
    const iv = Buffer.alloc(8, 0);
    const cipher = crypto.createCipheriv('des-ede3-cbc', secretKey, iv);
    cipher.setAutoPadding(false);
    const en_key = cipher.update(zeroPad(str, 8), 'utf8', 'binary') + cipher.final('binary');
    const l = Math.ceil(str.length / 8) * 8;
    //$message = $message.str_repeat("\0", $l - strlen($message));
    return Buffer.from(en_key.substr(0, l), 'binary').toString('base64');
}

Alguna manera de gestionar devoluciones

Hola buenas.

¿Se podría de alguna manera hacer una devolución usando este módulo?
Actualmente lo usamos para generar formularios de pago pero estaría geníal poder pasar parte de la operativa que tenemos que hacer en la web del banco a poder hacerse programaticamente. Así si pudieramos de alguna manera listar las operaciones realizadas y sus dato y poder por ejemplo seleccionar una de las operaciones y realizar una devolución podríamos integrar de manera total el pago web en nuestro sistema.

Fix to use redsys per API Rest

As it comes, it is not possible to consume REST API.
To solve this problem you have to make a small correction.

We have to replace:

decodeMerchantParameters(data) {
    const decodedData = JSON.parse(base64url.decode(data, 'utf8'));
    const res = {};
    Object.keys(decodedData).forEach((param) => {
      res[decodeURIComponent(param)] = decodeURIComponent(decodedData[param]);
    });
    return res;
  }

by

decodeMerchantParameters(data) {
     return this.parmsToObject(JSON.parse(base64url.decode(data, 'utf8')));
}

parmsToObject(data)
{
    const res = {};
    Object.keys(data).forEach((param) => {
    const decode = decodeURIComponent(data[param]);
    if (decode == "[object Object]")
	  res[decodeURIComponent(param)] = this.parmsToObject(data[param]);
    else
	  res[decodeURIComponent(param)] = decode;
    });
    return res;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.