diff --git a/README.md b/README.md index ba21a21..7a969a9 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,7 @@ try { |v2.0.2|增加敏感信息加密方法(publicEncrypt)| |v2.0.3|修复get请求无参时的签名| |v2.0.4|修复敏感信息加密方法(publicEncrypt)使用微信平台公钥| +|v2.0.5|修复发起商家转账零钱参数wx_serial_no(自定义参数,即http请求头Wechatpay-Serial的值)为可选参数| ## 文档 [v2支付文档](https://pay.weixin.qq.com/wiki/doc/api/index.html) diff --git a/docs/batches_transfer.md b/docs/batches_transfer.md index cc45094..3df3f84 100644 --- a/docs/batches_transfer.md +++ b/docs/batches_transfer.md @@ -24,7 +24,7 @@ const res = await pay.batches_transfer({ batch_remark: '2019年1月深圳分部报销单', total_amount: 4000000, total_num: 200, - wx_serial_no: certificate.serial_no, + wx_serial_no: certificate.serial_no, // 当你需要传user_name时 需要传当前参数 transfer_detail_list: [ { out_detail_no: 'x23zy545Bd5436', diff --git a/index.ts b/index.ts index 77e63bd..c90e472 100644 --- a/index.ts +++ b/index.ts @@ -689,16 +689,16 @@ class Pay extends Base { public async batches_transfer(params: BatchesTransfer.Input): Promise { const url = 'https://api.mch.weixin.qq.com/v3/transfer/batches'; // 请求参数 - const _params = Object.assign({ + const _params = { appid: this.appid, ...params, - }); + }; - const serial_no = _params.wx_serial_no; + const serial_no = _params?.wx_serial_no; delete _params.wx_serial_no; const authorization = this.init('POST', url, _params); - return await this.postRequestV2(url, _params, authorization, { 'Wechatpay-Serial': serial_no }); + return await this.postRequestV2(url, _params, authorization, { ...(serial_no && { 'Wechatpay-Serial': serial_no }) }); } /** * 微信批次单号查询批次单API diff --git a/lib/interface-v2.ts b/lib/interface-v2.ts index 3479a53..f4be77e 100644 --- a/lib/interface-v2.ts +++ b/lib/interface-v2.ts @@ -42,8 +42,8 @@ export declare namespace BatchesTransfer { total_num: number; /** 转账明细列表 */ transfer_detail_list: TransferDetailList[]; - /** 微信平台证书序列号 */ - wx_serial_no: string; + /** 微信平台证书序列号-Wechatpay-Serial(当有敏感信息加密时,需要当前参数) */ + wx_serial_no?: string; } export interface DataOutput { diff --git a/package.json b/package.json index ac5b39d..026724c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechatpay-node-v3", - "version": "2.0.4", + "version": "2.0.5", "description": "微信支付文档v3", "main": "dist/index.js", "types": "dist/index.d.ts",