From 5c9bb4982d15fedc8808d888a444d76b0eace628 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 15 Sep 2014 18:51:12 -0700 Subject: [PATCH] paypro: fix signature error. fix merchant_data. see #1409. --- app.js | 3 +++ js/models/core/Wallet.js | 24 ++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app.js b/app.js index d531b0274..ea1e50f42 100644 --- a/app.js +++ b/app.js @@ -20,6 +20,9 @@ app.start = function(port, callback) { pserver.removeListener('request', pserver.app); + // pserver.options['no-tx'] = true; + // pserver.options['discovery'] = true; + pserver.on('request', function(req, res) { if (req.url.indexOf('/-/') === 0) { return pserver.app(req, res); diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index 4246c3a0e..2a9faadc0 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -841,7 +841,7 @@ Wallet.prototype.store = function(cb) { this.keepAlive(); this.storage.setFromObj(this.id, this.toObj(), function(err) { log.debug('Wallet stored'); - if (cb) + if (cb) cb(err); }); }; @@ -1416,9 +1416,9 @@ Wallet.prototype.receivePaymentRequest = function(options, pr, cb) { expires: expires, memo: memo || 'This server would like some BTC from you.', payment_url: payment_url, - merchant_data: merchant_data ? merchant_data.toString('hex') - // : new Buffer('none', 'utf8').toString('hex') - : '00' + merchant_data: merchant_data + ? merchant_data.toString('hex') + : null }, signature: sig.toString('hex'), ca: trust.caName, @@ -1540,8 +1540,10 @@ Wallet.prototype.sendPaymentTx = function(ntxid, options, cb) { var pay = new PayPro(); pay = pay.makePayment(); var merchant_data = txp.merchant.pr.pd.merchant_data; - merchant_data = new Buffer(merchant_data, 'hex'); - pay.set('merchant_data', merchant_data); + if (merchant_data) { + merchant_data = new Buffer(merchant_data, 'hex'); + pay.set('merchant_data', merchant_data); + } pay.set('transactions', [tx.serialize()]); pay.set('refund_to', refund_outputs); @@ -1582,7 +1584,13 @@ Wallet.prototype.sendPaymentTx = function(ntxid, options, cb) { return self.receivePaymentRequestACK(ntxid, tx, txp, ack, cb); }) .error(function(data, status, headers, config) { - return cb(new Error('Status: ' + status)); + log.debug('Sending to server was not met with a returned tx.'); + log.debug('XHR status: ' + status); + return self._checkSentTx(ntxid, function(txid) { + log.debug('[Wallet.js.1581:txid:%s]', txid); + if (txid) self.store(); + return cb(txid, txp.merchant); + }); }); }; @@ -1611,7 +1619,7 @@ Wallet.prototype.receivePaymentRequestACK = function(ntxid, tx, txp, ack, cb) { if (!tx) { log.debug('Sending to server was not met with a returned tx.'); return this._checkSentTx(ntxid, function(txid) { - self.log('[Wallet.js.1048:txid:%s]', txid); + log.debug('[Wallet.js.1613:txid:%s]', txid); if (txid) self.store(); return cb(txid, txp.merchant); });