Giter Club home page Giter Club logo

sgqr-go's Introduction

SGQR payload builder written in Go

VietQR specification

Data Objects Under the Root of a QR Code

Name ID Format Length Presence Comment
Payload Format Indicator "00" N "02" M Refer to Ref A.
Point of Initiation Method "01" N "02" O "11" for static, "22" for dynamic
Refer to Ref A.
Merchant Account Information "02"-"51" ans Each var. up to "99" M At least one Merchant Account Information data object shall be present.
Refer to Ref A.
Transaction Currency "53" N "03" M Fixed to "704"
Refer to Ref A.
Country Code "58" ans "02" M Fixed to "VN"
Refer to Ref A.
Additional Data Field Template "62" S var. up to "99" O Refer to Ref A.
CRC "63" ans "04" M Refer to Ref A.

Data Objects for Additional Data Field Template (ID "62")

Name ID Format Length Presence
Purpose of Transaction "08" ans var. up to "25" O

VietQR - Merchant Account Information (ID "38")

Data Object Input Characters Remarks
Merchant Account Information "3856" Floating ID "38". This ID is allocated for this QR only
Refer to Ref B.
- Global Unique Identifier
- Beneficiary Organization
* ACQ ID / BNB ID
* Merchant ID / Consumer ID
- Service Code
"0010A000000727"
"012600069704150112113366668888"


"0208QRIBFTTA"
Reversed domain

970415 - NAPAS BIN
113366668888
QRIBFTTA / QRIBFTTC

Sample code

package main

import (
	"fmt"

	"giautm.dev/sgqr"
	qrcode2 "github.com/lizebang/qrcode-terminal"
	"github.com/skip2/go-qrcode"
)

func main() {
	i := &sgqr.VietQRInput{
		AcqID:          "970415",
		AccountNo:      "113366668888",
		Amount:         79000,
		AdditionalInfo: "Ung Ho Quy Vac Xin",
	}

	payload, err := i.BuildPayload()
	if err != nil {
		panic(err)
	}
	fmt.Println("Data", payload)

	qrcode2.QRCode(payload, qrcode2.BrightWhite, qrcode2.NormalBlack, qrcode.Medium)
}

Performance

goos: darwin
goarch: amd64
pkg: giautm.dev/sgqr
cpu: Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
Benchmark_BuildPayload
Benchmark_BuildPayload-8   	 1558408	       771.8 ns/op	     594 B/op	       8 allocs/op
PASS
ok  	giautm.dev/sgqr	2.447s

References

sgqr-go's People

Contributors

giautm avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.