Giter VIP home page Giter VIP logo

go-paynow's Introduction

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

go-paynow's People

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.