refactor(payment): remove vip status flow

This commit is contained in:
2026-06-26 18:48:22 +08:00
parent e9fc001a6f
commit b6f18a1ef3
9 changed files with 46 additions and 176 deletions
@@ -0,0 +1,34 @@
import type { PaymentPlan } from "@/data/dto/payment";
import type { PaymentState } from "./payment-state";
export function toPaymentErrorMessage(error: unknown): string {
return error instanceof Error ? error.message : String(error);
}
export function defaultAutoRenewForPlan(planId: string): boolean {
return (
!planId.includes("lifetime") &&
!planId.startsWith("dol_") &&
!planId.startsWith("points_") &&
!planId.startsWith("credit_")
);
}
export function getDefaultPlanId(plans: readonly PaymentPlan[]): string {
return (
plans.find((plan) => plan.planId === "vip_monthly")?.planId ??
plans.find((plan) => plan.orderType.startsWith("vip_"))?.planId ??
plans[0]?.planId ??
""
);
}
export function resetOrderState(): Partial<PaymentState> {
return {
currentOrderId: null,
payParams: null,
orderStatus: null,
errorMessage: null,
};
}