Commit 309287ad authored by 任国军's avatar 任国军

add notify log

parent 7a4e2434
Pipeline #24554 passed with stage
in 1 minute 38 seconds
...@@ -88,7 +88,6 @@ class WechatController extends Controller { ...@@ -88,7 +88,6 @@ class WechatController extends Controller {
// 支付回调 // 支付回调
async payNotify() { async payNotify() {
const { ctx } = this; const { ctx } = this;
ctx.set('Content-Type', 'text/xml');
// 组装xml数据 // 组装xml数据
let xmlData = '<xml>'; let xmlData = '<xml>';
xmlData += '<return_code><![CDATA[SUCCESS]]></return_code>'; xmlData += '<return_code><![CDATA[SUCCESS]]></return_code>';
...@@ -96,11 +95,14 @@ class WechatController extends Controller { ...@@ -96,11 +95,14 @@ class WechatController extends Controller {
xmlData += '</xml>'; xmlData += '</xml>';
ctx.body = xmlData; ctx.body = xmlData;
ctx.logger.info('notify_headers: ' + JSON.stringify(ctx.request.header));
let data = ''; let data = '';
ctx.req.setEncoding('utf8'); ctx.req.setEncoding('utf8');
ctx.req.on('data', function(chunk) { ctx.req.on('data', function(chunk) {
data += chunk; data += chunk;
}); });
const getxml = await new Promise(function(resolve) { const getxml = await new Promise(function(resolve) {
ctx.req.on('end', function() { ctx.req.on('end', function() {
resolve(data); resolve(data);
...@@ -124,6 +126,7 @@ class WechatController extends Controller { ...@@ -124,6 +126,7 @@ class WechatController extends Controller {
} }
} }
ctx.set('Content-Type', 'text/xml');
return ctx.body; return ctx.body;
} }
} }
......
...@@ -145,7 +145,7 @@ module.exports = appInfo => { ...@@ -145,7 +145,7 @@ module.exports = appInfo => {
}, },
enableTypes: [ 'json', 'form', 'text' ], enableTypes: [ 'json', 'form', 'text' ],
extendTypes: { extendTypes: {
text: [ 'text/xml', 'application/xml', 'application/x-www-form-urlencoded' ], text: [ 'text/xml', 'application/xml', 'text/html' ],
}, },
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment