rm-api-sdk-erider
Version:
A NodeJS wrapper for some of the RESTful methods documented at doc.revenuemonster.my
33 lines • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var crypto = require("crypto");
var signature_1 = require("../signature");
function createWebPayment(accessToken, data) {
var nonceStr = crypto.randomBytes(32).toString('hex');
var timestamp = new Date().getTime().toString();
return this.openApiInstance({
url: '/payment/online',
method: 'post',
data: signature_1.sortObject(data),
headers: {
'Authorization': 'Bearer ' + accessToken,
'X-Timestamp': timestamp,
'X-Nonce-Str': nonceStr,
'X-Signature': 'sha256 ' + signature_1.generateSignature({
data: data,
requestUrl: this.openApiUrl + '/payment/online',
nonceStr: nonceStr,
signType: 'sha256',
method: 'post',
timestamp: timestamp,
}, this.privateKey)
}
})
.then(function (x) { return x.data; })
// .catch(err => console.error(err.response.data))
.catch(function (err) {
throw err.response.data;
});
}
exports.createWebPayment = createWebPayment;
//# sourceMappingURL=webPayment.js.map