New flow to link the bitpay card

This commit is contained in:
Gustavo Maximiliano Cortez 2016-10-06 19:23:39 -03:00
commit 35cd6ce4cc
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
19 changed files with 385 additions and 384 deletions

View file

@ -1,5 +1,5 @@
'use strict';
angular.module('copayApp.controllers').controller('bitpayCardIntroController', function($scope, $state, $timeout, $ionicHistory, storageService, externalLinkService, bitpayCardService) {
angular.module('copayApp.controllers').controller('bitpayCardIntroController', function($scope, $state, $timeout, $ionicHistory, storageService, externalLinkService, bitpayCardService, gettextCatalog, popupService) {
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.data = {
@ -13,6 +13,39 @@ angular.module('copayApp.controllers').controller('bitpayCardIntroController', f
spaceBetween: 100
};
if (data.stateParams && data.stateParams.secret) {
var obj = {
secret: data.stateParams.secret,
email: data.stateParams.email,
otp: data.stateParams.otp
};
bitpayCardService.bitAuthPair(obj, function(err, data) {
if (err) {
popupService.showAlert(null, err);
return;
}
var title = gettextCatalog.getString('Add BitPay Cards?');
var msg = gettextCatalog.getString('Would you like to add this account to your wallet?');
var ok = gettextCatalog.getString('Add cards');
var cancel = gettextCatalog.getString('Go back');
popupService.showConfirm(title, msg, ok, cancel, function(res) {
if (res) {
// Save data
bitpayCardService.setBitpayDebitCards(data, function(err) {
if (err) return;
$ionicHistory.nextViewOptions({
disableAnimate: true
});
$state.go('tabs.home');
});
}
});
});
} else {
// TODO
}
/*
storageService.getNextStep('BitpayCard', function(err, value) {
if (value) {
$ionicHistory.nextViewOptions({
@ -24,6 +57,7 @@ angular.module('copayApp.controllers').controller('bitpayCardIntroController', f
}, 100);
}
});
*/
});
$scope.orderBitPayCard = function() {
@ -32,7 +66,11 @@ angular.module('copayApp.controllers').controller('bitpayCardIntroController', f
externalLinkService.open(url, target);
};
$scope.connectBitPayCard = function() {};
$scope.connectBitPayCard = function() {
var url = 'https://bitpay.com/visa/login';
var target = '_system';
externalLinkService.open(url, target);
};
$scope.goBack = function() {
if ($scope.data.index != 0) $scope.slider.slidePrev();