GoLang Library to generate QR Code payload for PromptPay inspired from dtinth/promptpay-qr
GoLang 1.12.x
go get -u github.com/kazekim/promptpay-qr-go
package main
import (
"bytes"
"fmt"
"github.com/kazekim/promptpay-qr-go"
"image"
"image/png"
"os"
)
func main() {
// Image is return in []byte. You should convert to image by yourself.
qr, err := promptpayqr.QRForTargetWithAmount("0899999999","500" )
if err != nil {
panic(err)
}
// I give an example of image convert here.
byteToImage(*qr)
}
func byteToImage(imgByte []byte) {
img, _, _ := image.Decode(bytes.NewReader(imgByte))
//save the imgByte to file
out, err := os.Create("./QRImg.png")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
err = png.Encode(out, img)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
Please use this function
qr, err := promptpayqr.QRWithPromptpayLogoForTargetWithAmount("0899999999","500" )
Everyone can contribute it. Feel free to improve it and make it better.
The MIT License (MIT)