@togtokh.dev/monpay
Version:
monpay is a library for payment gateway.
41 lines (40 loc) • 1.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const axios_1 = require("axios");
const _1 = require("./");
const qs_1 = require("qs");
const TOKEN = async (host, body) => {
_1.default.host = _1.default.hosts[host];
try {
const data = (0, qs_1.stringify)({
client_id: body.client_id,
client_secret: body.client_secret,
grant_type: "client_credentials",
});
const res = await axios_1.default.post(`${_1.default.host}/v2/oauth/token`, data, {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
});
_1.default.token = res.data.access_token;
_1.default.config = {
id: body.id.toString(),
client_id: body.client_id,
client_secret: body.client_secret,
username: body.username,
password: body.password,
};
_1.default.branch.BranchLogin();
return {
success: true,
message: "success",
};
}
catch (error) {
return {
success: false,
message: "error",
};
}
};
exports.default = { TOKEN };