node-fps-hk/example/index.js

27 lines
824 B
JavaScript
Raw Permalink Normal View History

2019-10-28 05:59:20 +00:00
var fps = require('node-fps-hk')
var qrimage = require('qr-image');
var http = require('http');
2024-09-24 05:09:14 +00:00
const server = http.createServer(function (req, res) {
if (req.url == '/') {
fps.setMerchantID("0000001");
fps.setBillNumber("0002");
fps.setStoreLabel("0003");
fps.setLoyaltyNumber("0004");
fps.setCustomerLabel("0005");
fps.setTerminalLabel("0006");
fps.setPurposeOfTransaction("0007");
fps.setMobileNumber("12345678");
fps.setTransactionAmount("5000");
fps.setReferenceLabel("HKFPS_TESTING");
var string = fps.generate();
var code = qrimage.image(string, { type: 'png' });
res.setHeader('Content-type', 'image/png'); //sent qr image to client side
code.pipe(res);
}
});
server.listen(8080, () => {
console.log('Server is running on http://localhost:8080');
});