feat(payment): expand Stripe methods and checkout handoff
Docker Image / Build and Push Docker Image (push) Successful in 2m10s
Docker Image / Build and Push Docker Image (push) Successful in 2m10s
This commit is contained in:
@@ -4,8 +4,10 @@ import { AuthStorage } from "@/data/storage/auth/auth_storage";
|
||||
import { UserStorage } from "@/data/storage/user/user_storage";
|
||||
import type { PendingChatPromotionType } from "@/data/storage/navigation";
|
||||
import type { LoginStatus } from "@/data/schemas/auth";
|
||||
import type { CheckoutIntent } from "@/data/schemas/auth";
|
||||
import {
|
||||
DEFAULT_CHARACTER_SLUG,
|
||||
getCharacterById,
|
||||
getCharacterBySlug,
|
||||
} from "@/data/constants/character";
|
||||
import { getCharacterRoutes, ROUTES } from "@/router/routes";
|
||||
@@ -100,6 +102,30 @@ export function resolveExternalEntryDestination({
|
||||
return routes.chat;
|
||||
}
|
||||
|
||||
export function resolveCheckoutIntentDestination(
|
||||
intent: CheckoutIntent,
|
||||
): string {
|
||||
const params = new URLSearchParams({ planId: intent.planId });
|
||||
|
||||
if (intent.recipientCharacterId) {
|
||||
const character = getCharacterById(intent.recipientCharacterId);
|
||||
const routes = getCharacterRoutes(
|
||||
character?.slug ?? DEFAULT_CHARACTER_SLUG,
|
||||
);
|
||||
if (intent.chatActionId) params.set("chatActionId", intent.chatActionId);
|
||||
params.set("payChannel", "stripe");
|
||||
return `${routes.tip}?${params.toString()}`;
|
||||
}
|
||||
|
||||
params.set("autoRenew", intent.autoRenew ? "1" : "0");
|
||||
if (intent.commercialOfferId) {
|
||||
params.set("commercialOfferId", intent.commercialOfferId);
|
||||
}
|
||||
if (intent.chatActionId) params.set("chatActionId", intent.chatActionId);
|
||||
params.set("payChannel", "stripe");
|
||||
return `${ROUTES.subscription}?${params.toString()}`;
|
||||
}
|
||||
|
||||
export async function persistExternalEntryPayload({
|
||||
deviceId,
|
||||
asid,
|
||||
@@ -138,6 +164,7 @@ function resolveTarget(
|
||||
return ROUTES.privateZone;
|
||||
}
|
||||
if (target === "topup") return ROUTES.subscription;
|
||||
if (target === "checkout") return ROUTES.subscription;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user