fix: advance orders only after matching paid Stripe events
masterplan-lock / check (pull_request) Successful in 5s
masterplan-lock / check (push) Successful in 8s
CI (SIAX Cloud) / security (push) Successful in 18s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 16s
Security Scan (SIAX Cloud) / security (push) Successful in 18s
CI (SIAX Cloud) / security (pull_request) Successful in 18s
CI (SIAX Cloud) / integration (push) Successful in 28s
CI (SIAX Cloud) / quality (push) Successful in 36s
CI (SIAX Cloud) / integration (pull_request) Successful in 48s
CI (SIAX Cloud) / quality (pull_request) Successful in 56s

This commit is contained in:
2026-09-15 18:15:42 +02:00
parent 8911709931
commit ae190fa60d
7 changed files with 178 additions and 6 deletions
+3 -1
View File
@@ -31,6 +31,8 @@ export async function POST(
"line_items[0][price_data][unit_amount]": String(depositOre),
"line_items[0][quantity]": "1",
mode: "payment",
"metadata[order_id]": order_id,
"metadata[kind]": "deposit",
success_url: `${origin}/order/${order_id}?deposit=success`,
cancel_url: `${origin}/bestall/forskott?order=${order_id}`,
});
@@ -51,4 +53,4 @@ export async function POST(
const session = (await stripeRes.json()) as { url: string };
return NextResponse.json({ url: session.url });
}
}
+3 -2
View File
@@ -1,6 +1,6 @@
import { NextRequest, NextResponse } from "next/server";
import { getStripe } from "@/lib/stripe";
import { getOrder, setStatus } from "@/lib/orders-store";
import { getOrder } from "@/lib/orders-store";
// POST /api/payments/{order_id}/release (docs/04) — charge the held 50% balance.
// Called on ACCEPT only; escrow balance is never charged before approval.
@@ -35,6 +35,7 @@ export async function POST(req: NextRequest, ctx: { params: Promise<{ order_id:
cancel_url: `${origin}/order/${order_id}/validera`,
metadata: { order_id, kind: "balance" },
});
await setStatus(order_id, "delivered");
// Creating a Checkout Session is not payment. Only a verified paid webhook
// may advance the order to delivered.
return NextResponse.json({ checkout_url: session.url });
}