payway-sdk
Version:
Payway SDK NODEJS ===============
97 lines (93 loc) • 3.44 kB
JavaScript
module.exports = {
paymentData: function(args) {
this.getJSON = function() {
dataCompare = {
site_transaction_id: '',
token: '',
// user_id: '',
payment_method_id: '',
bin: '',
amount: '',
currency: '',
installments: '',
description:'',
payment_type: '',
sub_payments: ''
}
Object.keys(dataCompare).map(function(objectKey, value) {
if(objectKey in args) {
}else{
console.log("Error: el campo requerido "+objectKey+" no está definido o es incorrecto.");
return "Error: el campo requerido "+objectKey+" no está definido o es incorrecto.";
}
});
final = {
data: {
site_transaction_id: args.site_transaction_id,
token: args.token,
user_id: args.user_id,
payment_method_id: args.payment_method_id,
bin: args.bin,
amount: args.amount,
currency: args.currency,
installments: args.installments,
description: args.description,
payment_type: args.payment_type,
sub_payments: args.sub_payments,
fraud_detection: args.fraud_detection
},
headers: {
//apiKey: '566f2c897b5e4bfaa0ec2452f5d67f13', //Va una apikey, la publica o la privada según el caso
apiKey: args.apiKey,
'Content-Type': args['Content-Type']
}
};
if ("customer" in args) {
final.data.customer = args.customer;
}
return final;
}
this.setCustomer = function(c) {
args.customer = c;
}
this.getSiteTransactionId = function() {
return args.site_transaction_id;
};
this.getToken = function() {
return args.token;
};
this.getUserId = function() {
return args.userId;
};
this.getPaymentMethodId = function() {
return args.payment_method_id;
};
this.getBin = function() {
return args.bin;
};
this.getAmount = function() {
return args.amount;
};
this.getCurrency = function() {
return args.currency;
};
this.getInstallments = function() {
return args.installments;
};
this.getDescription = function() {
return args.description;
};
this.getPaymentType = function() {
return args.payment_type;
};
this.getSubPayments = function() {
return args.sub_payments;
};
this.getApiKey = function() {
return args.apiKey;
};
this.getContentType = function() {
return args['Content-Type'];
};
}
}