vietqr

package module
v0.0.0-...-4d7b681 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

Unofficial VietQR client written in Go

Documentation

Index

Constants

View Source
const BaseURL = "https://vietqr.net"

Variables

View Source
var (
	TimeNow       = time.Now
	GenPassphrase = func(accessToken string) string {
		return TimeNow().Format("20060102") + accessToken
	}
)

Functions

func IsTokenError

func IsTokenError(err error) bool

Types

type Bank

type Bank struct {
	Code string `json:"code"`
	Name string `json:"name"`
	BIN  string `json:"bin"`
}

type Client

type Client struct {
	AccessToken string
	BaseURL     string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient HttpClient) *Client

func (*Client) GenQRCode

func (c *Client) GenQRCode(ctx context.Context, input GenQRCodeInput) (*GenQRCodeResult, error)

func (*Client) GetBankList

func (c *Client) GetBankList(ctx context.Context) ([]Bank, error)

func (*Client) RequestAccessToken

func (c *Client) RequestAccessToken(ctx context.Context) error

type Envelope

type Envelope struct {
	Code string `json:"code"`
	Desc string `json:"desc"`
	Data string `json:"data"`
}

func (Envelope) Err

func (e Envelope) Err() error

type GenQRCodeInput

type GenQRCodeInput struct {
	IsMask      int    `json:"isMask"`
	AcqID       string `json:"acqId"`
	AccountNo   string `json:"accountNo"`
	AccountName string `json:"accountName"`
	Amount      string `json:"amount"`
	Message     string `json:"addInfo"`
}

type GenQRCodeResult

type GenQRCodeResult struct {
	ImagePNG []byte `json:"qrBase64"`
}

type HttpClient

type HttpClient interface {
	Do(*http.Request) (*http.Response, error)
}

type VietQRError

type VietQRError struct {
	Code string
	Desc string
}

func (VietQRError) Error

func (e VietQRError) Error() string

Jump to

Keyboard shortcuts

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