43 lines
961 B
TypeScript
43 lines
961 B
TypeScript
/**
|
|
* Payment 状态机:State 形状 + 初始值
|
|
*/
|
|
import type {
|
|
PayChannel,
|
|
PaymentOrderStatus,
|
|
PaymentPlan,
|
|
} from "@/data/dto/payment";
|
|
|
|
export type PaymentPlanCatalog = "default" | "tip";
|
|
|
|
export interface PaymentState {
|
|
planCatalog: PaymentPlanCatalog;
|
|
plans: PaymentPlan[];
|
|
isFirstRecharge: boolean;
|
|
selectedPlanId: string;
|
|
payChannel: PayChannel;
|
|
autoRenew: boolean;
|
|
agreed: boolean;
|
|
currentOrderId: string | null;
|
|
payParams: Record<string, unknown> | null;
|
|
orderStatus: PaymentOrderStatus | null;
|
|
orderPollingStartedAt: number | null;
|
|
errorMessage: string | null;
|
|
launchNonce: number;
|
|
}
|
|
|
|
export const initialState: PaymentState = {
|
|
planCatalog: "default",
|
|
plans: [],
|
|
isFirstRecharge: false,
|
|
selectedPlanId: "",
|
|
payChannel: "stripe",
|
|
autoRenew: true,
|
|
agreed: true,
|
|
currentOrderId: null,
|
|
payParams: null,
|
|
orderStatus: null,
|
|
orderPollingStartedAt: null,
|
|
errorMessage: null,
|
|
launchNonce: 0,
|
|
};
|