/// /// import { APPPayRequest, CreateCardTemplateRequest, CreateCardTemplateResponse, DevelopmentConfigRequest, FapiaoNotifyResult, GetIssueFapiaoResponse, GetUserTitleParams, GroupRedPackData, IssueFapiaoRequest, JSAPIPayRequest, MiniProgramPayRequest, RedPackData, RefundNotifyResult, RefundParameters, RefundResult, RequireOnlyOne, ReverseFapiaoRequest, SignatureHeaders, Trade, TransactionOrder, UserTitleEntity } from './types'; import type { Request, Response } from 'express'; import { CreateCardTemplateRequestOfPartner, DevelopmentConfigRequestOfPartner, FapiaoNotifyResultOfPartner, IssueFapiaoRequestOfPartner, RefundNotifyResultOfPartner, RefundParametersOfPartner, ReverseFapiaoRequestOfPartner, TradeOfPartner, TransactionOrderOfPartner } from './types/wepay-partner'; export declare class WePayService { private readonly debug; API_ROOT: string; private readonly logger; constructor(debug?: boolean); /** * 获取平台证书列表 * @param mchId * @param serialNo * @param privateKey * @param apiKey * @returns * @link https://pay.weixin.qq.com/wiki/doc/apiv3/apis/wechatpay5_1.shtml */ getPlatformCertificates(mchId: string, serialNo: string, privateKey: Buffer | string, apiKey: string): Promise>; /** * 统一下单接口 * @param type 支付类型: jsapi/h5/native/app * @param order 下单信息 * @param serialNo 私钥序列号 * @param privateKey 私钥 * @returns * @link https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_1.shtml */ unifiedOrder(type: 'jsapi' | 'h5' | 'native' | 'app', order: TransactionOrder, serialNo: string, privateKey: Buffer | string): Promise>; /** * JSAPI下单 * @param order 下单信息 * @param serialNo 私钥序列号 * @param privateKey 私钥 * @returns * @link https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_1.shtml */ jsapi(order: TransactionOrder, serialNo: string, privateKey: Buffer | string): Promise>; /** * H5下单 * @param order 下单信息 * @param serialNo 私钥序列号 * @param privateKey 私钥 * @returns * @link https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_3_1.shtml */ h5(order: TransactionOrder, serialNo: string, privateKey: Buffer | string): Promise>; /** * Native下单 * @param order 下单信息 * @param serialNo 私钥序列号 * @param privateKey 私钥 * @returns * @link https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_4_1.shtml */ native(order: TransactionOrder, serialNo: string, privateKey: Buffer | string): Promise>; /** * APP下单 * @param order 下单信息 * @param serialNo 私钥序列号 * @param privateKey 私钥 * @returns * @link https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_2_1.shtml */ app(order: TransactionOrder, serialNo: string, privateKey: Buffer | string): Promise>; /** * 服务端JSAPI下单 * @param order 下单信息 * @param serialNo 私钥序列号 * @param privateKey 私钥 * @returns * @link https://pay.weixin.qq.com/docs/partner/apis/partner-jsapi-payment/partner-jsons/partner-jsapi-prepay.html */ jsapiOfPartner(order: TransactionOrderOfPartner, serialNo: string, privateKey: Buffer | string): Promise>; /** * 微信支付订单号查询订单 * @param id * @param mchId * @param serialNo * @param privateKey * @returns * @link https://pay.weixin.qq.com/docs/merchant/apis/jsapi-payment/query-by-wx-trade-no.html */ getTransactionById(id: string, mchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 服务商微信支付订单号查询订单 * @param id * @param spMchId * @param subMchid * @param serialNo * @param privateKey * @returns * @link https://pay.weixin.qq.com/docs/partner/apis/partner-jsapi-payment/query-by-wx-trade-no.html */ getTransactionByIdOfPartner(id: string, spMchId: string, subMchid: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 商户订单号查询订单 * @param outTradeNo * @param mchId * @param serialNo * @param privateKey * @returns * @link https://pay.weixin.qq.com/docs/merchant/apis/jsapi-payment/query-by-out-trade-no.html */ getTransactionByOutTradeNo(outTradeNo: string, mchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 服务商按商户订单号查询订单 * @param outTradeNo * @param spMchId * @param serialNo * @param privateKey * @returns * @link https://pay.weixin.qq.com/docs/partner/apis/partner-jsapi-payment/query-by-out-trade-no.html */ getTransactionByOutTradeNoOfPartner(outTradeNo: string, spMchId: string, subMchid: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 关闭订单 * @param outTradeNo * @param mchId * @param serialNo * @param privateKey * @returns * @link https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_3.shtml */ close(outTradeNo: string, mchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 关闭订单 * @param outTradeNo * @param spMchId * @param subMchId * @param serialNo * @param privateKey * @returns * @link https://pay.weixin.qq.com/docs/partner/apis/partner-jsapi-payment/close-order.html */ closeOfPartner(outTradeNo: string, spMchId: string, subMchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 申请退款 * @param refund * @param mchId * @param serialNo * @param privateKey * @returns * @link https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_9.shtml */ refund(refund: RequireOnlyOne, mchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 服务商申请退款 * @param refund * @param spMchId * @param serialNo * @param privateKey * @returns * @link https://pay.weixin.qq.com/docs/partner/apis/partner-jsapi-payment/create.html */ refundOfPartner(refund: RequireOnlyOne, spMchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 查询单笔退款 * @param outRefundNo * @param mchId * @param serialNo * @param privateKey * @returns * @link https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_10.shtml */ getRefund(outRefundNo: string, mchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 服务商查询单笔退款 * @param outRefundNo * @param spMchId * @param subMchId * @param serialNo * @param privateKey * @returns * @link https://pay.weixin.qq.com/docs/partner/apis/partner-jsapi-payment/query-by-out-refund-no.html */ getRefundOfPartner(outRefundNo: string, spMchId: string, subMchId: string, serialNo: string, privateKey: Buffer | string): Promise>; private getTradeBill; private getFlowBill; /** * 支付通知处理程序 * @param certs 微信支付平台证书 * @param apiKey * @param req * @param res * @returns * @link https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_5.shtml */ paidCallback(certs: Map, apiKey: string, req: Request, res: Response): Promise; /** 电子发票 **/ /** * 配置开发选项 * * @link https://pay.weixin.qq.com/docs/merchant/apis/fapiao/fapiao-merchant/update-development-config.html */ fapiaoDevConfig(data: DevelopmentConfigRequest, mchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 查询商户配置的开发选项 * * @link https://pay.weixin.qq.com/docs/merchant/apis/fapiao/fapiao-merchant/query-development-config.html */ getFapiaoDevConfig(mchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 服务端为特约商户配置开发选项 * * @link https://pay.weixin.qq.com/docs/partner/apis/fapiao/fapiao-merchant/update-development-config.html */ fapiaoDevConfigOfPartner(data: DevelopmentConfigRequestOfPartner, spMchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 服务商查询商户配置的开发选项 * * @link https://pay.weixin.qq.com/docs/partner/apis/fapiao/fapiao-merchant/query-development-config.html */ getFapiaoDevConfigOfPartner(spMchId: string, subMchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 创建电子发票卡券模板 * * @link https://pay.weixin.qq.com/docs/merchant/apis/fapiao/fapiao-card-template/create-fapiao-card-template.html */ createCardTemplate(data: CreateCardTemplateRequest, mchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 服务商创建电子发票卡券模板 * * @link https://pay.weixin.qq.com/docs/partner/apis/fapiao/fapiao-card-template/create-fapiao-card-template.html */ createCardTemplateOfPartner(data: CreateCardTemplateRequestOfPartner, spMchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 微信发票通知 * @link https://pay.weixin.qq.com/docs/merchant/apis/fapiao/fapiao-card-template/user-invoice-rise-write-notice.html */ fapiaoCallback(certs: Map, apiKey: string, req: Request, res: Response): Promise; /** * 服务商微信发票通知 * @link https://pay.weixin.qq.com/docs/partner/apis/fapiao/fapiao-card-template/user-invoice-rise-write-notice.html */ fapiaoCallbackOfPartner(certs: Map, apiKey: string, req: Request, res: Response): Promise; /** * 获取用户填写的抬头 * * @link https://pay.weixin.qq.com/docs/merchant/apis/fapiao/user-title/get-user-title.html */ getUserTitle(params: GetUserTitleParams, mchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 服务商获取用户填写的抬头 * * @link https://pay.weixin.qq.com/docs/partner/apis/fapiao/user-title/get-user-title.html */ getUserTitleOfPartner(params: GetUserTitleParams, spMchId: string, subMchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 开具电子发票 * * @link https://pay.weixin.qq.com/docs/merchant/apis/fapiao/fapiao-applications/issue-fapiao-applications.html */ issueFapiao(data: IssueFapiaoRequest, mchId: string, serialNo: string, privateKey: Buffer | string, platformSerial: string): Promise>; /** * 服务商开具电子发票 * * @link https://pay.weixin.qq.com/docs/partner/apis/fapiao/fapiao-applications/issue-fapiao-applications.html */ issueFapiaoOfPartner(data: IssueFapiaoRequestOfPartner, spMchId: string, serialNo: string, privateKey: Buffer | string, platformSerial: string): Promise>; /** * 查询电子发票 * * @link https://pay.weixin.qq.com/docs/merchant/apis/fapiao/fapiao-applications/get-fapiao-applications.html */ getIssueFapiao(fapiaoApplyId: string, fapiaoId: string | null | undefined, mchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 服务商查询电子发票 * * @link https://pay.weixin.qq.com/docs/partner/apis/fapiao/fapiao-applications/get-fapiao-applications.html */ getIssueFapiaoOfPartner(fapiaoApplyId: string, fapiaoId: string | null | undefined, spMchId: string, subMchid: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 冲红电子发票 * * @link https://pay.weixin.qq.com/docs/merchant/apis/fapiao/fapiao-applications/reverse-fapiao-applications.html */ reverseFapiao(fapiaoApplyId: string, data: ReverseFapiaoRequest, mchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** * 服务商冲红电子发票 * * @link https://pay.weixin.qq.com/docs/partner/apis/fapiao/fapiao-applications/reverse-fapiao-applications.html */ reverseFapiaoOfPartner(fapiaoApplyId: string, data: ReverseFapiaoRequestOfPartner, spMchId: string, serialNo: string, privateKey: Buffer | string): Promise>; /** 电子发票 **/ /** * 敏感信息加解密 * * 解密算法 * * @param cipherText base64密文 * @param privateKey 私钥证书 * @returns * @link https://wechatpay-api.gitbook.io/wechatpay-api-v3/qian-ming-zhi-nan-1/min-gan-xin-xi-jia-mi */ rsaDecryptOAEP(cipherText: string, privateKey: Buffer | string): Buffer; /** * 敏感信息加解密 * * 加密算法 * * @param text 明文 * @param publicKey 公钥证书 * @returns * @link https://wechatpay-api.gitbook.io/wechatpay-api-v3/qian-ming-zhi-nan-1/min-gan-xin-xi-jia-mi */ rsaEncryptOAEP(text: string, publicKey: Buffer | string): Buffer; /** * 退款结果通知 * * 实现与付款通知一样,解密后数据结构不同,直接复用付款通知实现 * * @param certs * @param apiKey * @param req * @param res * @returns * @tutorial https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_11.shtml */ refundedCallback(certs: Map, apiKey: string, req: Request, res: Response): Promise; /** * 服务商退款结果通知处理 * * 实现与付款通知一样,解密后数据结构不同,直接复用付款通知实现 * * @param certs * @param apiKey * @param req * @param res * @returns * @link https://pay.weixin.qq.com/docs/partner/apis/partner-jsapi-payment/refund-result-notice.html */ refundedCallbackOfPartner(certs: Map, apiKey: string, req: Request, res: Response): Promise; /** * 服务商支付通知处理程序 * @param certs 微信支付平台证书 * @param apiKey * @param req * @param res * @returns * @link https://pay.weixin.qq.com/docs/partner/apis/partner-jsapi-payment/payment-notice.html */ paidCallbackOfPartner(certs: Map, apiKey: string, req: Request, res: Response): Promise; callbackHandlerForExpress(certs: Map, apiKey: string, req: Request, res: Response): Promise<{ result: string | T; callbackBody: undefined; }>; callbackHandler(certs: Map, apiKey: string, headers: SignatureHeaders, body: Buffer | string): { result: string | T; callbackBody: undefined; }; getCallbackSignatureParameters(headers: SignatureHeaders): { signature: string; platformSerial: string; timestamp: string; nonce: string; }; /** 现金红包 **/ /** * * 发放红包接口 * * @param redPack * @param appId * @param mchId * @param apiKey * @param publicKey * @param privateKey * @param group 是否裂变红包,默认否 * @returns XML字符串 * @link https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_4&index=3 */ sendRedPack(redPack: RedPackData, appId: string, mchId: string, apiKey: string, publicKey: Buffer | string, privateKey: Buffer | string, group?: boolean): Promise>; /** * 发放裂变红包 * @param redPack * @param appId * @param mchId * @param apiKey * @param publicKey * @param privateKey * @returns XML字符串 * @link https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5&index=4 */ sendGroupRedPack(redPack: GroupRedPackData, appId: string, mchId: string, apiKey: string, publicKey: Buffer | string, privateKey: Buffer | string): Promise>; getHbInfo(billNO: string, appId: string, mchId: string, apiKey: string, publicKey: Buffer | string, privateKey: Buffer | string): Promise>; /** 现金红包 **/ /** * * 报文解密 * * 密文是json时,返回对象,类型是T * 密文是string时,返回string * * @param apiKey * @param cipher * @param associatedData * @param nonce * @returns * @link https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_2.shtml */ decryptCipherText(apiKey: string, cipher: string, associatedData: string, nonce: string): T | string; /** * 回调或者通知签名验证方法 * @param publicKey * @param timestamp * @param nonce * @param body * @param signature * @returns */ verifySignature(publicKey: Buffer | string, timestamp: string, nonce: string, body: string | object, signature: string): boolean; /** * 构造小程序调起支付参数 * @param appId String 小程序APPID * @param prepayId String JSAPI下单生成的prepay_id * @param privateKey String 微信支付私钥 * @returns MiniProgramPaymentParameters * @link https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_4.shtml */ buildMiniProgramPayment(appId: string, prepayId: string, privateKey: Buffer | string): MiniProgramPayRequest; /** * * 构造JSAPI拉起支付参数 * * @param appId 商户申请的公众号对应的AppID,由微信支付生成,可在公众号后台查看。服务商模式若下单时传了sub_appid,可为sub_appid的值。 * @param prepayId JSAPI下单生成的prepay_id * @param privateKey 微信支付私钥 * @returns MiniProgramPaymentParameters * @link https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_4.shtml */ buildJSAPIParameters(appId: string, prepayId: string, privateKey: Buffer | string): JSAPIPayRequest; /** * 构造 APP 拉起支付参数 * @param appId 商户申请的应用对应的AppID,由微信支付生成,可在商户平台查看。 * @param mchId 商户号 * @param prepayId APP下单生成的prepay_id * @param privateKey 微信支付私钥 * @returns APPPayRequest * @link https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_2_4.shtml */ buildAPPPayment(appId: string, mchId: string, prepayId: string, privateKey: Buffer | string): APPPayRequest; /** * 构建请求签名 * @param mchId * @param nonceStr * @param timestamp * @param serialNo * @param signature * @returns */ private generateHeader; /** * 生成请求签名串 * @param method * @param url * @param timestamp * @param nonceStr * @param privateKey * @param body * @returns */ private generateSignature; /** * 读取x509证书序列号 * @param publicKey * @returns */ getCertificateSn(publicKey: Buffer | string): string; }