From c940cb25b5d086a2e4d29f2ab1bf69bb8e7f35ba Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 4 Aug 2014 10:47:04 -0700 Subject: [PATCH] paypro: return merchantData in createTx and sendTx. --- js/controllers/send.js | 36 +++++++++++++++--------------------- js/models/core/Wallet.js | 4 ++-- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/js/controllers/send.js b/js/controllers/send.js index 88c3101b7..5af53273a 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -61,30 +61,28 @@ angular.module('copayApp.controllers').controller('SendController', var w = $rootScope.wallet; - function done(ntxid, ca) { - var txp = w.txProposals.txps[ntxid]; - var merchantData = txp.merchant; + function done(ntxid, merchantData) { if (w.isShared()) { $scope.loading = false; var message = 'The transaction proposal has been created'; - if (ca) { - message += '\nThis payment protocol transaction' - + ' has been verified through ' + ca + '.'; - } if (merchantData) { + if (merchantData.pr.ca) { + message += '\nThis payment protocol transaction' + + ' has been verified through ' + merchantData.pr.ca + '.'; + } message += '\nFor merchant: ' + merchantData.pr.pd.payment_url; } notification.success('Success!', message); $scope.loadTxs(); } else { - w.sendTx(ntxid, function(txid, ca) { + w.sendTx(ntxid, function(txid, merchantData) { if (txid) { var message = 'Transaction id: ' + txid; - if (ca) { - message += '\nThis payment protocol transaction' - + ' has been verified through ' + ca + '.'; - } if (merchantData) { + if (merchantData.pr.ca) { + message += '\nThis payment protocol transaction' + + ' has been verified through ' + merchantData.pr.ca + '.'; + } message += '\nFor merchant: ' + merchantData.pr.pd.payment_url; } notification.success('Transaction broadcast', message); @@ -332,23 +330,19 @@ angular.module('copayApp.controllers').controller('SendController', $scope.loading = true; $rootScope.txAlertCount = 0; var w = $rootScope.wallet; - w.sendTx(ntxid, function(txid, ca) { + w.sendTx(ntxid, function(txid, merchantData) { if (!txid) { notification.error('Error', 'There was an error sending the transaction'); } else { - if (!ca) { + if (!merchantData) { notification.success('Transaction broadcast', 'Transaction id: '+txid); } else { - var txp = w.txProposals.txps[ntxid]; - var merchantData = txp.merchant; var message = 'Transaction ID: ' + txid; - if (ca) { + if (merchantData.pr.ca) { message += '\nThis payment protocol transaction' - + ' has been verified through ' + ca + '.'; - } - if (merchantData) { - message += '\nFor merchant: ' + merchantData.pr.pd.payment_url; + + ' has been verified through ' + merchantData.pr.ca + '.'; } + message += '\nFor merchant: ' + merchantData.pr.pd.payment_url; notification.success('Transaction sent', message); } } diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index 98535ed0e..79801267c 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -943,7 +943,7 @@ Wallet.prototype.receivePaymentRequest = function(options, pr, cb) { self.log('The server sent you a message:'); self.log(memo); - return cb(ntxid, ca); + return cb(ntxid, merchantData); }); }; @@ -1083,7 +1083,7 @@ Wallet.prototype.receivePaymentRequestACK = function(tx, txp, ack, cb) { } var txid = tx.getHash().toString('hex'); - return cb(txid, txp.merchant.pr.ca); + return cb(txid, txp.merchant); }; Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent) {