mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-09 12:16:50 +00:00
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.
65 lines
1.1 KiB
Go
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
|
|
}
|
|
}
|