commit
ab1191695b
31 changed files with 575 additions and 165 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService) {
|
||||
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService) {
|
||||
|
||||
var unitToSatoshi;
|
||||
var satToUnit;
|
||||
|
|
@ -210,18 +210,30 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
}
|
||||
|
||||
bitpayCardService.getInvoice(invoiceId, function(err, data) {
|
||||
ongoingProcess.set('Preparing transaction...', false);
|
||||
if (err) {
|
||||
ongoingProcess.set('Preparing transaction...', false);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
var payProUrl = data.paymentUrls.BIP73;
|
||||
|
||||
$state.transitionTo('tabs.bitpayCard.confirm', {
|
||||
cardId: $scope.cardId,
|
||||
toName: $scope.toName,
|
||||
paypro: payProUrl
|
||||
});
|
||||
payproService.getPayProDetails(payProUrl, function(err, payProDetails) {
|
||||
ongoingProcess.set('Preparing transaction...', false);
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
var stateParams = {
|
||||
cardId: $scope.cardId,
|
||||
toName: $scope.toName,
|
||||
toAmount: payProDetails.amount,
|
||||
toAddress: payProDetails.toAddress,
|
||||
description: payProDetails.memo,
|
||||
paypro: payProDetails
|
||||
};
|
||||
|
||||
$state.transitionTo('tabs.bitpayCard.confirm', stateParams);
|
||||
}, true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, gettext, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig) {
|
||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, gettext, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService) {
|
||||
var cachedTxp = {};
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
var countDown = null;
|
||||
|
|
@ -25,13 +25,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
});
|
||||
|
||||
var initConfirm = function() {
|
||||
if ($scope.paypro) {
|
||||
return setFromPayPro($scope.paypro, function(err) {
|
||||
if (err && !isChromeApp) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettext('Could not fetch payment'));
|
||||
}
|
||||
});
|
||||
}
|
||||
// TODO (URL , etc)
|
||||
if (!$scope.toAddress || !$scope.toAmount) {
|
||||
$log.error('Bad params at amount');
|
||||
|
|
@ -103,6 +96,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.alternativeAmountStr = v;
|
||||
});
|
||||
|
||||
if($scope.paypro) {
|
||||
_paymentTimeControl($scope.paypro.expires);
|
||||
}
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
|
|
@ -152,56 +149,6 @@ 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('Error'), gettextCatalog.getString('Payment Protocol not supported on Chrome App'));
|
||||
return cb(true);
|
||||
}
|
||||
|
||||
$log.debug('Fetch PayPro Request...', uri);
|
||||
|
||||
ongoingProcess.set('fetchingPayPro', true);
|
||||
wallet.fetchPayPro({
|
||||
payProUrl: uri,
|
||||
}, function(err, 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(gettextCatalog.getString('Error'), msg);
|
||||
return cb(true);
|
||||
}
|
||||
|
||||
if (!paypro.verified) {
|
||||
$log.warn('Failed to verify payment protocol signatures');
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), 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;
|
||||
_paymentTimeControl(paypro.expires);
|
||||
return initConfirm();
|
||||
});
|
||||
};
|
||||
|
||||
function _paymentTimeControl(expirationTime) {
|
||||
$scope.paymentExpired.value = false;
|
||||
setExpirationTime();
|
||||
|
|
@ -222,7 +169,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
var m = Math.floor(totalSecs / 60);
|
||||
var s = totalSecs % 60;
|
||||
$scope.remainingTimeStr.value = ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2);
|
||||
};
|
||||
}
|
||||
|
||||
function setExpiredValues() {
|
||||
$scope.paymentExpired.value = true;
|
||||
|
|
@ -231,8 +178,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function setWallet(wallet, delayed) {
|
||||
var stop;
|
||||
|
|
@ -260,7 +207,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
});
|
||||
}, delayed ? 2000 : 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var setSendError = function(msg) {
|
||||
$scope.sendStatus = '';
|
||||
|
|
@ -297,7 +244,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
var msg = 'Amount too big';
|
||||
$log.warn(msg);
|
||||
return setSendError(msg);
|
||||
};
|
||||
}
|
||||
|
||||
outputs.push({
|
||||
'toAddress': toAddress,
|
||||
|
|
@ -316,7 +263,9 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
|
||||
txp.outputs = outputs;
|
||||
txp.message = description;
|
||||
txp.payProUrl = paypro;
|
||||
if(paypro) {
|
||||
txp.payProUrl = paypro.url;
|
||||
}
|
||||
txp.excludeUnconfirmedUtxos = config.spendUnconfirmed ? false : true;
|
||||
txp.feeLevel = config.settings && config.settings.feeLevel ? config.settings.feeLevel : 'normal';
|
||||
txp.dryRun = dryRun;
|
||||
|
|
@ -340,8 +289,9 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
};
|
||||
|
||||
$scope.approve = function(onSendStatusChange) {
|
||||
if ($scope._paypro && $scope.paymentExpired.value) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('The payment request has expired'));
|
||||
|
||||
if ($scope.paypro && $scope.paymentExpired.value) {
|
||||
popupService.showAlert(null, gettextCatalog.getString('This bitcoin payment request has expired.'));
|
||||
$scope.sendStatus = '';
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
|
|
@ -352,7 +302,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
var wallet = $scope.wallet;
|
||||
if (!wallet) {
|
||||
return setSendError(gettextCatalog.getString('No wallet selected'));
|
||||
};
|
||||
}
|
||||
|
||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||
$log.info('No signing proposal: No private key');
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
|
|||
$scope.$on("$ionicView.afterEnter", function() {
|
||||
// try initializing and refreshing status any time the view is entered
|
||||
scannerService.gentleInitialize();
|
||||
scannerService.resumePreview();
|
||||
});
|
||||
|
||||
function activate(){
|
||||
|
|
@ -95,9 +96,15 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
|
|||
|
||||
function handleSuccessfulScan(contents){
|
||||
$log.debug('Scan returned: "' + contents + '"');
|
||||
scannerService.pausePreview();
|
||||
incomingData.redir(contents);
|
||||
}
|
||||
|
||||
$rootScope.$on('incomingDataMenu.menuHidden', function() {
|
||||
scannerService.resumePreview();
|
||||
activate();
|
||||
});
|
||||
|
||||
$scope.openSettings = function(){
|
||||
scannerService.openSettings();
|
||||
};
|
||||
|
|
@ -126,7 +133,7 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
|
|||
|
||||
$scope.canGoBack = function(){
|
||||
return $state.params.passthroughMode;
|
||||
}
|
||||
};
|
||||
function goBack(){
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableAnimate: true
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
|||
|
||||
$scope.openScanner = function() {
|
||||
$state.go('tabs.scan');
|
||||
}
|
||||
};
|
||||
|
||||
$scope.showMore = function() {
|
||||
currentContactsPage++;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.directives')
|
||||
.directive('actionSheet', function() {
|
||||
.directive('actionSheet', function($rootScope, $timeout) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'views/includes/actionSheet.html',
|
||||
|
|
@ -10,8 +10,16 @@ angular.module('copayApp.directives')
|
|||
show: '=actionSheetShow',
|
||||
},
|
||||
link: function(scope, element, attrs) {
|
||||
scope.$watch('show', function() {
|
||||
if(scope.show) {
|
||||
$timeout(function() { scope.revealMenu = true; }, 100);
|
||||
} else {
|
||||
scope.revealMenu = false;
|
||||
}
|
||||
});
|
||||
scope.hide = function() {
|
||||
scope.show = false;
|
||||
$rootScope.$broadcast('incomingDataMenu.menuHidden');
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
|||
50
src/js/directives/incomingDataMenu.js
Normal file
50
src/js/directives/incomingDataMenu.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.directives')
|
||||
.directive('incomingDataMenu', function($timeout, $rootScope, $state, externalLinkService) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'views/includes/incomingDataMenu.html',
|
||||
link: function(scope, element, attrs) {
|
||||
$rootScope.$on('incomingDataMenu.showMenu', function(event, data) {
|
||||
$timeout(function() {
|
||||
scope.data = data.data;
|
||||
scope.type = data.type;
|
||||
scope.showMenu = true;
|
||||
scope.https = false;
|
||||
|
||||
if(scope.type === 'url') {
|
||||
if(scope.data.indexOf('https://') === 0) {
|
||||
scope.https = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
scope.hide = function() {
|
||||
scope.showMenu = false;
|
||||
$rootScope.$broadcast('incomingDataMenu.menuHidden');
|
||||
};
|
||||
scope.goToUrl = function(url){
|
||||
externalLinkService.open(url);
|
||||
};
|
||||
scope.sendPaymentToAddress = function(bitcoinAddress) {
|
||||
scope.showMenu = false;
|
||||
$state.go('tabs.send').then(function() {
|
||||
$timeout(function() {
|
||||
$state.transitionTo('tabs.send.amount', {toAddress: bitcoinAddress});
|
||||
}, 50);
|
||||
});
|
||||
};
|
||||
scope.addToAddressBook = function(bitcoinAddress) {
|
||||
scope.showMenu = false;
|
||||
$timeout(function() {
|
||||
$state.go('tabs.send').then(function() {
|
||||
$timeout(function() {
|
||||
$state.transitionTo('tabs.send.addressbook', {addressbookEntry: bitcoinAddress});
|
||||
});
|
||||
});
|
||||
}, 100);
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
@ -269,13 +269,14 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
})
|
||||
.state('tabs.send.confirm', {
|
||||
url: '/confirm/:isWallet/:toAddress/:toName/:toAmount/:toEmail/:description/:paypro',
|
||||
url: '/confirm/:isWallet/:toAddress/:toName/:toAmount/:toEmail/:description',
|
||||
views: {
|
||||
'tab-send@tabs': {
|
||||
controller: 'confirmController',
|
||||
templateUrl: 'views/confirm.html'
|
||||
}
|
||||
}
|
||||
},
|
||||
params: { paypro: null }
|
||||
})
|
||||
.state('tabs.send.addressbook', {
|
||||
url: '/addressbook/add/:fromSendTab/:addressbookEntry',
|
||||
|
|
@ -884,13 +885,14 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
})
|
||||
.state('tabs.bitpayCard.confirm', {
|
||||
url: '/confirm/:cardId/:toAddress/:toName/:toAmount/:toEmail/:description/:paypro',
|
||||
url: '/confirm/:cardId/:toAddress/:toName/:toAmount/:toEmail/:description',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'confirmController',
|
||||
templateUrl: 'views/confirm.html'
|
||||
}
|
||||
}
|
||||
},
|
||||
params: { paypro: null }
|
||||
})
|
||||
.state('tabs.bitpayCard.preferences', {
|
||||
url: '/preferences',
|
||||
|
|
|
|||
|
|
@ -215,7 +215,11 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
if (!card) return cb(_setError('Not card found'));
|
||||
$http(_post('/api/v2/' + card.token, json, credentials)).then(function(data) {
|
||||
$log.info('BitPay TopUp: SUCCESS');
|
||||
return cb(data.data.error, data.data.data.invoice);
|
||||
if(data.data.error) {
|
||||
return cb(data.data.error);
|
||||
} else {
|
||||
return cb(null, data.data.data.invoice);
|
||||
}
|
||||
}, function(data) {
|
||||
return cb(_setError('BitPay Card Error: TopUp', data));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('incomingData', function($log, $state, $window, $timeout, bitcore, lodash) {
|
||||
angular.module('copayApp.services').factory('incomingData', function($log, $state, $window, $timeout, bitcore, $rootScope, payproService, scannerService) {
|
||||
|
||||
var root = {};
|
||||
|
||||
root.showMenu = function(data) {
|
||||
$rootScope.$broadcast('incomingDataMenu.showMenu', data);
|
||||
};
|
||||
|
||||
root.redir = function(data) {
|
||||
$log.debug('Processing incoming data: ' + data);
|
||||
|
||||
|
|
@ -21,7 +25,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
newUri.replace('://', ':');
|
||||
|
||||
return newUri;
|
||||
};
|
||||
}
|
||||
|
||||
function getParameterByName(name, url) {
|
||||
if (!url) return;
|
||||
|
|
@ -53,59 +57,59 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
|
||||
var amount = parsed.amount ? parsed.amount : '';
|
||||
|
||||
$state.go('tabs.send');
|
||||
// Timeout is required to enable the "Back" button
|
||||
$timeout(function() {
|
||||
if (parsed.r) {
|
||||
$state.transitionTo('tabs.send.confirm', {paypro: parsed.r});
|
||||
} else {
|
||||
if (parsed.r) {
|
||||
payproService.getPayProDetails(parsed.r, function(err, details) {
|
||||
handlePayPro(details);
|
||||
});
|
||||
} else {
|
||||
$state.go('tabs.send');
|
||||
// Timeout is required to enable the "Back" button
|
||||
$timeout(function() {
|
||||
if (amount) {
|
||||
$state.transitionTo('tabs.send.confirm', {toAmount: amount, toAddress: addr, description:message});
|
||||
} else {
|
||||
$state.transitionTo('tabs.send.amount', {toAddress: addr});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return true;
|
||||
|
||||
// Plain URL
|
||||
} else if (/^https?:\/\//.test(data)) {
|
||||
$state.go('tabs.send').then(function() {
|
||||
$state.transitionTo('tabs.send.confirm', {paypro: data});
|
||||
});
|
||||
return true;
|
||||
|
||||
// Plain Address
|
||||
} else if (bitcore.Address.isValid(data, 'livenet')) {
|
||||
$state.go('tabs.send').then(function() {
|
||||
$state.transitionTo('tabs.send.amount', {toAddress: data});
|
||||
payproService.getPayProDetails(data, function(err, details) {
|
||||
if(err) {
|
||||
root.showMenu({data: data, type: 'url'});
|
||||
return;
|
||||
}
|
||||
handlePayPro(details);
|
||||
return true;
|
||||
});
|
||||
return true;
|
||||
} else if (bitcore.Address.isValid(data, 'testnet')) {
|
||||
$state.go('tabs.send').then(function() {
|
||||
$state.transitionTo('tabs.send.amount', {toAddress: data});
|
||||
});
|
||||
return true;
|
||||
// Plain Address
|
||||
} else if (bitcore.Address.isValid(data, 'livenet') || bitcore.Address.isValid(data, 'testnet')) {
|
||||
if($state.includes('tabs.scan')) {
|
||||
root.showMenu({data: data, type: 'bitcoinAddress'});
|
||||
} else {
|
||||
goToAmountPage(data);
|
||||
}
|
||||
} else if (data && data.indexOf($window.appConfig.name + '://glidera') === 0) {
|
||||
return $state.go('uriglidera', {url: data});
|
||||
} else if (data && data.indexOf($window.appConfig.name + '://coinbase') === 0) {
|
||||
return $state.go('uricoinbase', {url: data});
|
||||
|
||||
// Protocol
|
||||
} else if (data && data.indexOf($window.appConfig.name + '://glidera')==0) {
|
||||
return $state.go('uriglidera', {url: data});
|
||||
} else if (data && data.indexOf($window.appConfig.name + '://coinbase')==0) {
|
||||
return $state.go('uricoinbase', {url: data});
|
||||
|
||||
// BitPayCard Authentication
|
||||
} else if (data && data.indexOf($window.appConfig.name + '://')==0) {
|
||||
var secret = getParameterByName('secret', data);
|
||||
var email = getParameterByName('email', data);
|
||||
var otp = getParameterByName('otp', data);
|
||||
$state.go('tabs.home').then(function() {
|
||||
$state.transitionTo('tabs.bitpayCardIntro', {
|
||||
secret: secret,
|
||||
email: email,
|
||||
otp: otp
|
||||
// BitPayCard Authentication
|
||||
} else if (data && data.indexOf($window.appConfig.name + '://') === 0) {
|
||||
var secret = getParameterByName('secret', data);
|
||||
var email = getParameterByName('email', data);
|
||||
var otp = getParameterByName('otp', data);
|
||||
$state.go('tabs.home').then(function() {
|
||||
$state.transitionTo('tabs.bitpayCardIntro', {
|
||||
secret: secret,
|
||||
email: email,
|
||||
otp: otp
|
||||
});
|
||||
});
|
||||
});
|
||||
return true;
|
||||
return true;
|
||||
|
||||
// Join
|
||||
} else if (data && data.match(/^copay:[0-9A-HJ-NP-Za-km-z]{70,80}$/)) {
|
||||
|
|
@ -120,11 +124,38 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
$state.transitionTo('tabs.add.join', {url: data});
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
|
||||
if($state.includes('tabs.scan')) {
|
||||
root.showMenu({data: data, type: 'text'});
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
function goToAmountPage(toAddress) {
|
||||
$state.go('tabs.send');
|
||||
$timeout(function() {
|
||||
$state.transitionTo('tabs.send.amount', {toAddress: toAddress});
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function handlePayPro(payProDetails){
|
||||
var stateParams = {
|
||||
toAmount: payProDetails.amount,
|
||||
toAddress: payProDetails.toAddress,
|
||||
description: payProDetails.memo,
|
||||
paypro: payProDetails
|
||||
};
|
||||
scannerService.pausePreview();
|
||||
$state.go('tabs.send').then(function() {
|
||||
$timeout(function() {
|
||||
$state.transitionTo('tabs.send.confirm', stateParams);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
51
src/js/services/payproService.js
Normal file
51
src/js/services/payproService.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('payproService',
|
||||
function($window, profileService, platformInfo, popupService, gettextCatalog, ongoingProcess, $log) {
|
||||
|
||||
var ret = {};
|
||||
|
||||
ret.getPayProDetails = function(uri, cb, disableLoader) {
|
||||
if (!cb) cb = function() {};
|
||||
|
||||
var wallet = profileService.getWallets({
|
||||
onlyComplete: true
|
||||
})[0];
|
||||
|
||||
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 (err) {
|
||||
return cb(true);
|
||||
}
|
||||
|
||||
if (!paypro.verified) {
|
||||
$log.warn('Failed to verify payment protocol signatures');
|
||||
popupService.showAlert(gettextCatalog.getString('Payment Protocol Invalid'));
|
||||
return cb(true);
|
||||
}
|
||||
cb(null, paypro);
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
return ret;
|
||||
});
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').service('scannerService', function($log, $timeout, platformInfo, $rootScope) {
|
||||
angular.module('copayApp.services').service('scannerService', function($log, $timeout, platformInfo, $rootScope, $window) {
|
||||
|
||||
var isDesktop = !platformInfo.isCordova;
|
||||
var QRScanner = window.QRScanner;
|
||||
var QRScanner = $window.QRScanner;
|
||||
var lightEnabled = false;
|
||||
var backCamera = true; // the plugin defaults to the back camera
|
||||
|
||||
|
|
@ -55,8 +55,8 @@ angular.module('copayApp.services').service('scannerService', function($log, $ti
|
|||
canEnableLight: canEnableLight,
|
||||
canChangeCamera: canChangeCamera,
|
||||
canOpenSettings: canOpenSettings
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var initializeStarted = false;
|
||||
/**
|
||||
|
|
@ -123,10 +123,10 @@ angular.module('copayApp.services').service('scannerService', function($log, $ti
|
|||
}
|
||||
this.isInitialized = function(){
|
||||
return initializeCompleted;
|
||||
}
|
||||
};
|
||||
this.initializeStarted = function(){
|
||||
return initializeStarted;
|
||||
}
|
||||
};
|
||||
|
||||
var nextHide = null;
|
||||
var nextDestroy = null;
|
||||
|
|
@ -167,6 +167,14 @@ angular.module('copayApp.services').service('scannerService', function($log, $ti
|
|||
QRScanner.scan(callback);
|
||||
};
|
||||
|
||||
this.pausePreview = function() {
|
||||
QRScanner.pausePreview();
|
||||
};
|
||||
|
||||
this.resumePreview = function() {
|
||||
QRScanner.resumePreview();
|
||||
};
|
||||
|
||||
/**
|
||||
* Deactivate the QRScanner. To balance user-perceived performance and power
|
||||
* consumption, this kicks off a countdown which will "sleep" the scanner
|
||||
|
|
@ -177,7 +185,7 @@ angular.module('copayApp.services').service('scannerService', function($log, $ti
|
|||
*/
|
||||
this.deactivate = function(callback) {
|
||||
$log.debug('Deactivating scanner...');
|
||||
// QRScanner.cancelScan();
|
||||
QRScanner.cancelScan();
|
||||
nextHide = $timeout(_hide, hideAfterSeconds * 1000);
|
||||
nextDestroy = $timeout(_destroy, destroyAfterSeconds * 1000);
|
||||
};
|
||||
|
|
@ -200,7 +208,7 @@ angular.module('copayApp.services').service('scannerService', function($log, $ti
|
|||
initializeCompleted = false;
|
||||
QRScanner.destroy();
|
||||
initialize(callback);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggle the device light (if available).
|
||||
|
|
@ -236,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){
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ action-sheet {
|
|||
transition: transform 250ms cubic-bezier(0.4, 0.0, 0.2, 1);
|
||||
z-index: 100;
|
||||
padding-top: 1.75rem;
|
||||
padding-left: 2rem;
|
||||
padding-right: .75rem;
|
||||
padding-left: 1.25rem;
|
||||
padding-right: 1.25rem;
|
||||
color: #2f2f2f;
|
||||
padding-bottom: 3.5rem;
|
||||
max-width: 550px;
|
||||
|
|
|
|||
81
src/sass/views/includes/incomingDataMenu.scss
Normal file
81
src/sass/views/includes/incomingDataMenu.scss
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
incoming-data-menu {
|
||||
.bp-action-sheet__sheet {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
padding-top: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.incoming-data-menu {
|
||||
&__header {
|
||||
padding-bottom: 1rem;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
&__item {
|
||||
border-top: 1px solid #f7f4f4;
|
||||
font-size: 14px;
|
||||
padding: 1rem 1.25rem;
|
||||
color: #4A4A4A;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
&.head {
|
||||
display: block;
|
||||
padding-top: 1.5rem;
|
||||
}
|
||||
|
||||
&:first-child {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
> img {
|
||||
margin-left: .2rem;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
&__text {
|
||||
padding-left: 2.7rem;
|
||||
}
|
||||
}
|
||||
|
||||
&__cancel {
|
||||
background: #EDEDED;
|
||||
font-size: 18px;
|
||||
height: 66px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #3A3A3A;
|
||||
border-top: 1px solid #e4e4e4;
|
||||
|
||||
&:active {
|
||||
background: #dadada;
|
||||
}
|
||||
}
|
||||
&__url {
|
||||
background: rgba(203, 203, 203, .13);
|
||||
padding: .5rem;
|
||||
padding-left: 0;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: .5rem;
|
||||
|
||||
&__icon {
|
||||
padding: 0 9px 0 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__text {
|
||||
color: #4A4A4A;
|
||||
font-size: 14px;
|
||||
border-left: 1px solid #E4E4E4;
|
||||
padding-left: .7rem;//1rem;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,12 @@
|
|||
wallet-selector {
|
||||
|
||||
|
||||
$border-color: #EFEFEF;
|
||||
|
||||
.bp-action-sheet__sheet {
|
||||
padding-left: 2rem;
|
||||
padding-right: .75rem;
|
||||
}
|
||||
|
||||
.wallet-selector {
|
||||
.wallet {
|
||||
border: 0;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
@import "includes/wallets";
|
||||
@import "includes/modals/modals";
|
||||
@import "includes/clickToAccept";
|
||||
@import "includes/incomingDataMenu";
|
||||
@import "includes/slideToAccept";
|
||||
@import "includes/slideToAcceptSuccess";
|
||||
@import "includes/tx-details";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue