Skip to content

Commit

Permalink
middleware支持动态config: req.wxpayconfig supersheep#56
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Liu committed Jan 26, 2018
1 parent cd592f4 commit d44996f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit d44996f

Please sign in to comment.