import type { WechatJssdkConfig, WechatJsapiPrepayParams } from '@dukang/shared-types'; export type WechatCodeSession = { openId: string; unionId?: string; sessionKey?: string; accessToken?: string; }; export type WechatOAuthSession = { openId: string; unionId?: string; accessToken?: string; refreshToken?: string; }; export type WechatOAuthUserInfo = { openId: string; nickname?: string; headImgUrl?: string; unionId?: string; }; export type WechatPayNotifyResult = { transactionId: string; outTradeNo: string; tradeState: string; amountFen: number; }; export interface IWechatProvider { isEnabled(): boolean; /** 微信支付是否已配置(商户号 + 证书) */ isPayEnabled(): boolean; /** 当前商户号(用于日志/排查) */ getMchId(): string; /** 小程序 code2session */ code2Session(code: string, actorRef?: { refType: string; refId: bigint }): Promise; /** 公众号 H5 OAuth code 换 openId */ oauth2AccessToken(code: string, actorRef?: { refType: string; refId: bigint }): Promise; /** 公众号 OAuth access_token 拉取用户昵称头像(snsapi_userinfo) */ fetchOAuthUserInfo( accessToken: string, openId: string, actorRef?: { refType: string; refId: bigint }, ): Promise; /** JSSDK 签名配置 */ createJssdkConfig(url: string, actorRef?: { refType: string; refId: bigint }): Promise; /** 构建公众号 OAuth 授权 URL */ buildOAuthUrl(redirectUri: string, state: string, scope?: string): string; /** 小程序手机号 code 解密(或调用微信 getPhoneNumber 接口) */ getPhoneNumberByCode( code: string, platform: 'mini' | 'h5', actorRef?: { refType: string; refId: bigint }, ): Promise; /** 创建 JSAPI 预支付参数(使用 WX_MCH_ID 统一下单) */ createJsapiPrepay(params: { orderNo: string; description: string; amountFen: number; openId: string; notifyUrl: string; }): Promise; /** 解析并验签支付回调通知 */ parsePayNotification( headers: Record, rawBody: string, ): Promise; }