refactor(payment): remove vip status flow
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user