Documentation
¶
Overview ¶
Package stripe implements payment.Provider for Stripe Checkout (one-time payment mode). PayURL creates a hosted Checkout Session and returns its URL as a "redirect" PayDirective that the frontend opens in a browser. Async notifications are Stripe webhooks; the signature is verified with the webhook signing secret, and a completed checkout.session event grants entitlement. Credentials are read lazily from SystemConfig (stripe.* 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.OrderPlatformStripe
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 stripe Provider.
Types ¶
type Config ¶
type Config struct {
SecretKey string
WebhookSecret string
SuccessURL string
CancelURL string
Currency string // ISO currency, e.g. "cny"; defaults to "cny"
}
Config holds stripe credentials read from SystemConfig (stripe.* keys).
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is the stripe implementation of payment.Provider.
func (*Provider) IsConfigured ¶
IsConfigured implements payment.ConfigStatusProvider.
func (*Provider) PayURL ¶
PayURL implements payment.Provider. It creates a hosted Checkout Session for a one-time payment of order.Amount (already in the currency's minor unit, e.g. cents for cny) and returns the session URL as a redirect directive.
func (*Provider) VerifyNotify ¶
func (p *Provider) VerifyNotify(ctx context.Context, r *http.Request) (outTradeNo, tradeNo string, paid bool, err error)
VerifyNotify implements payment.Provider. It verifies the webhook signature with the signing secret and, on a completed checkout session, returns the out_trade_no (our ClientReferenceID) and the session id.