export function createPaymentMock(options: PaymentMockOptions = {}) {
  const { shouldFail = false, orderNo = 'MOCK202605190001' } = options;

  return {
    createOrder: vi.fn().mockImplementation(async (userId: number, planId: number, paymentMethod: string) => {
      if (shouldFail) {
        throw new Error('Mock Payment failure');
      }
      return {
        orderNo: orderNo,
        amount: 99,
        planName: '专业版',
        qrCode: `https://mock-pay.example.com/qr/${orderNo}`,
      };
    }),
    verifySign: vi.fn().mockReturnValue(true),
    handleCallback: vi.fn().mockResolvedValue({ success: true }),
    queryOrder: vi.fn().mockResolvedValue({ status: 'PAID' }),
  };
}

export interface PaymentMockOptions {
  shouldFail?: boolean;
  orderNo?: string;
}

export const mockOrder = {
  orderNo: 'MOCK202605190001',
  amount: 99,
  planName: '专业版',
  qrCode: 'https://mock-pay.example.com/qr/MOCK202605190001',
};