From 4159c5aa5b4ea452c1261ce285d55fc7d192b419 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 8 Aug 2014 14:10:18 -0700 Subject: [PATCH] paypro: fix sendPaymentTx to be in line with sendTx. --- js/models/core/Wallet.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index 9cbe857e5..804742fc9 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -1062,14 +1062,14 @@ Wallet.prototype.sendPaymentTx = function(ntxid, options, cb) { data = PayPro.PaymentACK.decode(data); var ack = new PayPro(); ack = ack.makePaymentACK(data); - return self.receivePaymentRequestACK(tx, txp, ack, cb); + return self.receivePaymentRequestACK(ntxid, tx, txp, ack, cb); }) .error(function(data, status, headers, config) { return cb(new Error('Status: ' + JSON.stringify(status))); }); }; -Wallet.prototype.receivePaymentRequestACK = function(tx, txp, ack, cb) { +Wallet.prototype.receivePaymentRequestACK = function(ntxid, tx, txp, ack, cb) { var self = this; var payment = ack.get('payment'); @@ -1082,10 +1082,19 @@ Wallet.prototype.receivePaymentRequestACK = function(tx, txp, ack, cb) { var pay = new PayPro(); payment = pay.makePayment(payment); + txp.merchant.ack = { + memo: memo + }; + var tx = payment.message.transactions[0]; if (!tx) { - return cb(); + this.log('Sending to server was not met with a returned tx.'); + return this._checkSentTx(ntxid, function(txid) { + self.log('[Wallet.js.1048:txid:%s]', txid); + if (txid) self.store(); + return cb(txid, txp.merchant); + }); } if (tx.buffer) { @@ -1096,11 +1105,14 @@ Wallet.prototype.receivePaymentRequestACK = function(tx, txp, ack, cb) { tx = ptx; } - txp.merchant.ack = { - memo: memo - }; - var txid = tx.getHash().toString('hex'); + var txHex = tx.serialize().toString('hex'); + this.log('Raw transaction: ', txHex); + this.log('BITCOIND txid:', txid); + this.txProposals.get(ntxid).setSent(txid); + this.sendTxProposal(ntxid); + this.store(); + return cb(txid, txp.merchant); };