Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
tests/testing.js
package-lock.json
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ var pse_info = {
last_name: "PAYCO",
email: "no-responder@payco.co",
country: "CO",
city: "Bogota",
cell_phone: "3010000001",
ip:"190.000.000.000", /*This is the client's IP, it is required */
url_response: "https://ejemplo.com/respuesta.html",
Expand Down Expand Up @@ -418,6 +419,8 @@ var cash_info = {
name: "testing",
last_name: "PAYCO",
email: "test@mailinator.com",
country: "CO",
city: "bogota",
cell_phone: "3010000001",
end_date: "2020-12-05",
ip:"190.000.000.000", /*This is the client's IP, it is required */
Expand Down Expand Up @@ -635,7 +638,16 @@ var body = {
value: "100",
tax: "0",
tax_base: "0",
method_confirmation: ""
method_confirmation: "GET",
url_response: "https://ejemplo.com/respuesta.html",
url_confirmation: "https://ejemplo.com/confirmacion",
extra1: "",
extra2: "",
extra3: "",
extra4: "",
extra5: "",
extra6: ""

}
epayco.daviplata.create(body)
.then(function(daviplata){
Expand Down Expand Up @@ -686,7 +698,13 @@ var body = {
ico: 0,
tax_base: 0,
url_confirmation: "",
method_confirmation: ""
method_confirmation: "",
extra1: "",
extra2: "",
extra3: "",
extra4: "",
extra5: "",
extra6: ""
}

epayco.safetypay.create(body)
Expand Down
4 changes: 2 additions & 2 deletions lib/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"EN": "[108] Error encrypting the data, please retry the operation"
},
"109": {
"ES": "[109] Método de pago en efectivo no válido, unicamnete soportados (efecty - baloto - gana)",
"EN": "[109] Unsupported payment method, we only support (efecty - baloto - gana)"
"ES": "[109] Método de pago en efectivo no válido, unicamnete soportados efecty, gana, redservi, puntored, sured",
"EN": "[109] Unsupported payment method, we only support efecty, gana, redservi, puntored, sured"
}
}
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Module dependencies
*/

var debug = require('debug')('epayco:api');
//var debug = require('debug')('epayco:api');


/**
Expand Down
40 changes: 16 additions & 24 deletions lib/resources/cash.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,23 @@ util.inherits(cash, Resource);
* @param {Object} options
* @api public
*/
cash.prototype.create = function(type, options) {
var url;
switch (type) {
case "efecty":
url = "/restpagos/v2/efectivo/efecty";
break;
case "baloto":
url = "/restpagos/v2/efectivo/baloto";
break;
case "gana":
url = "/restpagos/v2/efectivo/gana";
break;
case "redservi":
url = "/restpagos/v2/efectivo/redservi";
break;
case "puntored":
url = "/restpagos/v2/efectivo/puntored";
break;
case "sured":
url = "/restpagos/v2/efectivo/sured";
break;
default:
throw new EpaycoError(this._epayco.lang, 109);
cash.prototype.create = async function(type, options) {
medio = type.toLowerCase();
if(medio == "baloto"){
throw new EpaycoError(this._epayco.lang, 109);
}
return this.request('post', url, options, sw = true, cashData = true);
var methods_payment = await this.request('get', '/payment/cash/entities', [], false, false, false, true);

if(!methods_payment.data || !Array.isArray(methods_payment.data) || methods_payment.data.length == 0){
throw new EpaycoError(this._epayco.lang, 106);
}
var entities = methods_payment.data.map(function(item){
return item.name.toLowerCase().replace(" ", "");
})
if(!entities.includes(medio)){
throw new EpaycoError(this._epayco.lang, 109);
}
return this.request('post', "/restpagos/v2/efectivo/"+medio, options, sw = true, cashData = true);
};

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/resources/customers.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ customers.prototype.create = function(options) {
* @api public
*/
customers.prototype.get = function(uid) {
return this.request('get', "/payment/v1/customer/" + this._epayco.apiKey + "/" + uid + "/", {}, sw = false);
return this.request('get', "/payment/v1/customer/" + this._epayco.apiKey + "/" + uid, {}, sw = false);
};

/**
* List Customer
* @api public
*/
customers.prototype.list = function() {
return this.request('get', "/payment/v1/customers/" + this._epayco.apiKey + "/", {}, sw = false);
return this.request('get', "/payment/v1/customers/" + this._epayco.apiKey, {}, sw = false);
};

/**
Expand Down
1 change: 0 additions & 1 deletion lib/resources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ Resource.prototype.request = async function (method, url, data, sw, cashData, ca
'Authorization': token_bearer
}
};

var send = await sendData(options, data)

return send;
Expand Down
4 changes: 2 additions & 2 deletions lib/resources/plans.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ plans.prototype.create = function(options) {
* @api public
*/
plans.prototype.get = function(uid) {
return this.request('get', "/recurring/v1/plan/" + this._epayco.apiKey + "/" + uid + "/", {}, sw = false);
return this.request('get', "/recurring/v1/plan/" + this._epayco.apiKey + "/" + uid, {}, sw = false);
};

/**
* List Plans
* @api public
*/
plans.prototype.list = function() {
return this.request('get', "/recurring/v1/plans/" + this._epayco.apiKey + "/", {}, sw = false);
return this.request('get', "/recurring/v1/plans/" + this._epayco.apiKey, {}, sw = false);
};

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/resources/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ subscriptions.prototype.create = function(options) {
* @api public
*/
subscriptions.prototype.get = function(uid) {
return this.request('get', "/recurring/v1/subscription/" + uid + "/" + this._epayco.apiKey + "/", {}, sw = false);
return this.request('get', "/recurring/v1/subscription/" + uid + "/" + this._epayco.apiKey, {}, sw = false);
};

/**
* List Subscriptions
* @api public
*/
subscriptions.prototype.list = function() {
return this.request('get', "/recurring/v1/subscriptions/" + this._epayco.apiKey + "/", {}, sw = false);
return this.request('get', "/recurring/v1/subscriptions/" + this._epayco.apiKey, {}, sw = false);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "epayco-sdk-node",
"version": "1.1.1",
"version": "1.2.1",
"description": "Epayco API client for node.js",
"main": "lib/index.js",
"scripts": {
Expand Down