Static QRCode

Static QR codes are fixed, reusable codes that enable payments to be sent to a specific PIX key.

Create a static QRCode

To create a static QRCode, you can use the createStatic function.

import { createStatic } from "@pix.js/qrcode";
 
 
const static = createStatic({
  merchantCity: 'Sao Paulo',
  merchantName: 'Victor Mesquita',
  merchantAccountInfo: {
    key: '1234567890', // PIX key used to receive the payment
  },
})
 
console.log(static.brcode)
// >00020126420014br.gov.bcb.pix0111070598133900205teste52040000530398654041.005802BR5915Victor Mesquita6009Sao Paulo62140510123456789063049CE5

Parameters

PropTypeDefault
merchantAccountInfo
{ gui?: string | undefined; key: string; merchantAdditionalInfo?: string | undefined; fss?: string | undefined; }
-
value
number
-
merchantCategoryCode
string
-
transactionCurrency
string
-
countryCode
string
-
merchantName
string
-
merchantCity
string
-
additionalData
{ txId?: string | undefined; }
-
postalCode
string
-
unreservedTemplate
{ gui?: string | undefined; url?: string | undefined; }
-

Static QRCode methods

PropTypeDefault
toBase64
() => Promise<string>
-
toDataUrl
() => Promise<string>
-
type
PixQrCodeType
-
keyType
PixKeyType
-

Create a QRCode image

To create a QRCode image, you can use the toDataUrl method:

import { createStatic } from "@pix.js/qrcode";
 
const static = createStatic({
  merchantCity: 'Sao Paulo',
  merchantName: 'Victor Mesquita',
  merchantAccountInfo: {
    key: '1234567890', // PIX key used to receive the payment
  },
});
 
const dataUrl = await static.toBase64();
console.log(dataUrl)
// >data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=

Verify wheather a string is a static QRCode

Use the isStaticPix function to verify whether a string is a static QRCode:

import { isStaticPix } from "@pix.js/qrcode";
 
console.log(isStaticPix('00020126420014br.gov.bcb.pix0111070598133900205teste52040000530398654041.005802BR5915Victor Mesquita6009Sao Paulo62140510123456789063049CE55'))
// >true

On this page