qrpay

package module
v0.0.0-...-d3cad2e Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2023 License: MIT Imports: 3 Imported by: 0

README

QR code for payment

Payment QR code for Go

Build Status codecov Go Report Card Maintainability CodeScene Code Health

Golang library for creating QR codes for payments.

Short Payment Descriptor format and EPC QR Code (SEPA) format is supported.

Installation

go get -u github.com/dundee/qrpay

Usage

Generating QR code image for Short Payment Descriptor format
import "github.com/dundee/qrpay"

p := qrpay.NewSpaydPayment()
p.SetIBAN("CZ5855000000001265098001")
p.SetAmount("10.8")
p.SetDate(time.Date(2021, 12, 24, 0, 0, 0, 0, time.UTC))
p.SetMessage("M")
p.SetRecipientName("go")
p.SetNofificationType('E')
p.SetNotificationValue("daniel@milde.cz")
p.SetExtendedAttribute("vs", "1234567890")

qrpay.SaveQRCodeImageToFile(p, "qr-payment.png")
Generating QR code image for EPC QR Code
import "github.com/dundee/qrpay"

p := qrpay.NewEpcPayment()
p.SetIBAN("CZ5855000000001265098001")
p.SetAmount("10.8")
p.SetMessage("M")
p.SetRecipientName("go")

qrpay.SaveQRCodeImageToFile(p, "qr-payment.png")

QR code image encoding uses skip2/go-qrcode.

Getting QR code content for Short Payment Descriptor format
import "github.com/dundee/qrpay"

p := qrpay.NewSpaydPayment()
p.SetIBAN("CZ5855000000001265098001")
p.SetAmount("108")

fmt.Println(qrpay.GenerateString())
// Output: SPD*1.0*ACC:CZ5855000000001265098001*AM:108*

Documentation

Overview

Package for creating QR codes for payments.

Short Payment Descriptor format and EPC QR Code (SEPA) format is supported.

- Generating QR code image for Short Payment Descriptor format

import "github.com/wogri/qrpay"

p := qrpay.NewSpaydPayment()
p.SetIBAN("CZ5855000000001265098001")
p.SetAmount("10.8")
p.SetDate(time.Date(2021, 12, 24, 0, 0, 0, 0, time.UTC))
p.SetMessage("M")
p.SetRecipientName("go")
p.SetNofificationType('E')
p.SetNotificationValue("daniel@milde.cz")
p.SetExtendedAttribute("vs", "1234567890")

qrpay.SaveQRCodeImageToFile(p, "qr-payment.png")

- Generating QR code image for EPC QR Code

import "github.com/wogri/qrpay"

p := qrpay.NewEpcPayment()
p.SetIBAN("CZ5855000000001265098001")
p.SetAmount("10.8")
p.SetMessage("M")
p.SetRecipientName("go")

qrpay.SaveQRCodeImageToFile(p, "qr-payment.png")

QR code image encoding uses https://github.com/skip2/go-qrcode

- Getting QR code content for Short Payment Descriptor format

import "github.com/wogri/qrpay"

p := qrpay.NewSpaydPayment()
p.SetIBAN("CZ5855000000001265098001")
p.SetAmount("108")

fmt.Println(qrpay.GenerateString())
// Output: SPD*1.0*ACC:CZ5855000000001265098001*AM:108*

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetQRCodeImage

func GetQRCodeImage(payment Payment) ([]byte, error)

func NewEpcPayment

func NewEpcPayment() *epc.EpcPayment

func NewSpaydPayment

func NewSpaydPayment() *spayd.SpaydPayment

func SaveQRCodeImageToFile

func SaveQRCodeImageToFile(payment Payment, path string) error

Types

type Payment

type Payment interface {
	SetIBAN(string) error
	SetBIC(string) error
	SetAmount(value string) error
	SetCurrency(value string) error
	SetSenderReference(value string) error
	SetRecipientName(value string) error
	SetMessage(value string) error

	GetErrors() map[string]error
	GenerateString() (string, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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