diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index e64f31d9c..609b7a6d2 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -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) { var unitToSatoshi; var satToUnit; @@ -203,6 +203,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ $timeout(function() { bitpayCardService.topUp($scope.cardId, dataSrc, function(err, invoiceId) { + console.log('hereerere'); if (err) { ongoingProcess.set('Preparing transaction...', false); popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err)); @@ -220,7 +221,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ $state.transitionTo('tabs.bitpayCard.confirm', { cardId: $scope.cardId, toName: $scope.toName, - paypro: payProUrl + payProUrl: payProUrl }); }); }); diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index 2c0e2b595..276dcf625 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -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; @@ -15,6 +15,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( $scope.toEmail = data.stateParams.toEmail; $scope.description = data.stateParams.description; $scope.paypro = data.stateParams.paypro; + $scope.payProUrl = data.stateParams.payProUrl; $scope._paypro = $scope.paypro; $scope.paymentExpired = { value: false @@ -26,6 +27,19 @@ angular.module('copayApp.controllers').controller('confirmController', function( }); var initConfirm = function() { + console.log('in init confirm'); + console.log('$scope.paypro', $scope.paypro); + if($scope.payProUrl && !$scope.paypro) { + console.log('getting paypro details', $scope.payProUrl); + payproService.getPayProDetails($scope.payProUrl, function(err, details) { + console.log('paypro details', details); + $scope.toAmount = details.amount; + $scope.toAddress = details.toAddress; + $scope.description = details.memo; + $scope.paypro = details; + return initConfirm(); + }); + } // TODO (URL , etc) if (!$scope.toAddress || !$scope.toAmount) { $log.error('Bad params at amount'); diff --git a/src/js/routes.js b/src/js/routes.js index e7017cc41..a3352836d 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -885,7 +885,7 @@ 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/:payProUrl', views: { 'tab-home@tabs': { controller: 'confirmController', diff --git a/src/js/services/bitpayCardService.js b/src/js/services/bitpayCardService.js index 1d83d9ffb..84bf93a47 100644 --- a/src/js/services/bitpayCardService.js +++ b/src/js/services/bitpayCardService.js @@ -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)); }); diff --git a/src/js/services/incomingData.js b/src/js/services/incomingData.js index 2075fc4bc..4b54adcad 100644 --- a/src/js/services/incomingData.js +++ b/src/js/services/incomingData.js @@ -8,9 +8,9 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat $rootScope.$broadcast('incomingDataMenu.showMenu', data); }; - $timeout(function() { - root.redir(); - }, 2000);; + // $timeout(function() { + // root.redir(); + // }, 2000); root.redir = function(data) { $log.debug('Processing incoming data: ' + data);