"All-in-one Golang for PromptPay & EMVCo QR Codes"
That No dependency required. So here we go!
go get github.com/mrwan200/promptparse-go
- Parse — PromptPay & EMVCo QR Code data strings into object
- Generate — QR Code data from pre-made templates (for example: PromptPay AnyID, PromptPay Bill Payment, TrueMoney, etc.)
- Manipulate — any values from parsed QR Code data (for example: transfer amount, account number) and encodes back into QR Code data
- Validate — checksum and data structure for known QR Code formats (for example: Slip Verify API Mini QR)
package main
import (
"log"
promptparse "github.com/mrwan200/promptparse-go"
)
func main() {
parsed := promptparse.Parse("000201010212293...", true, true)
if parsed == nil {
log.Println("Invalid payload.")
return
}
// Now get tag transfer ref
log.Println(parsed.GetTagValue("00", "")) // Result: YYYY/MM/DD HH:mm:ss 01
}
package main
import (
"log"
"github.com/mrwan200/promptparse-go/lib"
)
func main() {
// Example data
data := []lib.TLVTag{
lib.Tag("00", "01"),
lib.Tag("01", "11"),
}
// Set CRC Tag ID '63'
tag, err := lib.WithCRCTag(lib.Encode(data), "63")
if err != nil {
log.Println("Error when create CRC tag")
return
}
log.Println(tag) // Result: YYYY/MM/DD HH:mm:ss 00020101...
}
package main
import (
"log"
"github.com/mrwan200/promptparse-go/generator"
)
func main() {
log.Println(generator.BillPayment("1xxxxxxxxxxxx", 300, "INV12345", "", "")) // Result: YYYY/MM/DD HH:mm:ss 00020101021230490016...
}
package main
import (
"log"
promptparse "github.com/mrwan200/promptparse-go"
)
func main() {
slip := promptparse.SlipVerify("0041000600.....")
if slip == nil {
log.Println("Invalid slip verify")
return
}
log.Println(slip.SendingBank) // Result: YYYY/MM/DD HH:mm:ss 004
log.Println(slip.TransRef) // Result: YYYY/MM/DD HH:mm:ss 0141012...
}
package main
import (
"log"
promptparse "github.com/mrwan200/promptparse-go"
)
func main() {
bill := promptparse.ParseBarcode("|310109999999901\r...")
if bill.BillerID == "" {
log.Println("Invalid barcode.")
return
}
log.Println(bill.ToQRTag30()) // Reseult: YYYY/MM/DD HH:mm:ss 00020101021....
}
- phoomin2012/promptparse-php PromptParse port for PHP
This project is MIT licensed (see LICENSE)