Merge pull request #1559 from yemel/fix/android-uri

Fix payment uri handling
This commit is contained in:
Matias Alejo Garcia 2014-10-09 11:06:27 -03:00
commit 71e6fce6e6
3 changed files with 17 additions and 6 deletions

View File

@ -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');

View File

@ -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);

View File

@ -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; }
}
});
}));