mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #15 from cmgustavo/ref/design-07
Amazon uses new popupService
This commit is contained in:
commit
9be82d3bf9
|
@ -12,18 +12,15 @@
|
||||||
|
|
||||||
<div ng-show="!buy.giftCard">
|
<div ng-show="!buy.giftCard">
|
||||||
|
|
||||||
<div class="box-notification error" ng-show="buy.error" ng-click="buy.error = null">
|
<div class="box-notification error" ng-show="buy.errorInfo" ng-click="buy.errorInfo = null">
|
||||||
{{buy.error}}
|
There was an error when trying to buy gift card, but the funds were sent to BitPay Invoice. Please, contact
|
||||||
<div ng-show="buy.errorInfo">
|
BitPay to refund your bitcoin
|
||||||
There was an error when trying to buy gift card, but the funds were sent to BitPay Invoice. Please, contact
|
<div>
|
||||||
BitPay to refund your bitcoin
|
Amount: {{buy.errorInfo.amount}} {{buy.errorInfo.currency}}<br>
|
||||||
<div>
|
BitPay Invoice ID: {{buy.errorInfo.invoiceId}}.
|
||||||
Amount: {{buy.errorInfo.amount}} {{buy.errorInfo.currency}}<br>
|
</div>
|
||||||
BitPay Invoice ID: {{buy.errorInfo.invoiceId}}.
|
<div class="text-center">
|
||||||
</div>
|
<a ng-click="openExternalLink(buy.errorInfo.invoiceUrl)">Open invoice</a>
|
||||||
<div class="text-center">
|
|
||||||
<a ng-click="openExternalLink(buy.errorInfo.invoiceUrl)">Open invoice</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('amazonController',
|
angular.module('copayApp.controllers').controller('amazonController',
|
||||||
function($scope, $timeout, $ionicModal, $log, lodash, bwcError, amazonService, platformInfo, nodeWebkit) {
|
function($scope, $timeout, $ionicModal, $log, lodash, bwcError, amazonService, platformInfo, nodeWebkit, popupService) {
|
||||||
|
|
||||||
if (platformInfo.isCordova && StatusBar.isVisible) {
|
|
||||||
StatusBar.backgroundColorByHexString("#4B6178");
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.openExternalLink = function(url, target) {
|
$scope.openExternalLink = function(url, target) {
|
||||||
if (platformInfo.isNW) {
|
if (platformInfo.isNW) {
|
||||||
|
@ -21,7 +17,7 @@ angular.module('copayApp.controllers').controller('amazonController',
|
||||||
$scope.network = amazonService.getEnvironment();
|
$scope.network = amazonService.getEnvironment();
|
||||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = err;
|
popupService.showAlert(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$scope.giftCards = lodash.isEmpty(gcds) ? null : gcds;
|
$scope.giftCards = lodash.isEmpty(gcds) ? null : gcds;
|
||||||
|
@ -41,7 +37,7 @@ angular.module('copayApp.controllers').controller('amazonController',
|
||||||
$log.debug("creating gift card");
|
$log.debug("creating gift card");
|
||||||
amazonService.createGiftCard(dataFromStorage, function(err, giftCard) {
|
amazonService.createGiftCard(dataFromStorage, function(err, giftCard) {
|
||||||
if (err) {
|
if (err) {
|
||||||
$log.debug(bwcError.msg(err));
|
popupService.showAlert(bwcError.msg(err));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (giftCard.status != 'PENDING') {
|
if (giftCard.status != 'PENDING') {
|
||||||
|
@ -61,7 +57,7 @@ angular.module('copayApp.controllers').controller('amazonController',
|
||||||
$log.debug("Saving new gift card");
|
$log.debug("Saving new gift card");
|
||||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = err;
|
popupService.showAlert(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$scope.giftCards = gcds;
|
$scope.giftCards = gcds;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('buyAmazonController',
|
angular.module('copayApp.controllers').controller('buyAmazonController',
|
||||||
function($rootScope, $scope, $ionicModal, $log, $timeout, $state, $ionicPopup, lodash, profileService, bwcError, gettext, configService, walletService, fingerprintService, amazonService, ongoingProcess, platformInfo, nodeWebkit) {
|
function($scope, $log, $timeout, $state, lodash, profileService, bwcError, gettextCatalog, configService, walletService, amazonService, ongoingProcess, platformInfo, nodeWebkit, popupService) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var wallet;
|
var wallet;
|
||||||
|
@ -33,14 +33,13 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
||||||
};
|
};
|
||||||
|
|
||||||
this.createTx = function() {
|
this.createTx = function() {
|
||||||
self.error = null;
|
|
||||||
self.errorInfo = null;
|
self.errorInfo = null;
|
||||||
|
|
||||||
if (lodash.isEmpty(wallet)) return;
|
if (lodash.isEmpty(wallet)) return;
|
||||||
|
|
||||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||||
$log.info('No signing proposal: No private key');
|
$log.info('No signing proposal: No private key');
|
||||||
self.error = bwcError.msg('MISSING_PRIVATE_KEY');
|
popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,20 +59,14 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
||||||
amazonService.createBitPayInvoice(dataSrc, function(err, dataInvoice) {
|
amazonService.createBitPayInvoice(dataSrc, function(err, dataInvoice) {
|
||||||
if (err) {
|
if (err) {
|
||||||
ongoingProcess.set('Processing Transaction...', false);
|
ongoingProcess.set('Processing Transaction...', false);
|
||||||
self.error = bwcError.msg(err);
|
popupService.showAler(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||||
$timeout(function() {
|
|
||||||
$scope.$digest();
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
amazonService.getBitPayInvoice(dataInvoice.invoiceId, function(err, invoice) {
|
amazonService.getBitPayInvoice(dataInvoice.invoiceId, function(err, invoice) {
|
||||||
if (err) {
|
if (err) {
|
||||||
ongoingProcess.set('Processing Transaction...', false);
|
ongoingProcess.set('Processing Transaction...', false);
|
||||||
self.error = bwcError.msg(err);
|
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||||
$timeout(function() {
|
|
||||||
$scope.$digest();
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,19 +81,16 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
||||||
$log.warn('Could not fetch payment request:', err);
|
$log.warn('Could not fetch payment request:', err);
|
||||||
var msg = err.toString();
|
var msg = err.toString();
|
||||||
if (msg.match('HTTP')) {
|
if (msg.match('HTTP')) {
|
||||||
msg = gettext('Could not fetch payment information');
|
msg = gettextCatalog.getString('Could not fetch payment information');
|
||||||
}
|
}
|
||||||
self.error = msg;
|
popupService.showAlert(gettextCatalog.getString('Error'), msg);
|
||||||
$timeout(function() {
|
|
||||||
$scope.$digest();
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!paypro.verified) {
|
if (!paypro.verified) {
|
||||||
ongoingProcess.set('Processing Transaction...', false);
|
ongoingProcess.set('Processing Transaction...', false);
|
||||||
$log.warn('Failed to verify payment protocol signatures');
|
$log.warn('Failed to verify payment protocol signatures');
|
||||||
self.error = gettext('Payment Protocol Invalid');
|
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Payment Protocol Invalid'));
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$digest();
|
$scope.$digest();
|
||||||
});
|
});
|
||||||
|
@ -133,16 +123,13 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
||||||
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
||||||
ongoingProcess.set('Processing Transaction...', false);
|
ongoingProcess.set('Processing Transaction...', false);
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = bwcError.msg(err);
|
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||||
$timeout(function() {
|
|
||||||
$scope.$digest();
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
walletService.publishAndSign(wallet, createdTxp, function(err, tx) {
|
walletService.publishAndSign(wallet, createdTxp, function(err, tx) {
|
||||||
if (err) {
|
if (err) {
|
||||||
ongoingProcess.set('Processing Transaction...', false);
|
ongoingProcess.set('Processing Transaction...', false);
|
||||||
self.error = bwcError.msg(err);
|
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||||
walletService.removeTx(wallet, tx, function(err) {
|
walletService.removeTx(wallet, tx, function(err) {
|
||||||
if (err) $log.debug(err);
|
if (err) $log.debug(err);
|
||||||
});
|
});
|
||||||
|
@ -182,7 +169,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
||||||
giftCard = {};
|
giftCard = {};
|
||||||
giftCard.status = 'FAILURE';
|
giftCard.status = 'FAILURE';
|
||||||
ongoingProcess.set('Processing Transaction...', false);
|
ongoingProcess.set('Processing Transaction...', false);
|
||||||
self.error = bwcError.msg(err);
|
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||||
self.errorInfo = dataSrc;
|
self.errorInfo = dataSrc;
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$digest();
|
$scope.$digest();
|
||||||
|
|
|
@ -62,12 +62,12 @@ angular.module('copayApp.services').service('popupService', function($log, $ioni
|
||||||
* Show a simple alert popup
|
* Show a simple alert popup
|
||||||
*
|
*
|
||||||
* @param {String} Title
|
* @param {String} Title
|
||||||
* @param {String} Message
|
* @param {String} Message (optional)
|
||||||
* @param {Callback} Function (optional)
|
* @param {Callback} Function (optional)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
this.showAlert = function(title, msg, cb) {
|
this.showAlert = function(title, msg, cb) {
|
||||||
var message = msg.message ? msg.message : msg;
|
var message = (msg && msg.message) ? msg.message : msg;
|
||||||
$log.warn(title + ": " + message);
|
$log.warn(title + ": " + message);
|
||||||
|
|
||||||
if (isCordova)
|
if (isCordova)
|
||||||
|
|
Loading…
Reference in New Issue