promptpayqr

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: MIT Imports: 6 Imported by: 1

README

promptpay-qr-go

GoLang Library to generate QR Code payload for PromptPay inspired from dtinth/promptpay-qr

Requirement

GoLang 1.12.x

Install

go get -u github.com/kazekim/promptpay-qr-go

Implement

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)
    }
}

Contributing

Everyone can contribute it. Feel free to improve it and make it better.

License

The MIT License (MIT)

Documentation

Index

Constants

View Source
const (
	ID_PAYLOAD_FORMAT                        = "00"
	ID_POI_METHOD                            = "01"
	ID_MERCHANT_INFORMATION_BOT              = "29"
	ID_MERCHANT_INFORMATION_BOT_BILL_PAYMENT = "30"
	ID_TRANSACTION_CURRENCY                  = "53"
	ID_TRANSACTION_AMOUNT                    = "54"
	ID_COUNTRY_CODE                          = "58"
	ID_DATA_OBJECTS                          = "62"
	ID_CRC                                   = "63"

	PAYLOAD_FORMAT_EMV_QRCPS_MERCHANT_PRESENTED_MODE = "01"
	POI_METHOD_STATIC                                = "11"
	POI_METHOD_DYNAMIC                               = "12"
	MERCHANT_INFORMATION_TEMPLATE_ID_GUID            = "00"
	BOT_ID_MERCHANT_PHONE_NUMBER                     = "01"
	BOT_ID_MERCHANT_TAX_ID                           = "02"
	BOT_ID_MERCHANT_EWALLET_ID                       = "03"
	BOT_ID_TAG30_AID                                 = "00"
	BOT_ID_TAG30_BILLER_ID                           = "01"
	BOT_ID_TAG30_REF1                                = "02"
	BOT_ID_TAG30_REF2                                = "03"
	BOT_ID_TAG62_TERMINAL_ID                         = "07"
	GUID_PROMPTPAY                                   = "A000000677010111"
	GUID_PROMPTPAY_BILL_PAYMENT                      = "A000000677010112"
	TRANSACTION_CURRENCY_THB                         = "764"
	COUNTRY_CODE_TH                                  = "TH"
)

Variables

This section is empty.

Functions

func QRForBillPayment added in v1.0.1

func QRForBillPayment(billerID string, ref1 string, ref2 string, terminalID string, amount string) (*[]byte, error)

func QRForTarget

func QRForTarget(target, amount string) (*[]byte, error)

func QRForTargetWithAmount

func QRForTargetWithAmount(target, amount string) (*[]byte, error)

Types

type PromptPayQR

type PromptPayQR struct {
}

func New

func New() *PromptPayQR

func (*PromptPayQR) GenerateBillPaymentPayload added in v1.0.1

func (qr *PromptPayQR) GenerateBillPaymentPayload(billerID string, ref1 string, ref2 string, terminalID *string, amount *string) string

func (*PromptPayQR) GeneratePayload

func (qr *PromptPayQR) GeneratePayload(target string, amount *string) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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