readConfig required all Dodo values, so the console could not start before the railyard Dodo brand and products exist (owner item Y-2), although Railyard is sold inside the Scribase add-on (bridge orgs need no checkout). Dodo values are now optional: billingReady is true only when the key, the webhook secret and the three product ids are all set. Without them checkout, pause and cancel redirect with 'card payments open soon', the webhook answers 503, and everything else runs. Scribase project and session secret stay required. 4 new tests; console 158/158, tsc clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
18 lines
771 B
TypeScript
18 lines
771 B
TypeScript
import { deps } from "../../../../lib/deps.ts";
|
|
import { json } from "../../../../lib/http.ts";
|
|
import { handleDodoWebhook } from "../../../../lib/webhook.ts";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export async function POST(req: Request) {
|
|
const { cfg, repo, dodo } = deps();
|
|
if (!cfg.billingReady) return json({ error: "billing_not_configured" }, 503);
|
|
const body = await req.text();
|
|
const res = await handleDodoWebhook(
|
|
{ repo, dodo, webhookSecret: cfg.dodoWebhookSecret, sessionSecret: cfg.sessionSecret, brandId: cfg.dodoBrandId, now: () => new Date() },
|
|
{ id: req.headers.get("webhook-id"), timestamp: req.headers.get("webhook-timestamp"), signature: req.headers.get("webhook-signature") },
|
|
body,
|
|
);
|
|
return json(res.body, res.status);
|
|
}
|