diff --git a/public/views/amazon.html b/public/views/amazon.html index 1d43633f0..730035d41 100644 --- a/public/views/amazon.html +++ b/public/views/amazon.html @@ -10,7 +10,7 @@ - + Sandbox version. Only for testing purpose @@ -40,8 +40,10 @@ - Your cards - + + + Your cards + diff --git a/public/views/buyAmazon.html b/public/views/buyAmazon.html index 55e820458..f711b64a7 100644 --- a/public/views/buyAmazon.html +++ b/public/views/buyAmazon.html @@ -12,12 +12,12 @@ - + {{buy.error}} - + There was an error when trying to buy gift card, but the funds were sent to BitPay Invoice. Please, contact BitPay to refund your bitcoin - + Amount: {{buy.errorInfo.amount}} {{buy.errorInfo.currency}} BitPay Invoice ID: {{buy.errorInfo.invoiceId}}. @@ -53,23 +53,11 @@ - - - Pay From Copay Wallet - - - - - + Buy now diff --git a/src/js/controllers/buyAmazon.js b/src/js/controllers/buyAmazon.js index d1f65c01a..afb87955e 100644 --- a/src/js/controllers/buyAmazon.js +++ b/src/js/controllers/buyAmazon.js @@ -6,6 +6,15 @@ angular.module('copayApp.controllers').controller('buyAmazonController', var self = this; var wallet; + $scope.$on('Wallet/Changed', function(event, w) { + if (lodash.isEmpty(w)) { + $log.debug('No wallet provided'); + return; + } + wallet = w; + $log.debug('Wallet changed: ' + w.name); + }); + $scope.openExternalLink = function(url, target) { if (platformInfo.isNW) { nodeWebkit.openExternalLink(url); @@ -17,53 +26,18 @@ angular.module('copayApp.controllers').controller('buyAmazonController', this.init = function() { var network = amazonService.getEnvironment(); - self.allWallets = profileService.getWallets({ + $scope.wallets = profileService.getWallets({ network: network, - n: 1, onlyComplete: true }); - - if (lodash.isEmpty(self.allWallets)) return; - - wallet = self.allWallets[0]; - - $timeout(function() { - self.selectedWalletId = wallet.credentials.walletId; - self.selectedWalletName = wallet.credentials.walletName; - $scope.$apply(); - }, 100); - }; - - $scope.openWalletsModal = function(wallets) { - self.error = null; - - $scope.type = 'SELL'; - $scope.wallets = wallets; - $scope.self = self; - - $ionicModal.fromTemplateUrl('views/modals/wallets.html', { - scope: $scope, - animation: 'slide-in-up' - }).then(function(modal) { - $scope.walletsModal = modal; - $scope.walletsModal.show(); - }); - - $scope.$on('walletSelected', function(ev, walletId) { - $timeout(function() { - wallet = profileService.getClient(walletId); - self.selectedWalletId = walletId; - self.selectedWalletName = wallet.credentials.walletName; - $scope.$apply(); - }, 100); - $scope.walletsModal.hide(); - }); }; this.createTx = function() { self.error = null; self.errorInfo = null; + if (lodash.isEmpty(wallet)) return; + if (!wallet.canSign() && !wallet.isPrivKeyExternal()) { $log.info('No signing proposal: No private key'); self.error = bwcError.msg('MISSING_PRIVATE_KEY'); @@ -73,7 +47,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController', var dataSrc = { currency: 'USD', amount: $scope.fiat, - uuid: self.selectedWalletId + uuid: wallet.id }; var outputs = []; var config = configService.getSync(); @@ -241,7 +215,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController', $log.debug("Saving new gift card with status: " + newData.status); self.giftCard = newData; - if (newData.status == 'PENDING') $state.transitionTo('amazon'); + if (newData.status == 'PENDING') $state.transitionTo('amazon.main'); $timeout(function() { $scope.$digest(); }); @@ -278,18 +252,24 @@ angular.module('copayApp.controllers').controller('buyAmazonController', }); return bwcError.cb(err, null, cb); } - walletService.broadcastTx(wallet, signedTxp, function(err, broadcastedTxp) { - if (err) { - $log.debug(err); - walletService.removeTx(wallet, broadcastedTxp, function(err) { - if (err) $log.debug(err); - }); - return bwcError.cb(err, null, cb); - } + if (signedTxp.status == 'accepted') { + walletService.broadcastTx(wallet, signedTxp, function(err, broadcastedTxp) { + if (err) { + $log.debug(err); + walletService.removeTx(wallet, broadcastedTxp, function(err) { + if (err) $log.debug(err); + }); + return bwcError.cb(err, null, cb); + } + $timeout(function() { + return cb(null, broadcastedTxp); + }, 5000); + }); + } else { $timeout(function() { - return cb(null, broadcastedTxp); + return cb(null, signedTxp); }, 5000); - }); + } }); }); }); diff --git a/src/sass/main.scss b/src/sass/main.scss index 3e1c659cc..4a8d52f4f 100644 --- a/src/sass/main.scss +++ b/src/sass/main.scss @@ -81,32 +81,26 @@ h3.title { } .box-notification { - position: relative; - font-size: 12px; padding: 0.5rem; - border-radius: 2px; - background: #FFFFFF; - .box-icon { - position: absolute; - top: 0; - left: 0; - color: white; - background-color: #1ABC9C; - padding: 0 0.5rem; - border-top-left-radius: 4px; - border-bottom-left-radius: 4px; - height: 100%; - i { - position: relative; - top: 10%; - display: block; - } - &.error { - background-color: #ED4A43; - } - &.secondary { - background-color: #3498DB; - } + border: 1px solid; + margin-bottom: 20px; + a { + color: #fff; + } + &.notice { + border-color: #b2b2b2; + background-color: #f8f8f8; + color: #444; + } + &.warning { + border-color: #e6b500; + background-color: #ffc900; + color: #fff; + } + &.error { + background-color: #ef473a; + border-color: #e42112; + color: #fff; } } @@ -878,7 +872,7 @@ input[type=file] { } .wallets { - height: 105px; + height: 90px; } /* * Calculator