first commit
This commit is contained in:
40
lib/bp-pay-request.js
Normal file
40
lib/bp-pay-request.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const moment = require("moment");
|
||||
const soap = require("soap");
|
||||
const { TERMINALID, USERNAME, USERPASSWORD, MELLATWSDL } = require("./data");
|
||||
|
||||
function bpPayRequest(orderId, priceAmount, additionalText, callbackUrl) {
|
||||
const localDate = moment().format("YYYYMMDD");
|
||||
const localTime = moment().format("HHmmss");
|
||||
const args = {
|
||||
terminalId: TERMINALID,
|
||||
userName: USERNAME,
|
||||
userPassword: USERPASSWORD,
|
||||
orderId: orderId,
|
||||
amount: priceAmount,
|
||||
localDate: localDate,
|
||||
localTime: localTime,
|
||||
additionalData: additionalText,
|
||||
callBackUrl: callbackUrl,
|
||||
payerId: 0,
|
||||
};
|
||||
|
||||
var options = {
|
||||
overrideRootElement: {
|
||||
namespace: "ns1",
|
||||
},
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
soap.createClient(MELLATWSDL, options, (err, client) => {
|
||||
client.bpPayRequest(args, (err, result, body) => {
|
||||
if (err) {
|
||||
//console.log(err);
|
||||
reject(err);
|
||||
}
|
||||
return resolve(result);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { bpPayRequest };
|
||||
Reference in New Issue
Block a user