feat(payment): add chat support discounts and gratitude
This commit is contained in:
@@ -5,7 +5,11 @@ import { useRouter } from "next/navigation";
|
||||
|
||||
import { usePaymentRouteFlow } from "@/app/_hooks/use-payment-route-flow";
|
||||
import type { PayChannel } from "@/data/schemas/payment";
|
||||
import { DEFAULT_CHARACTER_SLUG } from "@/data/constants/character";
|
||||
import {
|
||||
DEFAULT_CHARACTER,
|
||||
DEFAULT_CHARACTER_SLUG,
|
||||
getCharacterBySlug,
|
||||
} from "@/data/constants/character";
|
||||
import {
|
||||
consumeSubscriptionExitUrl,
|
||||
resolveSubscriptionSuccessExitUrl,
|
||||
@@ -19,7 +23,7 @@ export interface UseSubscriptionPaymentFlowInput {
|
||||
shouldResumePendingOrder: boolean;
|
||||
returnTo: SubscriptionReturnTo;
|
||||
initialPayChannel: PayChannel;
|
||||
sourceCharacterSlug?: string;
|
||||
sourceCharacterSlug?: string | null;
|
||||
initialPlanId?: string | null;
|
||||
initialAutoRenew?: boolean | null;
|
||||
commercialOfferId?: string | null;
|
||||
@@ -40,10 +44,13 @@ export function useSubscriptionPaymentFlow({
|
||||
chatActionId = null,
|
||||
}: UseSubscriptionPaymentFlowInput) {
|
||||
const router = useRouter();
|
||||
const supportCharacter = getCharacterBySlug(sourceCharacterSlug);
|
||||
const exitCharacterSlug = supportCharacter?.slug ?? DEFAULT_CHARACTER.slug;
|
||||
const { payment, paymentDispatch } = usePaymentRouteFlow({
|
||||
initialPayChannel,
|
||||
paymentType: subscriptionType,
|
||||
shouldResumePendingOrder,
|
||||
characterId: supportCharacter?.id,
|
||||
initialPlanId,
|
||||
initialAutoRenew,
|
||||
commercialOfferId,
|
||||
@@ -65,7 +72,7 @@ export function useSubscriptionPaymentFlow({
|
||||
const handleBackClick = () => {
|
||||
void (async () => {
|
||||
router.replace(
|
||||
await consumeSubscriptionExitUrl(returnTo, sourceCharacterSlug),
|
||||
await consumeSubscriptionExitUrl(returnTo, exitCharacterSlug),
|
||||
);
|
||||
})();
|
||||
};
|
||||
@@ -77,7 +84,7 @@ export function useSubscriptionPaymentFlow({
|
||||
router.replace(
|
||||
await resolveSubscriptionSuccessExitUrl(
|
||||
returnTo,
|
||||
sourceCharacterSlug,
|
||||
exitCharacterSlug,
|
||||
),
|
||||
);
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user