1.1.9 • Published 2 years ago

vietqr v1.1.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

VIETQR

npm.io

  • 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

ProjectSupport
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

OptionDescription
bankGet the bin field corresponding to the data returned in the banks API (VietQR.getTemplate() or API Bank)
accountNameBank account name
accountNumberBank account number
amountAmount of money
memoMoney transfer content
templateType of template returned to the user
clientIDapi_key is provided when registering an account at http://my.vietqr.io/
apiKeyclient_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

1.1.1

2 years ago

1.0.2

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.0.9

2 years ago

1.1.7

2 years ago

1.0.8

2 years ago

1.1.6

2 years ago

1.0.7

2 years ago

1.1.5

2 years ago

1.0.6

2 years ago

1.1.4

2 years ago

1.0.5

2 years ago

1.1.3

2 years ago

1.0.4

2 years ago

1.1.2

2 years ago

1.0.3

2 years ago

0.0.1

3 years ago