payment

package
v0.0.0-...-97e0de2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: GPL-3.0 Imports: 20 Imported by: 2

Documentation

Overview

Package payment implements payment methods.

Register your payment methods for POST requests under /payment/{method}:

router.Handler(http.MethodPost, fmt.Sprintf("/payment/%s/*path", paymentMethod.ID()), paymentMethod)

Note that the handlers will be publicly available.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BTCPay

type BTCPay struct {
	ExpirationMinutes int
	RedirectPath      string
	Store             btcpay.Store
	Purchases         PurchaseRepo

	CreateInvoiceError func(err error, msg string) http.Handler
	WebhookError       func(err error) http.Handler
}

func (BTCPay) ID

func (BTCPay) ID() string

func (BTCPay) Name

func (BTCPay) Name(l lang.Lang) string

func (BTCPay) PayHTML

func (b BTCPay) PayHTML(purchaseID, paymentKey string, l lang.Lang) (template.HTML, error)

func (BTCPay) ServeHTTP

func (b BTCPay) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (BTCPay) VerifiesAdult

func (BTCPay) VerifiesAdult() bool

type Cash

type Cash struct {
	AddressHTML string
}

func (Cash) ID

func (Cash) ID() string

func (Cash) Name

func (Cash) Name(l lang.Lang) string

func (Cash) PayHTML

func (cash Cash) PayHTML(purchaseID, paymentKey string, l lang.Lang) (template.HTML, error)

func (Cash) ServeHTTP

func (Cash) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (Cash) VerifiesAdult

func (Cash) VerifiesAdult() bool

type CashForeign

type CashForeign struct {
	AddressHTML string
	Purchases   PurchaseRepo
	History     *rates.History
}

func (CashForeign) ID

func (CashForeign) ID() string

func (CashForeign) Name

func (CashForeign) Name(l lang.Lang) string

func (CashForeign) PayHTML

func (cash CashForeign) PayHTML(purchaseID, paymentKey string, l lang.Lang) (template.HTML, error)

func (CashForeign) ServeHTTP

func (CashForeign) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (CashForeign) VerifiesAdult

func (CashForeign) VerifiesAdult() bool

type Method

type Method interface {
	http.Handler
	ID() string
	Name(l lang.Lang) string
	PayHTML(purchaseID, paymentKey string, l lang.Lang) (template.HTML, error)
	VerifiesAdult() bool
}

Method is the interface that wraps payment methods.

PayHTML takes a purchase ID and an optional payment key. The purchase ID should be unique. It is usually short and suitable for bank transfer forms, bookkeeping etc. It must not contain a colon. The optional payment key should have a high entropy. It can prevent the loss of goods if an purchase ID is accidentally or maliciously issued twice. Even if a payment key is used, payment methods should store the purchase ID because tax accounting may require a connection between payment and purchase.

func Get

func Get(methods []Method, id string) (Method, error)

type PayPal

type PayPal struct {
	Config    *paypal.Config
	Purchases PurchaseRepo
}

PayPal does the PayPal Standard Checkout described at https://developer.paypal.com/docs/checkout/standard/

func (PayPal) ID

func (PayPal) ID() string

func (PayPal) Name

func (PayPal) Name(l lang.Lang) string

func (PayPal) PayHTML

func (p PayPal) PayHTML(purchaseID, paymentKey string, l lang.Lang) (template.HTML, error)

func (PayPal) ServeHTTP

func (p PayPal) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (PayPal) VerifiesAdult

func (PayPal) VerifiesAdult() bool

type PurchaseRepo

type PurchaseRepo interface {
	PurchaseCreationDate(purchaseID, paymentKey string) (string, error) // yyyy-mm-dd
	PurchaseSumCents(purchaseID, paymentKey string) (int, error)
	SetPurchasePaid(purchaseID, paymentKey string) error
	SetPurchaseProcessing(purchaseID, paymentKey string) error
}

type SEPA

type SEPA struct {
	Account   SEPAAccount
	Purchases PurchaseRepo
}

func (SEPA) ID

func (SEPA) ID() string

func (SEPA) Name

func (SEPA) Name(l lang.Lang) string

func (SEPA) PayHTML

func (sepa SEPA) PayHTML(purchaseID, paymentKey string, l lang.Lang) (template.HTML, error)

func (SEPA) ServeHTTP

func (SEPA) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (SEPA) VerifiesAdult

func (SEPA) VerifiesAdult() bool

type SEPAAccount

type SEPAAccount struct {
	Holder   string
	IBAN     string
	BIC      string
	BankName string
}

Directories

Path Synopsis
Package health provides a widget which displays the synchronization status of payment methods.
Package health provides a widget which displays the synchronization status of payment methods.
Package rates retrieves and stores daily exchange rates.
Package rates retrieves and stores daily exchange rates.

Jump to

Keyboard shortcuts

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