Documentation
¶
Index ¶
- func IsLocalhostURL(baseURL string) bool
- type StripeHandler
- func (h *StripeHandler) CancelSubscription(c *gin.Context)
- func (h *StripeHandler) ChangePlan(c *gin.Context)
- func (h *StripeHandler) CheckoutByPlan(c *gin.Context)
- func (h *StripeHandler) CreateCheckoutSession(c *gin.Context)
- func (h *StripeHandler) CreatePortalSession(c *gin.Context)
- func (h *StripeHandler) GetWebhookSecret() string
- func (h *StripeHandler) ListInvoices(c *gin.Context)
- func (h *StripeHandler) SetWebhookSecret(secret string)
- func (h *StripeHandler) SetupWebhookEndpoint(ctx context.Context)
- func (h *StripeHandler) SyncRecentCheckouts(ctx context.Context)
- func (h *StripeHandler) VerifyCheckoutSession(c *gin.Context)
- func (h *StripeHandler) Webhook(c *gin.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsLocalhostURL ¶ added in v0.1.1
IsLocalhostURL returns true if the URL points to a local address. Stripe cannot deliver webhooks to localhost.
Types ¶
type StripeHandler ¶
type StripeHandler struct {
Store *store.Store
WebhookSecret string // initial value from config (backward compat)
BaseURL string
Email *service.EmailService
WebhookSvc *service.WebhookService
// Livemode is the environment this handler is configured for.
// Every inbound webhook event whose Livemode differs is rejected
// with 400 — guards against cross-environment delivery (test
// secret leaking + replay into prod, or vice versa).
Livemode bool
// contains filtered or unexported fields
}
func (*StripeHandler) CancelSubscription ¶
func (h *StripeHandler) CancelSubscription(c *gin.Context)
func (*StripeHandler) ChangePlan ¶
func (h *StripeHandler) ChangePlan(c *gin.Context)
func (*StripeHandler) CheckoutByPlan ¶ added in v0.1.1
func (h *StripeHandler) CheckoutByPlan(c *gin.Context)
CheckoutByPlan handles GET /pay/:checkout_id — looks up plan by checkout_id, creates a Stripe Checkout Session, and redirects to Stripe.
func (*StripeHandler) CreateCheckoutSession ¶
func (h *StripeHandler) CreateCheckoutSession(c *gin.Context)
func (*StripeHandler) CreatePortalSession ¶
func (h *StripeHandler) CreatePortalSession(c *gin.Context)
CreatePortalSession creates a Stripe billing portal session for the user to manage payment methods.
func (*StripeHandler) GetWebhookSecret ¶ added in v0.1.1
func (h *StripeHandler) GetWebhookSecret() string
GetWebhookSecret returns the current webhook signing secret (thread-safe).
func (*StripeHandler) ListInvoices ¶
func (h *StripeHandler) ListInvoices(c *gin.Context)
ListInvoices returns invoice history for a license's Stripe customer.
func (*StripeHandler) SetWebhookSecret ¶ added in v0.1.1
func (h *StripeHandler) SetWebhookSecret(secret string)
SetWebhookSecret updates the webhook signing secret (thread-safe).
func (*StripeHandler) SetupWebhookEndpoint ¶ added in v0.1.1
func (h *StripeHandler) SetupWebhookEndpoint(ctx context.Context)
SetupWebhookEndpoint ensures a Stripe webhook endpoint is configured. It runs synchronously on first attempt, then retries in the background if it fails.
func (*StripeHandler) SyncRecentCheckouts ¶ added in v0.1.1
func (h *StripeHandler) SyncRecentCheckouts(ctx context.Context)
SyncRecentCheckouts scans Stripe for completed checkout sessions in the last interval and creates licenses for any that were missed by webhooks.
func (*StripeHandler) VerifyCheckoutSession ¶ added in v0.1.1
func (h *StripeHandler) VerifyCheckoutSession(c *gin.Context)
VerifyCheckoutSession handles GET /api/v1/checkout/verify?session_id=xxx Called by the success page to verify payment and create license (webhook fallback).
func (*StripeHandler) Webhook ¶
func (h *StripeHandler) Webhook(c *gin.Context)