draw-vietqr
v2.0.2
Published
npm draw vietqr
Downloads
3
Readme
VIETQR
made by hieunt0303
Table of Contents
Features
- Support draw QR code from data bank ( accountName, amount, memo,....) with many templates
- Support create link URL from QR code
Installing
Using npm :
npm i draw-vietqr
Example
import {VietQRClient} from 'draw-vietqr';
let VietQR = new VietQRClient({
x_api_key: '1',
x_client_key: '1',
})
// list banks are supported create QR code by Vietqr
let banks = await VietQR.getBanks()
// list templates are supported by Vietqr
let templates = await VietQR.getTemplate()
// create QR code from data v1
let qrCode = await VietQR.genQRCodeSyncV1({
bank: '970415',
accountName: 'QUY VAC XIN PHONG CHONG COVID',
accountNumber: '113366668888',
amount: '79000',
memo: 'Ung Ho Quy Vac Xin',
})
// create QR code from data v2
let qrCode = await VietQR.genQRCodeSyncV2({
bank: '970415',
accountName: 'QUY VAC XIN PHONG CHONG COVID',
accountNumber: '113366668888',
amount: '79000',
memo: 'Ung Ho Quy Vac Xin',
})
Vietqr API
getTemplate()
let templates = await VietQR.getTemplate()
JSON res
{
code: '00',
desc: 'success',
data: [
{
name: 'QR Only',
template: 'qr_only',
demo: 'https://api.vietqr.io/Vietinbank/113366668888/790000/Gop%20Quy/qr_only.jpg?accountName=Quy%20Vacxin%20Covid'
},
{
name: 'Compact',
template: 'compact',
demo: 'https://api.vietqr.io/Vietinbank/113366668888/790000/Gop%20Quy/vietqr_net_2.jpg?accountName=Quy%20Vacxin%20Covid'
},
{
name: 'Compact 2',
template: 'compact2',
demo: 'https://api.vietqr.io/Vietinbank/113366668888/790000/Gop%20Quy/compact2.jpg?accountName=Quy%20Vacxin%20Covid'
}
]
}
getBanks()
let banks = await VietQR.getBanks()
JSON res
{
code: '00',
desc: 'Get Bank list successful! Total 52 banks',
data: [
{
id: 17,
name: 'Ngân hàng TMCP Công thương Việt Nam',
code: 'ICB',
bin: '970415',
isTransfer: 1,
short_name: 'VietinBank',
logo: 'https://api.vietqr.io/img/ICB.3d4d6760.png',
support: 3
},
...........
}
genQuickLink()
let quickLink = VietQR.genQuickLink({
bank: '970415',
accountName: 'QUY VAC XIN PHONG CHONG COVID',
accountNumber: '113366668888',
amount: '79000',
memo: 'Ung Ho Quy Vac Xin',
template: 'compact', //option
media: '.jpg' //option
})
genQRCodeSyncV1() / genQRCodeSyncV2()
let qrCode = await VietQR.genQRCodeSyncV1({
bank: '970415',
accountName: 'QUY VAC XIN PHONG CHONG COVID',
accountNumber: '113366668888',
amount: '79000',
memo: 'Ung Ho Quy Vac Xin',
format : 'qr_only' //option
})
let qrCode = await VietQR.genQRCodeSyncV2({
bank: '970415',
accountName: 'QUY VAC XIN PHONG CHONG COVID',
accountNumber: '113366668888',
amount: '79000',
memo: 'Ung Ho Quy Vac Xin',
template : 'qr_only' // option
})
JSON res
{
"code": "00",
"desc": "Gen VietQR successful!",
"data": {
"acqId": "970415",
"accountName": "QUY VAC XIN PHONG CHONG COVID",
"qrDataURL": "data:image/png;base64,QRCODE_BASE_64_HERE"
}
}
- Copy field qrDataURL paste on browser to looking image QR :