UNPKG

@liuhlightning/wx-pay

Version:
167 lines 4.33 kB
import { AxiosInstance, AxiosRequestConfig, AxiosResponse, CreateAxiosDefaults } from "axios"; import { buildAuthotization, checkSignature, closeTransaction, decrypto, decryptoByPrivateKey, encrypto, notifyTransactionBuilder, notifyTransactionRefundBuilder, postTransactionApp, postTransactionH5, postTransactionJsApi, postTransactionNative, queryRefund, queryTransaction, refundTransaction, sign } from "./lib"; /** * 微信支付参数 */ export interface WxPayParam { /** * appid 在微信开放平台申请 */ appId: string; /** * APIv3密钥 在商户平台设置 * * 为了保证安全性,微信支付在回调通知和平台证书下载接口中,对关键信息进行了AES-256-GCM加密。API v3密钥是加密时使用的对称密钥。 */ apiv3Key: string; /** * 商户ID 在微信支付申请 */ mchId: string; /** * 异步接收微信支付结果通知的回调地址 * * 通知url必须为外网可访问的url,不能携带参数。 * * 公网域名必须为https */ notifyUrl: string; /** * 微信支付公钥文件地址 */ wxPayPublicKeyPath: string; /** * 商户API私钥文件地址 * * 商户申请商户API证书时,会生成商户私钥,并保存在本地证书文件夹的文件apiclient_key.pem中 * * 私钥也可以通过工具从商户的p12证书中导出 * * 请妥善保管好你的商户私钥文件 */ privateKeyPath: string; /** * 商户证书序列号 */ certSerial: string; /** * 支持发票, 默认false * * 目前没有作用 */ supportFapiao?: boolean; /** * 请求的地址 */ baseURL?: string; /** * 超时时间 */ timeout?: number; /** * axios 配置 */ axiosConfig?: CreateAxiosDefaults; /** * 启用调试, 打印所有log */ debug?: boolean; } export interface WxPayRequestParam { url: string; method?: "get" | "post" | "put" | "delete"; query?: Record<string, string>; headers?: Record<string, string>; data?: unknown; } /** * 微信支付 */ export declare class WxPay { baseURL: string; appId: string; protected apiv3Key: string; mchId: string; notifyUrl: string; wxPayPublicKey: string; protected privateKey: string; certSerial: string; supportFapiao: boolean; service: AxiosInstance; request: <T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>) => Promise<R>; debug: boolean; constructor(param: WxPayParam); /** * 构造鉴权字符串 */ buildAuthorization: typeof buildAuthotization; /** * 签名 */ sign: typeof sign; /** * 检查签名 */ checkSignature: typeof checkSignature; /** * 解密, 使用APIv3密钥 */ decrypto: typeof decrypto; /** * 加密, 使用微信支付公钥 */ encrypto: typeof encrypto; /** * 解密, 使用商户API私钥 */ decryptoByPrivateKey: typeof decryptoByPrivateKey; /** * jsapi下单 小程序下单 */ postTransactionJsApi: typeof postTransactionJsApi; /** * app下单 */ postTransactionApp: typeof postTransactionApp; /** * h5下单 */ postTransactionH5: typeof postTransactionH5; /** * native下单 */ postTransactionNative: typeof postTransactionNative; /** * 构造处理支付通知函数 */ notifyTransactionBuilder: typeof notifyTransactionBuilder; /** * 处理支付通知 */ notifyTransaction: import("./lib").NotifyTransactionHandler; /** * 查询订单 */ queryTransaction: typeof queryTransaction; /** * 关闭订单 */ closeTransaction: typeof closeTransaction; /** * 退款 */ refundTransaction: typeof refundTransaction; /** * 构造退款通知处理函数 */ notifyTransactionRefundBuilder: typeof notifyTransactionRefundBuilder; /** * 退款通知处理 */ notifyTransactionRefund: import("./lib").NotifyRefundHandler; /** * 查询退款 */ queryRefund: typeof queryRefund; } //# sourceMappingURL=index.d.ts.map