An unofficial package in Golang to help developers to implement ZATCA (Fatoora) QR code easily which required for e-invoicing
✅ The hash result has been validated the same as the output from ZATCA's SDK as of 18th November 2021
go get github.com/Haraj-backend/zatca-sdk-go
package main
import (
"log"
"time"
"github.com/Haraj-backend/zatca-sdk-go/qrcode"
)
func main() {
// encode data using TLV method to get code hash
hash, err := qrcode.EncodeTLV(qrcode.Data{
SellerName: "Bobs Records",
SellerTaxNumber: "310122393500003",
Timestamp: time.Date(2022, 04, 25, 15, 30, 00, 00, time.UTC),
InvoiceTotal: 1000,
TotalVAT: 150,
})
if err != nil {
log.Fatalf("unable to encode TLV due: %v", err)
}
fmt.Println("hash data:", hash)
// decode hash using TLV method to get data
data, err := qrcode.DecodeTLV(hash)
if err != nil {
log.Fatalf("unable to decode TLV due: %v", err)
}
fmt.Printf("decoded hash: %s", data)
}
This package is only used for encoding QR Code data into base64 hash using TLV method. So it doesn't contain functionality to generate QR Code image.
If you want to generate the QR Code image, you could use another library such as skip2/go-qrcode. You could check examples/qrcode_generator for details.