/**
 * Payment 状态机：State 形状 + 初始值
 */
import type {
  PayChannel,
  PaymentOrderStatus,
  PaymentPlan,
} from "@/data/dto/payment";

export interface PaymentState {
  plans: PaymentPlan[];
  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 = {
  plans: [],
  selectedPlanId: "",
  payChannel: "stripe",
  autoRenew: true,
  agreed: true,
  currentOrderId: null,
  payParams: null,
  orderStatus: null,
  orderPollingStartedAt: null,
  errorMessage: null,
  launchNonce: 0,
};
