fixed paypro

This commit is contained in:
Ivan Socolsky 2014-10-31 16:10:11 -03:00
parent de7bfe90e0
commit a685fd77f1
3 changed files with 19 additions and 11 deletions

View File

@ -143,7 +143,7 @@ angular.module('copayApp.controllers').controller('SendController',
if (merchantData.pr.ca) {
message += ' This payment protocol transaction' + ' has been verified through ' + merchantData.pr.ca + '.';
}
message += ' Message from server: ' + merchantData.ack.memo;
message += ' Message from server: ' + merchantData.pr.pd.memo;
message += ' For merchant: ' + merchantData.pr.pd.payment_url;
}
notification.success('Success', message);
@ -156,7 +156,7 @@ angular.module('copayApp.controllers').controller('SendController',
if (merchantData.pr.ca) {
message += ' This payment protocol transaction' + ' has been verified through ' + merchantData.pr.ca + '.';
}
message += ' Message from server: ' + merchantData.ack.memo;
message += ' Message from server: ' + merchantData.pr.pd.memo;
message += ' For merchant: ' + merchantData.pr.pd.payment_url;
}
notification.success('Transaction broadcasted', message);
@ -464,6 +464,7 @@ angular.module('copayApp.controllers').controller('SendController',
// whether we're in the Send scope or not.
if (!scope.sendForm || !scope.sendForm.address) {
delete $rootScope.merchant;
$rootScope.merchantError = false;
if (callback) callback();
return;
}
@ -547,9 +548,8 @@ angular.module('copayApp.controllers').controller('SendController',
var balance = $rootScope.availableBalance;
var available = +(balance * w.settings.unitToSatoshi).toFixed(0);
if (merchantData && available < +merchantData.total) {
err = new Error('No unspent outputs available.');
err = new Error('Insufficient funds.');
err.amount = merchantData.total;
}

View File

@ -1434,7 +1434,7 @@ Wallet.prototype.createPaymentTx = function(options, cb) {
return self.receivePaymentRequest(options, pr, cb);
})
.error(function(data, status, headers, config) {
log.debug('Server was did not return PaymentRequest.');
log.debug('Server did not return PaymentRequest.');
log.debug('XHR status: ' + status);
if (options.fetch) {
return cb(new Error('Status: ' + status));
@ -1592,6 +1592,8 @@ Wallet.prototype.receivePaymentRequest = function(options, pr, cb) {
self.sendIndexes();
self.sendTxProposal(ntxid);
self.emit('txProposalsUpdated');
} else {
return cb(new Error('Error creating the transaction'));
}
log.debug('You are currently on this BTC network:', network);
@ -1867,9 +1869,15 @@ Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent)
merchantData.total = merchantData.total.toString(10);
var b = new Builder(opts)
.setUnspent(unspent)
.setOutputs(outs);
var b;
try {
b = new Builder(opts)
.setUnspent(unspent)
.setOutputs(outs);
} catch (e) {
log.debug(e.message);
return;
};
merchantData.pr.pd.outputs.forEach(function(output, i) {
var script = {
@ -2304,7 +2312,7 @@ Wallet.prototype.createTx = function(toAddress, amountSatStr, comment, opts, cb)
var ntxid = self.createTxSync(toAddress, amountSatStr, comment, safeUnspent, opts);
if (!ntxid) {
return cb(new Error('Error creating the Transaction'));
return cb(new Error('Error creating the transaction'));
}
self.sendIndexes();

View File

@ -72,7 +72,7 @@
</label>
<div class="small-9 columns">
<input type="number" id="amount"
ng-disabled="loading || ($root.merchant && +$root.merchant.total > 0) || $root.merchantError"
ng-disabled="loading || ($root.merchant && +$root.merchant.total > 0)"
name="amount" placeholder="{{'Amount'|translate}}" ng-model="amount"
min="0.00000001" max="10000000000" valid-amount required
autocomplete="off">
@ -95,7 +95,7 @@
<label for="alternative"><span translate>Amount in</span> {{ alternativeName }} </label>
<div class="small-9 columns">
<input type="number" id="alternative_amount"
ng-disabled="loading || !isRateAvailable || ($root.merchant && +$root.merchant.total > 0) || $root.merchantError"
ng-disabled="loading || !isRateAvailable || ($root.merchant && +$root.merchant.total > 0)"
name="alternative" placeholder="{{'Amount'|translate}}" ng-model="alternative"
required
autocomplete="off"