vietqr

1.1.9 • Public • Published

VIETQR

  • Support draw QR code from data bank ( accountName, amount, memo,....) with many templates
  • Support create link URL from QR code

Table of Contents

Features

  • Support draw QR code from data bank ( accountName, amount, memo,....) with many templates
  • Support create link URL from QR code

Choose what you need

Project Support
VietQR - Running with DOM on CLIENT-SIDE: Browser(IE6+, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, etc.), Electron, NW.js, etc.
- Running without DOM on SERVER-SIDE: Save image to file(PNG/JPEG/Base64) or get data url text. NodeJS, Electron, NW.js, etc.
- A QRCode generator for React Native: Generate QRCode image or get base64 data url text.

Try It!

Try It!

Demo preview

Demo preview

Installation

Example

import {VietQR} from 'vietqr';


let vietQR = new VietQR({
    clientID: 'de8a0804-a76d-41e5-8ad6-31503ce7d5f4',
    apiKey: '17c29f09-4ea2-4417-b9c2-7f020d35de42',
});

// list banks are supported create QR code by Vietqr
vietQR.getBanks().then((banks)=>{console.log(banks)})
.catch((err)=>{});

// list templates are supported by Vietqr
vietQR.getTemplate().then((data)=>{console.log(data)})
.catch((err)=>{});


// create QR code from data
vietQR.genQRCodeBase64({
    bank: '970415',
    accountName: 'QUY VAC XIN PHONG CHONG COVID',
    accountNumber: '113366668888',
    amount: '79000',
    memo: 'Ung Ho Quy Vac Xin',
    template: 'compact'
}).then((data)=>{console.log(data)})
.catch((err)=>{});

VietQR API

Option Description
bank Get the bin field corresponding to the data returned in the banks API (VietQR.getTemplate() or API Bank)
accountName Bank account name
accountNumber Bank account number
amount Amount of money
memo Money transfer content
template Type of template returned to the user
clientID api_key is provided when registering an account at http://my.vietqr.io/
apiKey client_key is provided when registering an account at http://my.vietqr.io/

getTemplate()

vietQR.getTemplate().then((data)=>{console.log(data)})
.catch((err)=>{});

Response successfully

 {
  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/compact.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()

vietQR.getBanks().then((data)=>{console.log(data)})
.catch((err)=>{});

Response successfully

{
  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 link = vietQR.genQuickLink({
        bank: '970415',
        accountName: 'QUY VAC XIN PHONG CHONG COVID',
        accountNumber: '113366668888',
        amount: '79000',
        memo: 'Ung Ho Quy Vac Xin',
        template: 'compact', 
        media: '.jpg' 
    });
console.log(link);

genQRCodeBase64()

vietQR.genQRCodeBase64({
    bank: '970415',
    accountName: 'QUY VAC XIN PHONG CHONG COVID',
    accountNumber: '113366668888',
    amount: '79000',
    memo: 'Ung Ho Quy Vac Xin',
    template : 'qr_only'
}).then((data)=>{console.log(data)})
.catch((err)=>{});

Response successfully

{
    "code": "00",
    "desc": "Gen VietQR successful!",
    "data": {
        "acqId": "970415",
        "accountName": "QUY VAC XIN PHONG CHONG COVID",
        "qrDataURL": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOwAAADeCAYAAAA..."
    }
}

License

MIT License

Package Sidebar

Install

npm i vietqr

Weekly Downloads

204

Version

1.1.9

License

MIT

Unpacked Size

11.5 kB

Total Files

7

Last publish

Collaborators

  • diep
  • haonh