-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpagofacil.js
33 lines (28 loc) · 1009 Bytes
/
pagofacil.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var request = require('request');
var PagoFacil = function() {};
PagoFacil.prototype.API_BASE = 'https://www.pagofacil.net/st/public/Wsrtransaccion/index/format/json';
PagoFacil.prototype.checkout = function(params, callback) {
params['idServicio'] = 3;
params['noMail'] = true;
params['divisa'] = 'USD';
data = {
"jsonrpc": "2.0",
"method": "transaccion",
"data": params,
"id": params["id"]
};
request.post(this.API_BASE, {
form: data,
json: true
}, function(error, response, body) {
if (error != null) return error;
var error = null;
if (body.WebServices_Transacciones.transaccion.hasOwnProperty("error")) {
error = body.WebServices_Transacciones.transaccion.error;
delete body.WebServices_Transacciones.transaccion["error"];
}
response = body.WebServices_Transacciones.transaccion;
callback(error, response);
});
};
module.exports = new PagoFacil();