This commit is contained in:
@@ -182,16 +182,27 @@ export async function createCheckoutSessionForInvoice(params: {
|
|||||||
// Stripe Checkout supports a limited set of locales; map our
|
// Stripe Checkout supports a limited set of locales; map our
|
||||||
// four to Stripe's codes and fall back to 'auto' if anything
|
// four to Stripe's codes and fall back to 'auto' if anything
|
||||||
// outside the set ever appears.
|
// 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"
|
invoice.locale === "de"
|
||||||
? "de"
|
? ("de" as const)
|
||||||
: invoice.locale === "fr"
|
: invoice.locale === "fr"
|
||||||
? "fr"
|
? ("fr" as const)
|
||||||
: invoice.locale === "it"
|
: invoice.locale === "it"
|
||||||
? "it"
|
? ("it" as const)
|
||||||
: invoice.locale === "en"
|
: invoice.locale === "en"
|
||||||
? "en"
|
? ("en" as const)
|
||||||
: "auto";
|
: ("auto" as const);
|
||||||
|
|
||||||
const successUrl = `${baseUrl}/billing/${encodeURIComponent(invoice.invoiceNumber)}?paid=1&session_id={CHECKOUT_SESSION_ID}`;
|
const successUrl = `${baseUrl}/billing/${encodeURIComponent(invoice.invoiceNumber)}?paid=1&session_id={CHECKOUT_SESSION_ID}`;
|
||||||
const cancelUrl = `${baseUrl}/billing/${encodeURIComponent(invoice.invoiceNumber)}?cancelled=1`;
|
const cancelUrl = `${baseUrl}/billing/${encodeURIComponent(invoice.invoiceNumber)}?cancelled=1`;
|
||||||
|
|||||||
Reference in New Issue
Block a user