paypro: even better notification when user has insufficient funds.
This commit is contained in:
parent
eea59bc0e1
commit
8e86826b68
2 changed files with 18 additions and 3 deletions
|
|
@ -425,12 +425,17 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
|
|
||||||
if (merchantData && available < +merchantData.total) {
|
if (merchantData && available < +merchantData.total) {
|
||||||
err = new Error('No unspent outputs available.');
|
err = new Error('No unspent outputs available.');
|
||||||
scope.notEnoughAmount = true;
|
err.amount = merchantData.total;
|
||||||
scope.sendForm.amount.$isValid = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
scope.sendForm.address.$isValid = false;
|
scope.sendForm.address.$isValid = false;
|
||||||
|
if (err.amount) {
|
||||||
|
scope.sendForm.amount.$setViewValue(+err.amount / config.unitToSatoshi);
|
||||||
|
scope.sendForm.amount.$render();
|
||||||
|
scope.sendForm.amount.$isValid = false;
|
||||||
|
scope.notEnoughAmount = true;
|
||||||
|
}
|
||||||
notification.error('Error', err.message || 'Bad payment server.');
|
notification.error('Error', err.message || 'Bad payment server.');
|
||||||
if ($rootScope.$$phase !== '$apply' && $rootScope.$$phase !== '$digest') {
|
if ($rootScope.$$phase !== '$apply' && $rootScope.$$phase !== '$digest') {
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
|
|
|
||||||
|
|
@ -932,7 +932,17 @@ Wallet.prototype.receivePaymentRequest = function(options, pr, cb) {
|
||||||
if (!unspent || !unspent.length) {
|
if (!unspent || !unspent.length) {
|
||||||
return cb(new Error('No unspent outputs available.'));
|
return cb(new Error('No unspent outputs available.'));
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
self.createPaymentTxSync(options, merchantData, unspent);
|
self.createPaymentTxSync(options, merchantData, unspent);
|
||||||
|
} catch (e) {
|
||||||
|
var msg = e.message || '';
|
||||||
|
if (msg.indexOf('not enough unspent tx outputs to fulfill')) {
|
||||||
|
var sat = /(\d+)/.exec(msg)[1];
|
||||||
|
e = new Error('No unspent outputs available.');
|
||||||
|
e.amount = sat;
|
||||||
|
return cb(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
return cb(null, merchantData, pr);
|
return cb(null, merchantData, pr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue