Skip to content

Rendering a QR Code

Omar Bahareth edited this page May 30, 2023 · 5 revisions

Assuming you've already constructed an invoice and have an instance of either invoice or ZATCA::Tags, you can render the QR Code like so:

# Either tags as ZATCA::Tags or a Hash works fine
ZATCA.render_qr_code(tags: tags)

# or 
ZATCA.render_qr_code(base64: invoice.qr_code)

# => data:image/png;base64,...
# Hint (Try pasting the above into your web browser's address bar)

If you'd like to customize the size of the QR Code you can manually use the generator like so:

# Tags must be ZATCA::Tags in this case
generator = ZATCA::QRCodeGenerator.new(tags: tags)

# or
generator = ZATCA::QRCodeGenerator.new(base64: invoice.qr_code)

generator.render(size: 512)