diff --git a/lib/payment.js b/lib/payment.js index 5a7a0cc..70c5e1c 100644 --- a/lib/payment.js +++ b/lib/payment.js @@ -251,7 +251,7 @@ Payment.prototype._signedQuery = function(url, params, options, callback) { } var request = (options.https ? this._httpsRequest : this._httpRequest).bind(this); - request(url, this._buildXml(params), function(err, body) { + request(url, this.buildXml(params), function(err, body) { if (err) { return callback(err); } @@ -347,7 +347,7 @@ Payment.prototype._parseCsv = function(text) { }; }; -Payment.prototype._buildXml = function(obj) { +Payment.prototype.buildXml = function(obj) { var builder = new xml2js.Builder({ allowSurrogateChars: true }); @@ -469,7 +469,8 @@ Payment.prototype._generateNonceStr = function(length) { if (global.Promise) { for (let key in Payment.prototype) { let func = Payment.prototype[key] - if (typeof func == 'function' && key.indexOf('_') !== 0) { + let syncFuncs = ['buildXml'] + if (typeof func == 'function' && key.indexOf('_') !== 0 && syncFuncs.indexOf(key) === -1) { Payment.prototype[key] = function () { let args = Array.prototype.slice.call(arguments) let originCallback = args[args.length - 1] diff --git a/package.json b/package.json index 4bfb838..814d47b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechat-pay", - "version": "0.3.1", + "version": "0.3.2", "description": "wechat payment api for document v3.3.5", "main": "index.js", "scripts": @@ -31,4 +31,4 @@ "underscore": "^1.7.0", "xml2js": "^0.4.4" } -} \ No newline at end of file +}