stripe

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: 10 Imported by: 0

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

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.

func Register

func Register(r *payment.Registry)

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

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

func (p *Provider) IsConfigured() bool

IsConfigured implements payment.ConfigStatusProvider.

func (*Provider) Mode

func (p *Provider) Mode() string

Mode implements payment.Provider. Stripe uses a hosted checkout redirect.

func (*Provider) PayURL

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

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) 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. 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.

Jump to

Keyboard shortcuts

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