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
- func NewProvider(getConfig payment.ConfigSource) (payment.Provider, error)
- func Register(r *payment.Registry)
- type Config
- type Provider
- func (p *Provider) IsConfigured() bool
- func (p *Provider) Mode() string
- func (p *Provider) PayURL(order *model.Order, subject string) (*payment.PayDirective, error)
- func (p *Provider) Platform() string
- func (p *Provider) VerifyNotify(ctx context.Context, r *http.Request) (outTradeNo, tradeNo string, paid bool, err error)
Constants ¶
const Platform = model.OrderPlatformAlipay
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.
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 ¶
IsConfigured implements payment.ConfigStatusProvider.
func (*Provider) PayURL ¶
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) 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.