paynow

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2021 License: MIT Imports: 3 Imported by: 0

README

Open in Visual Studio Code

PayNow

A Go package implementing QRCode generator for Singapore PayNow.

The main package implements the method to generate the value string for PayNow.

Optional package "github.com/jaynzr/go-paynow/qrcode" uses yeqown qrcode package to generate qrcodes. You may use other qrcode generator.

Generating PayNow Value


import "github.com/jaynzr/go-paynow"

payee := paynow.NewUEN("ACME Pte Ltd", "S99345678ABCD")
val : payee.New(12.34, "INV1234", true, time.Time{}).String()


QR Code Usage

import "github.com/jaynzr/go-paynow/qrcode"

payee := qrcode.NewMobile("90991234")

jpg, err := qrcode.QRCode(12.35, "ABCDEFG")

To customize image output, append qrcode.ImageOption to Payee.Options

Using custom logo, image attributes, expiry date, and image options


import (
    "github.com/jaynzr/go-paynow/qrcode"
	qrcopt "github.com/yeqown/go-qrcode"
)

payee := qrcode.NewUEN("ACME Pte Ltd", "S99345678ABCD")

// see https://github.com/yeqown/go-qrcode#options for available ImageOptions
payee.Options = []qrcopt.ImageOption{
    // logo size should not be > 1/5 of qrcode.
    qrcopt.WithLogoImageFilePNG("logo.png"),

    // width of each qr block
    qrcopt.WithQRWidth(12),

    // generates png format
    qrcopt.WithBuiltinImageEncoder(qrcopt.PNG_FORMAT),
}

amount := 12.35
ref := "ABCDEFG"
editable := false
expiry := time.Now().Add(time.Hour * 48)

png, err := payee.QRCodeExpiry(amount, ref, editable, expiry)

Credits

javascript/node.js

PaynowQR

QRGenerator.js

Documentation

Overview

Package paynow generates QR Code for Singapore PayNow payment system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Payee

type Payee struct {
	MerchantName string
	UEN          string
	Mobile       string
	// contains filtered or unexported fields
}

Payee struct, all fields are optional.

func NewMobile added in v1.1.0

func NewMobile(mobile string) *Payee

NewMobile returns Payee with mobile

func NewUEN added in v1.1.0

func NewUEN(merchantName string, uen string) *Payee

NewUEN returns Payee with UEN

func (*Payee) New added in v1.1.0

func (pp *Payee) New(amount float32, ref string, editable bool, expirySGT time.Time) payment

New returns a new payment

Directories

Path Synopsis
paynow module
Package paynow generates QR Code for Singapore PayNow payment system.
Package paynow generates QR Code for Singapore PayNow payment system.

Jump to

Keyboard shortcuts

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