From d44996fc5fcfdc3d4debca1833e035ca0ee1324e Mon Sep 17 00:00:00 2001 From: Jeff Liu Date: Fri, 26 Jan 2018 16:23:52 +0800 Subject: [PATCH] =?UTF-8?q?middleware=E6=94=AF=E6=8C=81=E5=8A=A8=E6=80=81c?= =?UTF-8?q?onfig:=20req.wxpayconfig=20#56?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/middleware.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/middleware.js b/lib/middleware.js index 112d4fd..855bc3f 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -48,6 +48,9 @@ Basic.prototype.done = function (handler) { var self = this; var payment = self.payment; return function (req, res, next) { + if(req.wxpayconfig){ + payment = new Payment(req.wxpayconfig); + } if (req.method !== 'POST') { var error = new Error(); error.name = 'NotImplemented'; @@ -131,6 +134,10 @@ Refund.prototype.done = function (handler) { var key = self.key; return function (req, res, next) { + if(req.wxpayconfig){ + payment = new Payment(req.wxpayconfig); + key = md5(req.wxpayconfig.partnerKey).toLowerCase(); + } if (req.method !== 'POST') { var error = new Error(); error.name = 'NotImplemented';