问题
微信支付成功后回调通过POS方式返回xml格式的数据,如果回调方法中没有获取到任何xml的值,则需要安装组件body-parser-xml。
安装
npm install body-parser-xml --save使用
在 app.js 里面 引入组件:
require('body-parser-xml')(bodyParser);然后使用中间件的方式,代码如下:
// 解决微信支付通知回调数据
app.use(bodyParser.xml({
limit: '2MB', // Reject payload bigger than 1 MB
xmlParseOptions: {
normalize: true, // Trim whitespace inside text nodes
normalizeTags: true, // Transform tags to lowercase
explicitArray: false // Only put nodes in array if >1
}
}));版权声明:本文为linzengfa原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。