From 4719bd0a30100babc358a7d9263af5ee073b5c41 Mon Sep 17 00:00:00 2001 From: James ZHANG Date: Fri, 18 Sep 2020 09:03:53 +0800 Subject: [PATCH] `Transformer.toXml` usage sample --- README.md | 12 ++++++++++++ lib/aes.js | 2 +- lib/utils.js | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 71cd8ad..7dac3c1 100644 --- a/README.md +++ b/README.md @@ -258,6 +258,18 @@ client.post('https://fraud.mch.weixin.qq.com/risk/getpublickey', { }).then(({data}) => console.info(data)).catch(({response}) => console.error(response)) ``` +### 通知应答 + +```javascript +const {Transformer} = require('wechatpay-axios-plugin') +const xml = Transformer.toXml({ + return_code: 'SUCCESS', + return_msg: 'OK', +}) + +console.info(xml) +``` + ## aes-256-ecb/pcks7padding ### v0.3.1开始支持解密 diff --git a/lib/aes.js b/lib/aes.js index cacdabd..aa300a1 100644 --- a/lib/aes.js +++ b/lib/aes.js @@ -19,7 +19,7 @@ class Aes { static get base64() { return `base64` } /** - * @property {string} BLOCK_SIZE - The `aes` block size + * @property {integer} BLOCK_SIZE - The `aes` block size */ static get BLOCK_SIZE() { return 16 } diff --git a/lib/utils.js b/lib/utils.js index 92e19aa..aca00e1 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -28,6 +28,11 @@ utils.extend(utils, { return this.isProcessEnv() && this.isObject(val) && val.toString() === '[object FormData]' }, + /** + * Compose the `User-Agent` content + * + * @returns {string} - The `User-Agent` value + */ userAgent: function() { const {name: pkgName, version: pkgVersion} = require('../package.json') const {version: axiosVersion} = require('axios/package.json')