rentease/internal/server/option.go
Ruidy 8384d85e3e
feat(stripe): add Stripe payment sync and webhook support
Introduce Stripe integration for automatic payment ingestion and refund
tracking. Adds new fields to the payment model for Stripe IDs and
status,
Stripe client driver, sync service, cron job, manual API endpoint, and
public webhook handler for real-time updates. Includes tests and
documentation. Manual cash entry remains supported.
2025-10-03 21:39:59 +02:00

65 lines
1.1 KiB
Go

package server
import (
"embed"
"errors"
)
type options struct {
port *int
fs *embed.FS
debug *bool
secretKey *string
origins []string
stripeWebhookSecret *string
}
type Option func(*options) error
func WithPort(port int) Option {
return func(o *options) error {
if port <= 0 {
return errors.New("port should be positive")
}
o.port = &port
return nil
}
}
func WithFileSystem(fs embed.FS) Option {
return func(o *options) error {
o.fs = &fs
return nil
}
}
func WithDebug(debug bool) Option {
return func(o *options) error {
o.debug = &debug
return nil
}
}
func WithSecretKey(secretKey string) Option {
return func(o *options) error {
o.secretKey = &secretKey
return nil
}
}
func WithOrigins(origins []string) Option {
return func(o *options) error {
o.origins = origins
return nil
}
}
func WithStripeWebhookSecret(secret string) Option {
return func(o *options) error {
if secret == "" {
return nil
}
o.stripeWebhookSecret = &secret
return nil
}
}