Fix payment uri handling
This commit is contained in:
parent
a3377a5579
commit
d849df98c6
3 changed files with 17 additions and 6 deletions
|
|
@ -3,8 +3,15 @@
|
||||||
var bitcore = require('bitcore');
|
var bitcore = require('bitcore');
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('UriPaymentController', function($rootScope, $scope, $routeParams, $timeout, $location) {
|
angular.module('copayApp.controllers').controller('UriPaymentController', function($rootScope, $scope, $routeParams, $timeout, $location) {
|
||||||
var data = decodeURIComponent($routeParams.data);
|
// Build bitcoinURI with querystring
|
||||||
$rootScope.pendingPayment = new bitcore.BIP21($routeParams.data);
|
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() {
|
$timeout(function() {
|
||||||
$location.path('/open');
|
$location.path('/open');
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ function onDeviceReady() {
|
||||||
|
|
||||||
function handleBitcoinURI(url) {
|
function handleBitcoinURI(url) {
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
window.location = '#!/uri-payment/' + encodeURIComponent(url);
|
window.location = '#!/uri-payment/' + url;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.plugins.webintent.getUri(handleBitcoinURI);
|
window.plugins.webintent.getUri(handleBitcoinURI);
|
||||||
|
|
|
||||||
|
|
@ -556,14 +556,18 @@ describe("Unit: Controllers", function() {
|
||||||
|
|
||||||
describe('UriPayment Controller', function() {
|
describe('UriPayment Controller', function() {
|
||||||
var what;
|
var what;
|
||||||
beforeEach(inject(function($controller, $rootScope) {
|
beforeEach(inject(function($controller, $rootScope, $location) {
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
var routeParams = {
|
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', {
|
what = $controller('UriPaymentController', {
|
||||||
$scope: scope,
|
$scope: scope,
|
||||||
$routeParams: routeParams
|
$routeParams: routeParams,
|
||||||
|
$location: {
|
||||||
|
search: function() { return query; }
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue