alipay

package
v0.0.0-...-2c9f6af Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package alipay implements payment.Provider for Alipay's offline QR pre-creation (alipay.trade.precreate, 统一收单线下交易预创建) and async notification verification, using github.com/go-pay/gopay/alipay (classic RSA2 public-key gateway). PayURL returns a "qr" PayDirective whose URL is the pre-created QR code string the user scans to pay. Credentials are read lazily from SystemConfig (alipay.* keys) through the injected ConfigSource, and the alipay client is cached and rebuilt only when the config signature changes.

Index

Constants

Platform is the canonical identifier stored on Order.Platform.

Variables

This section is empty.

Functions

func NewProvider

func NewProvider(getConfig payment.ConfigSource) (payment.Provider, error)

NewProvider builds an alipay Provider. The alipay client is created lazily on first use and cached.

func Register

func Register(r *payment.Registry)

Register wires the alipay Provider into the given Registry under its platform name. Call this once at startup after NewRegistry.

Types

type Config

type Config struct {
	AppID      string
	PrivateKey string
	PublicKey  string
	NotifyURL  string
	Sandbox    bool
}

Config holds alipay credentials read from SystemConfig (alipay.* keys).

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider is the alipay implementation of payment.Provider.

func (*Provider) IsConfigured

func (p *Provider) IsConfigured() bool

IsConfigured implements payment.ConfigStatusProvider.

func (*Provider) Mode

func (p *Provider) Mode() string

Mode implements payment.Provider. Alipay uses an offline QR pre-creation.

func (*Provider) PayURL

func (p *Provider) PayURL(order *model.Order, subject string) (*payment.PayDirective, error)

PayURL implements payment.Provider. It creates an offline pre-creation order (alipay.trade.precreate) and returns the generated QR code string as a "qr" PayDirective that the frontend renders for the user to scan.

func (*Provider) Platform

func (p *Provider) Platform() string

Platform implements payment.Provider.

func (*Provider) VerifyNotify

func (p *Provider) VerifyNotify(ctx context.Context, r *http.Request) (outTradeNo, tradeNo string, paid bool, err error)

VerifyNotify implements payment.Provider. Alipay posts an application/x-www-form-urlencoded body; we parse it, verify the signature with the configured alipay public key (public-key mode), then read the trade fields.

Jump to

Keyboard shortcuts

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