fatoora

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2022 License: MIT Imports: 3 Imported by: 0

README

ZATCA FATOORA QR Code

A Go library to encode data for ZATCA FATOORA-compliant QR Codes.

Documentation

godoc

Example Code

import (
    "github.com/ibrasho/zatca-fatoora-qr-code"
    "github.com/skip2/go-qrcode"
)

func main() {
	qr := fatoora.NewQRData(
		sellerName,
		vatRegistrationNumber,
		invoiceTimestamp,
        strconv.FormatFloat(invoiceTotal, 'f', 2, 64),
        strconv.FormatFloat(vatTotal, 'f', 2, 64),
	)

    // return LTV-encoded []byte
    qr.LTV()

    // return base64-encoded string (use this to generate the QR)
    qr.Base64()

    // You can use "github.com/skip2/go-qrcode" to generate the actual image
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QRData

type QRData struct {
	Tags []Tag
}

func NewQRData

func NewQRData(sellerName, vatRegistrationNumber, invoiceTimestamp, invoiceTotal, vatTotal string) *QRData

func (*QRData) Base64

func (c *QRData) Base64() string

func (*QRData) Base64PNG added in v1.1.0

func (c *QRData) Base64PNG() (string, error)

func (*QRData) TLV

func (c *QRData) TLV() []byte

type Tag

type Tag struct {
	Type  TagType
	Value string
}

func NewInvoiceHashTag

func NewInvoiceHashTag(v string) Tag

func NewInvoiceTimestampTag

func NewInvoiceTimestampTag(v string) Tag

func NewInvoiceTotalTag

func NewInvoiceTotalTag(v string) Tag

func NewPublicKeyTag

func NewPublicKeyTag(v string) Tag

func NewSellerNameTag

func NewSellerNameTag(v string) Tag

func NewSignatureTag

func NewSignatureTag(v string) Tag

func NewStampSignatureTag

func NewStampSignatureTag(v string) Tag

func NewTag

func NewTag(tag TagType, value string) Tag

func NewVATRegistrationNumberTag

func NewVATRegistrationNumberTag(v string) Tag

func NewVATTotalTag

func NewVATTotalTag(v string) Tag

func (Tag) TLV

func (t Tag) TLV() []byte

type TagType

type TagType int
const (
	SellerName            TagType = 1
	VATRegistrationNumber TagType = 2
	InvoiceTimestamp      TagType = 3
	InvoiceTotal          TagType = 4
	VATTotal              TagType = 5
	InvoiceHash           TagType = 6
	Signature             TagType = 7
	PublicKey             TagType = 8
	StampSignature        TagType = 9
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL