feat(admin): Paddle client behind an interface, config, and the event idempotency record
Client is a thin REST client (net/http) rather than the vendor SDK: the surface we need is two calls, and a hand-rolled client has no version-drift risk and no dependency in go.sum. All Paddle wire shapes live only in http.go. PADDLE_API_KEY and PADDLE_WEBHOOK_SECRET are boot-required — an unverified webhook endpoint is one anyone can issue licences through. paddle_events carries a unique index on event_id for webhook idempotency. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,10 @@ type Config struct {
|
||||
Addr string
|
||||
ReapAfter time.Duration
|
||||
|
||||
PaddleEnv string // "sandbox" or "production"
|
||||
PaddleAPIKey string
|
||||
PaddleWebhookSecret string
|
||||
|
||||
SMTPHost string
|
||||
SMTPPort string
|
||||
SMTPFrom string
|
||||
@@ -75,6 +79,10 @@ func Load() (Config, error) {
|
||||
SMTPFrom: os.Getenv("SMTP_FROM"),
|
||||
SMTPUsername: os.Getenv("SMTP_USERNAME"),
|
||||
SMTPPassword: os.Getenv("SMTP_PASSWORD"),
|
||||
|
||||
PaddleEnv: envOr("PADDLE_ENV", "sandbox"),
|
||||
PaddleAPIKey: os.Getenv("PADDLE_API_KEY"),
|
||||
PaddleWebhookSecret: os.Getenv("PADDLE_WEBHOOK_SECRET"),
|
||||
}
|
||||
|
||||
var missing []string
|
||||
@@ -85,6 +93,10 @@ func Load() (Config, error) {
|
||||
"LICENSE_SIGNING_KEY": c.SigningKey,
|
||||
"PUBLIC_URL": c.PublicURL,
|
||||
"ADMIN_ORIGIN": os.Getenv("ADMIN_ORIGIN"),
|
||||
// An unverified webhook endpoint is one anyone can issue licences
|
||||
// through, so the secret and API key are boot-required.
|
||||
"PADDLE_API_KEY": c.PaddleAPIKey,
|
||||
"PADDLE_WEBHOOK_SECRET": c.PaddleWebhookSecret,
|
||||
} {
|
||||
if v == "" {
|
||||
missing = append(missing, name)
|
||||
|
||||
Reference in New Issue
Block a user