Documentation
¶
Overview ¶
Package wechat implements payment.Provider for WeChat Pay v3 NATIVE. The PayURL call creates a NATIVE order and returns the code_url as a "qr" PayDirective that the frontend renders as a QR code for the user to scan. Async notifications are JSON-signed; the platform certificate is fetched lazily (every 6h) to verify the signature, then the resource is decrypted with the APIv3 key. Credentials are read lazily from SystemConfig (wechat.* keys) through the injected ConfigSource.
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.OrderPlatformWechat
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 a wechat Provider. The wechat client is created lazily on first use and cached.
Types ¶
type Config ¶
type Config struct {
AppID string
MchID string
APIV3Key string
SerialNo string
PrivateKey string
NotifyURL string
}
Config holds wechat credentials read from SystemConfig (wechat.* keys).
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is the wechat implementation of payment.Provider.
func (*Provider) IsConfigured ¶
IsConfigured implements payment.ConfigStatusProvider.
func (*Provider) PayURL ¶
PayURL implements payment.Provider. It creates a NATIVE order and returns the code_url wrapped as a QR PayDirective.
func (*Provider) VerifyNotify ¶
func (p *Provider) VerifyNotify(ctx context.Context, r *http.Request) (outTradeNo, tradeNo string, paid bool, err error)
VerifyNotify implements payment.Provider. WeChat posts a JSON body signed with its platform private key; we verify the signature with the platform public cert, then AES-decrypt the resource with the APIv3 key.