Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(web): add mobile checkout redirect helpers
Richie McIlroyb253dd99514a
diff --git a/apps/web/lib/mobile-checkout.ts b/apps/web/lib/mobile-checkout.tsnew file mode 100644index 000000000..844e372bb--- /dev/null+++ b/apps/web/lib/mobile-checkout.ts@@ -0,0 +1,37 @@+export type CheckoutPlatform = "desktop" | "mobile" | "web";++export type CheckoutRedirectUrls = {+ successUrl: string;+ cancelUrl: string;+};++const trimTrailingSlashes = (value: string) => value.replace(/\/+$/, "");++export function getCheckoutRedirectUrls(+ platform: CheckoutPlatform,+ webUrl: string,+): CheckoutRedirectUrls {+ if (platform === "mobile") {+ const baseUrl = trimTrailingSlashes(webUrl);+ return {+ successUrl: `${baseUrl}/mobile/checkout/complete?checkout=success`,+ cancelUrl: `${baseUrl}/mobile/checkout/complete?checkout=cancelled`,+ };+ }++ if (platform === "web") {+ return {+ successUrl: `${webUrl}/dashboard/caps?upgrade=true&guest=true&session_id={CHECKOUT_SESSION_ID}`,+ cancelUrl: `${webUrl}/pricing`,+ };+ }++ return {+ successUrl: `${webUrl}/dashboard/caps?upgrade=true`,+ cancelUrl: `${webUrl}/pricing`,+ };+}++export function getMobileCheckoutDeepLink(checkout: "cancelled" | "success") {+ return `cap://account?checkout=${checkout}`;+}