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;
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);
}
}

View file

@ -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) {