Merge pull request #5853 from JDonadio/fix/parsing-paypro

Use BIP21 params if paypro info is not complete
This commit is contained in:
Matias Alejo Garcia 2017-04-12 16:03:05 +02:00 committed by GitHub
commit 5f197b5f4e
2 changed files with 31 additions and 43 deletions

View File

@ -1,6 +1,6 @@
'use strict'; '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 = {}; var root = {};
@ -93,10 +93,10 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
if (parsed.r) { if (parsed.r) {
payproService.getPayProDetails(parsed.r, function(err, details) { payproService.getPayProDetails(parsed.r, function(err, details) {
if (err && addr && amount) { if (err) {
goSend(addr, amount, message); if (addr && amount) goSend(addr, amount, message);
} else popupService.showAlert(gettextCatalog.getString('Error'), err);
handlePayPro(details); } else handlePayPro(details);
}); });
} else { } else {
goSend(addr, amount, message); goSend(addr, amount, message);

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('payproService', angular.module('copayApp.services').factory('payproService',
function($window, profileService, platformInfo, popupService, gettextCatalog, ongoingProcess, $log) { function(profileService, platformInfo, gettextCatalog, ongoingProcess, $log) {
var ret = {}; var ret = {};
@ -15,35 +15,23 @@ function($window, profileService, platformInfo, popupService, gettextCatalog, on
if (!wallet) return cb(); if (!wallet) return cb();
if (platformInfo.isChromeApp) { if (platformInfo.isChromeApp) {
popupService.showAlert(gettextCatalog.getString('Payment Protocol not supported on Chrome App')); return cb(gettextCatalog.getString('Payment Protocol not supported on Chrome App'));
return cb(true);
} }
$log.debug('Fetch PayPro Request...', uri); $log.debug('Fetch PayPro Request...', uri);
if(!disableLoader) { if (!disableLoader) ongoingProcess.set('fetchingPayPro', true);
ongoingProcess.set('fetchingPayPro', true);
}
wallet.fetchPayPro({ wallet.fetchPayPro({
payProUrl: uri, payProUrl: uri,
}, function(err, paypro) { }, function(err, paypro) {
if (!disableLoader) ongoingProcess.set('fetchingPayPro', false);
if(!disableLoader) { if (err) return cb(err);
ongoingProcess.set('fetchingPayPro', false); else if (!paypro.verified) {
}
if (err) {
return cb(true);
}
if (!paypro.verified) {
$log.warn('Failed to verify payment protocol signatures'); $log.warn('Failed to verify payment protocol signatures');
popupService.showAlert(gettextCatalog.getString('Payment Protocol Invalid')); return cb(gettextCatalog.getString('Payment Protocol Invalid'));
return cb(true);
} }
cb(null, paypro); return cb(null, paypro);
}); });
}; };