diff --git a/lib/wxpay.js b/lib/wxpay.js index 969ac13..ce094ed 100644 --- a/lib/wxpay.js +++ b/lib/wxpay.js @@ -72,7 +72,13 @@ WXPay.mix('createUnifiedOrder', function(opts, fn){ passphrase: this.options.mch_id } }, function(err, response, body){ - util.parseXML(body, fn); + util.parseXML(body, function(err, result){ + if (err) { + return fn(err) + } + result.nonce_str = opts.nonce_str + fn(null, result) + }); }); }); @@ -81,6 +87,10 @@ WXPay.mix('getBrandWCPayRequestParams', function(order, fn){ order.trade_type = "JSAPI"; var _this = this; this.createUnifiedOrder(order, function(err, data){ + if (data.return_code === 'FAIL') { + fn(data) + return + } var reqparam = { appId: _this.options.appid, timeStamp: Math.floor(Date.now()/1000)+"",