diff --git a/js/controllers/uriPayment.js b/js/controllers/uriPayment.js index fe38ed7b6..8058bdbf9 100644 --- a/js/controllers/uriPayment.js +++ b/js/controllers/uriPayment.js @@ -3,8 +3,15 @@ var bitcore = require('bitcore'); angular.module('copayApp.controllers').controller('UriPaymentController', function($rootScope, $scope, $routeParams, $timeout, $location) { - var data = decodeURIComponent($routeParams.data); - $rootScope.pendingPayment = new bitcore.BIP21($routeParams.data); + // Build bitcoinURI with querystring + var query = []; + angular.forEach($location.search(), function(value, key) { + query.push(key + "=" + value); + }); + var queryString = query ? "?" + query.join("&") : ""; + var bitcoinURI = $routeParams.data + queryString; + + $rootScope.pendingPayment = new bitcore.BIP21(bitcoinURI); $timeout(function() { $location.path('/open'); diff --git a/js/mobile.js b/js/mobile.js index 75a5993df..668272b69 100644 --- a/js/mobile.js +++ b/js/mobile.js @@ -17,7 +17,7 @@ function onDeviceReady() { function handleBitcoinURI(url) { if (!url) return; - window.location = '#!/uri-payment/' + encodeURIComponent(url); + window.location = '#!/uri-payment/' + url; } window.plugins.webintent.getUri(handleBitcoinURI); diff --git a/test/unit/controllers/controllersSpec.js b/test/unit/controllers/controllersSpec.js index bb415764c..47e4d7a8f 100644 --- a/test/unit/controllers/controllersSpec.js +++ b/test/unit/controllers/controllersSpec.js @@ -556,14 +556,18 @@ describe("Unit: Controllers", function() { describe('UriPayment Controller', function() { var what; - beforeEach(inject(function($controller, $rootScope) { + beforeEach(inject(function($controller, $rootScope, $location) { scope = $rootScope.$new(); var routeParams = { - data: 'bitcoin:19mP9FKrXqL46Si58pHdhGKow88SUPy1V8?amount=0.1&message=a%20bitcoin%20donation' + data: 'bitcoin:19mP9FKrXqL46Si58pHdhGKow88SUPy1V8' }; + var query = {amount: 0.1, message: "a bitcoin donation"}; what = $controller('UriPaymentController', { $scope: scope, - $routeParams: routeParams + $routeParams: routeParams, + $location: { + search: function() { return query; } + } }); }));