diff --git a/js/controllers/header.js b/js/controllers/header.js index a638f7a2c..841e9ac9b 100644 --- a/js/controllers/header.js +++ b/js/controllers/header.js @@ -71,7 +71,9 @@ angular.module('copayApp.controllers').controller('HeaderController', $rootScope.$watch('txAlertCount', function(txAlertCount) { if (txAlertCount && txAlertCount > 0) { - notification.info('New Transaction', ($rootScope.txAlertCount == 1) ? 'You have a pending transaction proposal' : 'You have ' + $rootScope.txAlertCount + ' pending transaction proposals', txAlertCount); + notification.info('New Transaction', ($rootScope.txAlertCount == 1) ? + 'You have a pending transaction proposal' : + 'You have ' + $rootScope.txAlertCount + ' pending transaction proposals', txAlertCount); } }); diff --git a/js/controllers/send.js b/js/controllers/send.js index 5d94e90fd..0ab3d3858 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -23,6 +23,13 @@ angular.module('copayApp.controllers').controller('SendController', return flag; }; + if ($rootScope.pendingPayment) { + var pp = $rootScope.pendingPayment; + $scope.address = pp.address; + var amount = pp.amount / config.unitToSatoshi * 100000000; + $scope.amount = amount; + } + // Detect protocol $scope.isHttp = ($window.location.protocol.indexOf('http') === 0); @@ -61,6 +68,7 @@ angular.module('copayApp.controllers').controller('SendController', $scope.loading = false; }); } + $rootScope.pendingPayment = null; }); // reset fields @@ -265,7 +273,7 @@ angular.module('copayApp.controllers').controller('SendController', }; $scope.topAmount = function(form) { - $scope.amount = $scope.getAvailableAmount(); + $scope.amount = $scope.getAvailableAmount(); form.amount.$pristine = false; }; }); diff --git a/js/controllers/signin.js b/js/controllers/signin.js index b2e6ef0c8..6503d46ab 100644 --- a/js/controllers/signin.js +++ b/js/controllers/signin.js @@ -13,6 +13,10 @@ angular.module('copayApp.controllers').controller('SigninController', $scope.selectedWalletId = $scope.wallets.length ? $scope.wallets[0].id : null; $scope.openPassword = ''; + if ($rootScope.pendingPayment) { + notification.info('Login Required', 'Please open wallet to complete payment'); + } + $scope.open = function(form) { if (form && form.$invalid) { notification.error('Error', 'Please enter the required fields'); diff --git a/js/controllers/uriPayment.js b/js/controllers/uriPayment.js index 458a9e596..ccc701205 100644 --- a/js/controllers/uriPayment.js +++ b/js/controllers/uriPayment.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('UriPaymentController', function($rootScope, $scope, $routeParams) { +angular.module('copayApp.controllers').controller('UriPaymentController', function($rootScope, $scope, $routeParams, $timeout, $location) { var data = decodeURIComponent($routeParams.data); var splitDots = data.split(':'); $scope.protocol = splitDots[0]; @@ -12,7 +12,19 @@ angular.module('copayApp.controllers').controller('UriPaymentController', functi function(key, value) { return key === "" ? value : decodeURIComponent(value); }); - $scope.amount = parseInt(data.amount); + $scope.amount = parseFloat(data.amount); $scope.message = data.message; + $rootScope.pendingPayment = { + protocol: $scope.protocol, + address: $scope.address, + amount: $scope.amount, + message: $scope.message + }; + + $timeout(function() { + $location.path('signin'); + }, 1000); + + }); diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index bf2f387a7..aa386b618 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -103,7 +103,11 @@ angular.module('copayApp.services') }); w.on('ready', function(myPeerID) { $rootScope.wallet = w; - $location.path('addresses'); + if ($rootScope.pendingPayment) { + $location.path('send'); + } else { + $location.path('addresses'); + } if (!config.disableVideo) video.setOwnPeer(myPeerID, w, handlePeerVideo); }); diff --git a/test/unit/controllers/controllersSpec.js b/test/unit/controllers/controllersSpec.js index 96a30f4be..046ea0704 100644 --- a/test/unit/controllers/controllersSpec.js +++ b/test/unit/controllers/controllersSpec.js @@ -373,7 +373,7 @@ describe("Unit: Controllers", function() { beforeEach(inject(function($controller, $rootScope) { scope = $rootScope.$new(); var routeParams = { - data: 'bitcoin:19mP9FKrXqL46Si58pHdhGKow88SUPy1V8%3Famount=1&message=a%20bitcoin%20donation' + data: 'bitcoin:19mP9FKrXqL46Si58pHdhGKow88SUPy1V8%3Famount=0.1&message=a%20bitcoin%20donation' }; what = $controller('UriPaymentController', { $scope: scope, @@ -389,7 +389,7 @@ describe("Unit: Controllers", function() { should.exist(what); scope.protocol.should.equal('bitcoin'); scope.address.should.equal('19mP9FKrXqL46Si58pHdhGKow88SUPy1V8'); - scope.amount.should.equal(1); + scope.amount.should.equal(0.1); scope.message.should.equal('a bitcoin donation'); }); });