From 875ade435181a25c09c53805f6c177327f17d9dd Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 24 May 2026 23:59:05 +0200 Subject: [PATCH] Phase4: Stripe --- src/lib/stripe.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/lib/stripe.ts b/src/lib/stripe.ts index 11b51d5..20aa0cb 100644 --- a/src/lib/stripe.ts +++ b/src/lib/stripe.ts @@ -182,16 +182,27 @@ export async function createCheckoutSessionForInvoice(params: { // Stripe Checkout supports a limited set of locales; map our // four to Stripe's codes and fall back to 'auto' if anything // outside the set ever appears. - const stripeLocale: Stripe.Checkout.SessionCreateParams.Locale = + // + // We deliberately don't annotate this with + // `Stripe.Checkout.SessionCreateParams.Locale` — stripe-node v22 + // ships with a known type-export regression + // (stripe/stripe-node#2662) where params types under namespaced + // resources aren't re-exported from the resource barrel. The + // `as const` literal narrowing gives the variable the union type + // `"de" | "fr" | "it" | "en" | "auto"`, which `sessions.create` + // accepts at the call site via its own inline parameter typing. + // When the SDK fixes the re-export, we can put the annotation + // back without touching the call site. + const stripeLocale = invoice.locale === "de" - ? "de" + ? ("de" as const) : invoice.locale === "fr" - ? "fr" + ? ("fr" as const) : invoice.locale === "it" - ? "it" + ? ("it" as const) : invoice.locale === "en" - ? "en" - : "auto"; + ? ("en" as const) + : ("auto" as const); const successUrl = `${baseUrl}/billing/${encodeURIComponent(invoice.invoiceNumber)}?paid=1&session_id={CHECKOUT_SESSION_ID}`; const cancelUrl = `${baseUrl}/billing/${encodeURIComponent(invoice.invoiceNumber)}?cancelled=1`;