declare module 'expo-alipay-sdk' {
  /**
   * 注册支付宝应用
   * @param appId 支付宝应用ID
   * @param universalLink iOS Universal Link（可选，仅 iOS 需要）
   */
  export function registerApp(
    appId: string,
    universalLink?: string
  ): Promise<boolean>;

  /**
   * 发起支付
   * @param orderInfo 支付订单信息字符串（由服务端生成并签名）
   */
  export function pay(
    orderInfo: string
  ): Promise<PayResult>;

  /**
   * 获取 SDK 版本号
   */
  export function getVersion(): Promise<string>;

  /**
   * 判断支付宝是否已安装
   */
  export function isAlipayInstalled(): Promise<boolean>;

  /**
   * 支付结果
   */
  export interface PayResult {
    resultStatus: string;
    result: string;
    memo: string;
  }

  /**
   * 支付宝错误
   */
  export class AlipayError extends Error {
    code: string;
    result: string;
    memo: string;
  }

  /**
   * 添加事件监听器
   */
  export function addListener(
    eventName: string,
    listener: (...args: any[]) => void
  ): void;

  /**
   * 一次性事件监听器
   */
  export function once(
    eventName: string,
    listener: (...args: any[]) => void
  ): void;

  /**
   * 移除所有监听器
   */
  export function removeAllListeners(eventName?: string): void;
}

