paypro: return merchantData in createTx and sendTx.

This commit is contained in:
Christopher Jeffrey 2014-08-04 10:47:04 -07:00 committed by Manuel Araoz
commit c940cb25b5
2 changed files with 17 additions and 23 deletions

View file

@ -61,30 +61,28 @@ angular.module('copayApp.controllers').controller('SendController',
var w = $rootScope.wallet; var w = $rootScope.wallet;
function done(ntxid, ca) { function done(ntxid, merchantData) {
var txp = w.txProposals.txps[ntxid];
var merchantData = txp.merchant;
if (w.isShared()) { if (w.isShared()) {
$scope.loading = false; $scope.loading = false;
var message = 'The transaction proposal has been created'; var message = 'The transaction proposal has been created';
if (ca) {
message += '\nThis payment protocol transaction'
+ ' has been verified through ' + ca + '.';
}
if (merchantData) { 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; message += '\nFor merchant: ' + merchantData.pr.pd.payment_url;
} }
notification.success('Success!', message); notification.success('Success!', message);
$scope.loadTxs(); $scope.loadTxs();
} else { } else {
w.sendTx(ntxid, function(txid, ca) { w.sendTx(ntxid, function(txid, merchantData) {
if (txid) { if (txid) {
var message = 'Transaction id: ' + txid; var message = 'Transaction id: ' + txid;
if (ca) {
message += '\nThis payment protocol transaction'
+ ' has been verified through ' + ca + '.';
}
if (merchantData) { 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; message += '\nFor merchant: ' + merchantData.pr.pd.payment_url;
} }
notification.success('Transaction broadcast', message); notification.success('Transaction broadcast', message);
@ -332,23 +330,19 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.loading = true; $scope.loading = true;
$rootScope.txAlertCount = 0; $rootScope.txAlertCount = 0;
var w = $rootScope.wallet; var w = $rootScope.wallet;
w.sendTx(ntxid, function(txid, ca) { w.sendTx(ntxid, function(txid, merchantData) {
if (!txid) { if (!txid) {
notification.error('Error', 'There was an error sending the transaction'); notification.error('Error', 'There was an error sending the transaction');
} else { } else {
if (!ca) { if (!merchantData) {
notification.success('Transaction broadcast', 'Transaction id: '+txid); notification.success('Transaction broadcast', 'Transaction id: '+txid);
} else { } else {
var txp = w.txProposals.txps[ntxid];
var merchantData = txp.merchant;
var message = 'Transaction ID: ' + txid; var message = 'Transaction ID: ' + txid;
if (ca) { if (merchantData.pr.ca) {
message += '\nThis payment protocol transaction' message += '\nThis payment protocol transaction'
+ ' has been verified through ' + ca + '.'; + ' has been verified through ' + merchantData.pr.ca + '.';
}
if (merchantData) {
message += '\nFor merchant: ' + merchantData.pr.pd.payment_url;
} }
message += '\nFor merchant: ' + merchantData.pr.pd.payment_url;
notification.success('Transaction sent', message); notification.success('Transaction sent', message);
} }
} }

View file

@ -943,7 +943,7 @@ Wallet.prototype.receivePaymentRequest = function(options, pr, cb) {
self.log('The server sent you a message:'); self.log('The server sent you a message:');
self.log(memo); 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'); 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) { Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent) {