Help us shape the future of Go! Take the 2026 Go Developer Survey

payment

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package payment holds what every payment gateway protocol shares: the supported platforms and their names, and the money conversions between the minor units orders count and the decimal amounts gateways exchange.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAmount added in v1.21.0

func ConvertAmount(minor int64, rate float64) (int64, error)

ConvertAmount converts minor units of one currency into minor units of another at rate, the price of one source unit in target units; both currencies count hundredths. The rate is taken at its shortest decimal representation, which is the value the rate provider published rather than the nearest binary fraction, and the exact product is rounded to the nearest target minor unit with halves rounded away from zero. The result therefore never differs from the exact conversion by more than half a minor unit, and the same inputs always produce the same charge.

func FormatAmount added in v1.21.0

func FormatAmount(minor int64) string

FormatAmount renders minor units as the two-decimal string payment gateways exchange: 1990 is "19.90" and 5 is "0.05". It never goes through a float.

func GetSupportedPlatforms

func GetSupportedPlatforms() []integration.Info

func ParseAmount

func ParseAmount(value string) (int64, error)

ParseAmount converts a non-negative decimal currency amount to its integer minor unit. Financial callback code must not compare parsed float64 values.

func SupportedPlatformNames

func SupportedPlatformNames() []string

SupportedPlatformNames lists every platform that may be exposed for a new checkout. Keep this separate from GetSupportedPlatforms because balance is an internal checkout method rather than an administrator-configurable gateway.

Types

type Platform

type Platform int
const (
	Stripe Platform = iota
	AlipayF2F
	EPay
	Balance
	Cryptomus
	UNSUPPORTED Platform = -1
)

func ParsePlatform

func ParsePlatform(s string) Platform

func (Platform) String

func (p Platform) String() string

Directories

Path Synopsis
Package alipay implements the Alipay face-to-face payment protocol: QR code trade creation, trade query and close, and signed notification decoding.
Package alipay implements the Alipay face-to-face payment protocol: QR code trade creation, trade query and close, and signed notification decoding.
Package cryptomus implements the Cryptomus crypto-payment gateway protocol: invoice creation, invoice lookup and webhook signature verification.
Package cryptomus implements the Cryptomus crypto-payment gateway protocol: invoice creation, invoice lookup and webhook signature verification.
Package epay implements the EPay payment protocol: signed payment URLs, callback signature verification and the order query, with the EasyPay-compatible query as a fallback.
Package epay implements the EPay payment protocol: signed payment URLs, callback signature verification and the order query, with the EasyPay-compatible query as a fallback.
protocol
Package protocol implements EPay V1 and V2 using Go's standard library.
Package protocol implements EPay V1 and V2 using Go's standard library.
Package stripe implements the Stripe payment protocol: payment intents and their payment sheets, customers, webhook endpoints and signed webhook events.
Package stripe implements the Stripe payment protocol: payment intents and their payment sheets, customers, webhook endpoints and signed webhook events.

Jump to

Keyboard shortcuts

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