remove fetch pay pro logic from send confirm screen

This commit is contained in:
Marty Alcala 2016-10-14 13:42:56 -04:00
commit 2a7ed47548
4 changed files with 75 additions and 79 deletions

View file

@ -19,13 +19,13 @@ angular.module('copayApp.controllers').controller('confirmController', function(
});
var initConfirm = function() {
if ($scope.paypro) {
return setFromPayPro($scope.paypro, function(err) {
if (err && !isChromeApp) {
popupService.showAlert(gettext('Could not fetch payment'));
}
});
}
// if ($scope.paypro) {
// return setFromPayPro($scope.paypro, function(err) {
// if (err && !isChromeApp) {
// popupService.showAlert(gettext('Could not fetch payment'));
// }
// });
// }
// TODO (URL , etc)
if (!$scope.toAddress || !$scope.toAmount) {
$log.error('Bad params at amount')
@ -143,58 +143,58 @@ angular.module('copayApp.controllers').controller('confirmController', function(
return amountStr.split(' ')[1];
}
var setFromPayPro = function(uri, cb) {
if (!cb) cb = function() {};
var wallet = profileService.getWallets({
onlyComplete: true
})[0];
if (!wallet) return cb();
if (isChromeApp) {
popupService.showAlert(gettextCatalog.getString('Payment Protocol not supported on Chrome App'));
return cb(true);
}
$log.debug('Fetch PayPro Request...', uri);
ongoingProcess.set('fetchingPayPro', true);
//debugger;
var uri = 'https://bitpay.com/i/NhjqGZo1RNoHxiHxK7VBuM';
uri = 'https://test.bitpay.com:443/i/LCy5Y7hxmEbkprAK27odAU';
wallet.fetchPayPro({
payProUrl: uri,
}, function(err, paypro) {
console.log('paypro', paypro);
ongoingProcess.set('fetchingPayPro', false);
if (err) {
$log.warn('Could not fetch payment request:', err);
var msg = err.toString();
if (msg.match('HTTP')) {
msg = gettextCatalog.getString('Could not fetch payment information');
}
popupService.showAlert(msg);
return cb(true);
}
if (!paypro.verified) {
$log.warn('Failed to verify payment protocol signatures');
popupService.showAlert(gettextCatalog.getString('Payment Protocol Invalid'));
return cb(true);
}
$scope.toAmount = paypro.amount;
$scope.toAddress = paypro.toAddress;
$scope.description = paypro.memo;
$scope.paypro = null;
$scope._paypro = paypro;
return initConfirm();
});
};
// var setFromPayPro = function(uri, cb) {
// if (!cb) cb = function() {};
//
// var wallet = profileService.getWallets({
// onlyComplete: true
// })[0];
//
// if (!wallet) return cb();
//
// if (isChromeApp) {
// popupService.showAlert(gettextCatalog.getString('Payment Protocol not supported on Chrome App'));
// return cb(true);
// }
//
// $log.debug('Fetch PayPro Request...', uri);
//
// ongoingProcess.set('fetchingPayPro', true);
// //debugger;
// var uri = 'https://bitpay.com/i/NhjqGZo1RNoHxiHxK7VBuM';
// uri = 'https://test.bitpay.com:443/i/LCy5Y7hxmEbkprAK27odAU';
// wallet.fetchPayPro({
// payProUrl: uri,
// }, function(err, paypro) {
// console.log('paypro', paypro);
// ongoingProcess.set('fetchingPayPro', false);
//
// if (err) {
// $log.warn('Could not fetch payment request:', err);
// var msg = err.toString();
// if (msg.match('HTTP')) {
// msg = gettextCatalog.getString('Could not fetch payment information');
// }
// popupService.showAlert(msg);
// return cb(true);
// }
//
// if (!paypro.verified) {
// $log.warn('Failed to verify payment protocol signatures');
// popupService.showAlert(gettextCatalog.getString('Payment Protocol Invalid'));
// return cb(true);
// }
//
// $scope.toAmount = paypro.amount;
// $scope.toAddress = paypro.toAddress;
// $scope.description = paypro.memo;
// $scope.paypro = null;
//
// $scope._paypro = paypro;
//
// return initConfirm();
// });
// };
function setWallet(wallet, delayed) {
var stop;

View file

@ -136,7 +136,7 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
$scope.canGoBack = function(){
return $state.params.passthroughMode;
}
};
function goBack(){
$ionicHistory.nextViewOptions({
disableAnimate: true

View file

@ -25,7 +25,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
newUri.replace('://', ':');
return newUri;
};
}
// data extensions for Payment Protocol with non-backwards-compatible request
if ((/^bitcoin:\?r=[\w+]/).exec(data)) {
@ -65,7 +65,6 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
// Plain URL
} else if (/^https?:\/\//.test(data)) {
console.log('in here brah');
getPayProDetails(data, function(err, details) {
if(err) {
@ -75,9 +74,13 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
}
console.log('paypro details', details);
$state.go('tabs.send');
$timeout(function() {
$state.transitionTo('tabs.send.confirm', {paypro: data});
}, 100);
var stateParams = {
toAmount: details.amount,
toAddress: details.toAddress,
description: details.memo,
paypro: details
};
$state.transitionTo('tabs.send.confirm', stateParams);
return true;
});
// Plain Address
@ -137,16 +140,17 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
$log.debug('Fetch PayPro Request...', uri);
console.log('show fetchingPayPro loader');
ongoingProcess.set('fetchingPayPro', true);
//debugger;
// uri = 'https://bitpay.com/i/NhjqGZo1RNoHxiHxK7VBuM';
// uri = 'https://test.bitpay.com:443/i/LCy5Y7hxmEbkprAK27odAU';
//uri = 'https://test.bitpay.com:443/i/LCy5Y7hxmEbkprAK27odAU';
wallet.fetchPayPro({
payProUrl: uri,
}, function(err, paypro) {
console.log('paypro', paypro);
ongoingProcess.set('fetchingPayPro', false);
ongoingProcess.set('fetchingPayPro', false);
if (err) {
// $log.warn('Could not fetch payment request:', err);
// var msg = err.toString();
@ -162,18 +166,10 @@ angular.module('copayApp.services').factory('incomingData', function($log, $ioni
popupService.showAlert(gettextCatalog.getString('Payment Protocol Invalid'));
return cb(true);
}
// $scope.toAmount = paypro.amount;
// $scope.toAddress = paypro.toAddress;
// $scope.description = paypro.memo;
// $scope.paypro = null;
//
// $scope._paypro = paypro;
//return initConfirm();
cb(null, paypro);
});
};
}
return root;
});

View file

@ -208,7 +208,7 @@ angular.module('copayApp.services').service('scannerService', function($log, $ti
initializeCompleted = false;
QRScanner.destroy();
initialize(callback);
}
};
/**
* Toggle the device light (if available).
@ -244,7 +244,7 @@ angular.module('copayApp.services').service('scannerService', function($log, $ti
var nextCamera = backCamera? 1 : 0;
function cameraToString(index){
return index === 1? 'front' : 'back'; // front = 1, back = 0
};
}
$log.debug('Toggling to the ' + cameraToString(nextCamera) + ' camera...');
QRScanner.useCamera(nextCamera, function(err, status){
if(err){