fix params and errors handling
This commit is contained in:
parent
4fc5920c82
commit
2724911a05
2 changed files with 34 additions and 46 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('incomingData', function($log, $state, $timeout, $ionicHistory, bitcore, $rootScope, payproService, scannerService, appConfigService) {
|
||||
angular.module('copayApp.services').factory('incomingData', function($log, $state, $timeout, $ionicHistory, bitcore, $rootScope, payproService, scannerService, appConfigService, popupService, gettextCatalog) {
|
||||
|
||||
var root = {};
|
||||
|
||||
|
|
@ -93,10 +93,10 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
|
||||
if (parsed.r) {
|
||||
payproService.getPayProDetails(parsed.r, function(err, details) {
|
||||
if (err && addr && amount) {
|
||||
goSend(addr, amount, message);
|
||||
}
|
||||
handlePayPro(details);
|
||||
if (err) {
|
||||
if (addr && amount) goSend(addr, amount, message);
|
||||
else popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
} else handlePayPro(details);
|
||||
});
|
||||
} else {
|
||||
goSend(addr, amount, message);
|
||||
|
|
|
|||
|
|
@ -1,51 +1,39 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('payproService',
|
||||
function($window, profileService, platformInfo, popupService, gettextCatalog, ongoingProcess, $log) {
|
||||
function(profileService, platformInfo, gettextCatalog, ongoingProcess, $log) {
|
||||
|
||||
var ret = {};
|
||||
var ret = {};
|
||||
|
||||
ret.getPayProDetails = function(uri, cb, disableLoader) {
|
||||
if (!cb) cb = function() {};
|
||||
ret.getPayProDetails = function(uri, cb, disableLoader) {
|
||||
if (!cb) cb = function() {};
|
||||
|
||||
var wallet = profileService.getWallets({
|
||||
onlyComplete: true
|
||||
})[0];
|
||||
var wallet = profileService.getWallets({
|
||||
onlyComplete: true
|
||||
})[0];
|
||||
|
||||
if (!wallet) return cb();
|
||||
if (!wallet) return cb();
|
||||
|
||||
if (platformInfo.isChromeApp) {
|
||||
popupService.showAlert(gettextCatalog.getString('Payment Protocol not supported on Chrome App'));
|
||||
return cb(true);
|
||||
}
|
||||
|
||||
$log.debug('Fetch PayPro Request...', uri);
|
||||
|
||||
if(!disableLoader) {
|
||||
ongoingProcess.set('fetchingPayPro', true);
|
||||
}
|
||||
|
||||
wallet.fetchPayPro({
|
||||
payProUrl: uri,
|
||||
}, function(err, paypro) {
|
||||
|
||||
if(!disableLoader) {
|
||||
ongoingProcess.set('fetchingPayPro', false);
|
||||
if (platformInfo.isChromeApp) {
|
||||
return cb(gettextCatalog.getString('Payment Protocol not supported on Chrome App'));
|
||||
}
|
||||
|
||||
if (err) {
|
||||
return cb(true);
|
||||
}
|
||||
$log.debug('Fetch PayPro Request...', uri);
|
||||
|
||||
if (!paypro.verified) {
|
||||
$log.warn('Failed to verify payment protocol signatures');
|
||||
popupService.showAlert(gettextCatalog.getString('Payment Protocol Invalid'));
|
||||
return cb(true);
|
||||
}
|
||||
cb(null, paypro);
|
||||
if (!disableLoader) ongoingProcess.set('fetchingPayPro', true);
|
||||
|
||||
});
|
||||
};
|
||||
wallet.fetchPayPro({
|
||||
payProUrl: uri,
|
||||
}, function(err, paypro) {
|
||||
if (!disableLoader) ongoingProcess.set('fetchingPayPro', false);
|
||||
if (err) return cb(err);
|
||||
else if (!paypro.verified) {
|
||||
$log.warn('Failed to verify payment protocol signatures');
|
||||
return cb(gettextCatalog.getString('Payment Protocol Invalid'));
|
||||
}
|
||||
return cb(null, paypro);
|
||||
});
|
||||
};
|
||||
|
||||
return ret;
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue