///
import { UrlLibOptions, UrlLibResponse } from './types/urllib';
export interface UnifiedOrderReq {
deviceInfo?: string;
body: string;
detail?: string;
attach?: string;
outTradeNo: string;
feeType?: string;
totalFee: number;
spbillCreateIp: string;
timeStart?: string;
timeExpire?: string;
goodsTag?: string;
notifyUrl: string;
tradeType: 'JSAPI' | 'NATIVE' | 'APP';
productId?: string;
limitPay?: 'no_credit';
openid?: string;
sceneInfo?: string;
}
export interface UnifiedOrderResp {
tradeType: 'JSAPI' | 'NATIVE' | 'APP';
prepayId: string;
codeUrl?: string;
}
export interface OrderInfo {
deviceInfo?: string;
openid: string;
isSubscribe?: 'Y' | 'N';
tradeType: 'JSAPI' | 'NATIVE' | 'APP' | 'MICROPAY';
tradeState: 'SUCCESS' | 'REFUND' | 'NOTPAY' | 'CLOSED' | 'REVOKED' | 'USERPAYING' | 'PAYERROR';
bankType: string;
totalFee: number;
settlementTotalFee?: number;
feeType?: string;
cashFee: number;
cashFeeType?: string;
couponFee?: number;
couponCount?: number;
transactionId: string;
outTradeNo: string;
attach?: string;
timeEnd: string;
tradeStateDesc: string;
coupon?: Array<{
type?: 'CASH' | 'NO_CASH';
id?: string;
fee?: number;
}>;
}
export interface RefundReq {
transactionId?: string;
outTradeNo?: string;
outRefundNo: string;
totalFee: number;
refundFee: number;
refundFeeType?: string;
refundDesc?: string;
refundAccount?: 'REFUND_SOURCE_UNSETTLED_FUNDS' | 'REFUND_SOURCE_RECHARGE_FUNDS';
notifyUrl?: string;
}
export interface RefundResp {
transactionId: string;
outTradeNo: string;
outRefundNo: string;
refundId: string;
refundFee: number;
settlementRefundFee?: number;
totalFee: number;
settlementTotalFee?: number;
feeType?: string;
cashFee: number;
cashFeeType?: string;
cashRefundFee?: number;
couponRefundFee?: number;
couponRefundCount?: number;
coupon?: Array<{
type?: 'CASH' | 'NO_CASH';
refundFee?: number;
refundId?: string;
}>;
}
export interface Refund {
totalRefundCount?: number;
transactionId: string;
outTradeNo: string;
totalFee: number;
settlementTotalFee?: number;
feeType?: string;
cashFee: number;
refundCount: number;
refund: Array<{
outRefundNo?: string;
refundId?: string;
refundChannel?: 'ORIGINAL' | 'BALANCE' | 'OTHER_BALANCE' | 'OTHER_BANKCARD';
refundFee?: number;
settlementRefundFee?: number;
couponRefundFee?: number;
couponRefundCount?: number;
coupon?: Array<{
type?: 'CASH' | 'NO_CASH';
refundId?: string;
refundFee?: number;
}>;
refundStatus?: 'SUCCESS' | 'REFUNDCLOSE' | 'PROCESSING' | 'CHANGE';
refundAccount?: 'REFUND_SOURCE_RECHARGE_FUNDS' | 'REFUND_SOURCE_UNSETTLED_FUNDS';
refundRecvAccout?: string;
refundSuccessTime?: string;
}>;
}
export declare class WechatPay {
private readonly appid;
private readonly mchid;
private readonly key;
private readonly pfx;
private readonly passphrase;
private sandbox;
constructor(appid: string, mchid: string, key: string, pfx?: Buffer, passphrase?: string);
private _endpoint;
endpoint: string;
defaults: UrlLibOptions;
setOpts(opts: UrlLibOptions): void;
toggleSandbox(sandbox: boolean): void;
request(url: string, opts?: UrlLibOptions): Promise;
getKey(raw?: boolean): Promise;
getSign(params: object, signType?: 'MD5' | 'HMAC-SHA256', raw?: boolean): Promise;
_processResponse(ret: {
return_code: 'SUCCESS' | 'FAIL';
return_msg?: string;
sign?: string;
result_code?: 'SUCCESS' | 'FAIL';
err_code?: string;
err_code_des?: string;
}, signType?: 'MD5' | 'HMAC-SHA256'): Promise