mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #5514 from cmgustavo/ref/amazon-gift-cards-01
Refactor Amazon integration. Clear amount/confirm views
This commit is contained in:
commit
54ef068968
|
@ -1,9 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amazonController',
|
||||
function($scope, $timeout, $ionicModal, $log, $ionicScrollDelegate, lodash, amazonService, platformInfo, externalLinkService, popupService, ongoingProcess) {
|
||||
|
||||
$scope.network = amazonService.getEnvironment();
|
||||
function($scope, $timeout, $ionicModal, $log, $state, $ionicHistory, lodash, amazonService, externalLinkService, popupService) {
|
||||
|
||||
$scope.openExternalLink = function(url) {
|
||||
externalLinkService.open(url);
|
||||
|
@ -11,108 +9,16 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
|
||||
var initAmazon = function() {
|
||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||
if (err) {
|
||||
popupService.showAlert('Error', err);
|
||||
return;
|
||||
}
|
||||
$scope.giftCards = lodash.isEmpty(gcds) ? null : gcds;
|
||||
if (err) $log.error(err);
|
||||
$scope.giftCards = gcds;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
if ($scope.cardClaimCode) {
|
||||
var card = lodash.find($scope.giftCards, {
|
||||
claimCode: $scope.cardClaimCode
|
||||
});
|
||||
if (lodash.isEmpty(card)) {
|
||||
popupService.showAlert('Error', 'Card not found');
|
||||
return;
|
||||
}
|
||||
$scope.openCardModal(card);
|
||||
}
|
||||
});
|
||||
$scope.updatePendingGiftCards();
|
||||
};
|
||||
|
||||
$scope.updatePendingGiftCards = lodash.debounce(function() {
|
||||
ongoingProcess.set('updatingGiftCards', true);
|
||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||
if (lodash.isEmpty(gcds)) {
|
||||
$timeout(function() {
|
||||
ongoingProcess.set('updatingGiftCards', false);
|
||||
}, 1000);
|
||||
}
|
||||
$timeout(function() {
|
||||
$scope.giftCards = lodash.isEmpty(gcds) ? null : gcds;
|
||||
$scope.$digest();
|
||||
});
|
||||
var index = 0;
|
||||
lodash.forEach(gcds, function(dataFromStorage) {
|
||||
if (++index == Object.keys(gcds).length) {
|
||||
$timeout(function() {
|
||||
ongoingProcess.set('updatingGiftCards', false);
|
||||
}, 1000);
|
||||
}
|
||||
if (dataFromStorage.status == 'PENDING') {
|
||||
$log.debug("creating gift card");
|
||||
amazonService.createGiftCard(dataFromStorage, function(err, giftCard) {
|
||||
if (err) {
|
||||
popupService.showAlert('Error', err);
|
||||
return;
|
||||
}
|
||||
if (giftCard.status != 'PENDING') {
|
||||
var newData = {};
|
||||
|
||||
lodash.merge(newData, dataFromStorage, giftCard);
|
||||
|
||||
if (newData.status == 'expired') {
|
||||
amazonService.savePendingGiftCard(newData, {
|
||||
remove: true
|
||||
}, function(err) {
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
amazonService.savePendingGiftCard(newData, null, function(err) {
|
||||
$log.debug("Saving new gift card");
|
||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||
if (err) {
|
||||
popupService.showAlert('Error', err);
|
||||
return;
|
||||
}
|
||||
$scope.giftCards = lodash.isEmpty(gcds) ? null : gcds;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
$ionicScrollDelegate.resize();
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
} else $log.debug("pending gift card not available yet");
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}, 1000, {
|
||||
'leading': true
|
||||
});
|
||||
|
||||
$scope.openCardModal = function(card) {
|
||||
$scope.card = card;
|
||||
|
||||
$ionicModal.fromTemplateUrl('views/modals/amazon-card-details.html', {
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
$scope.amazonCardDetailsModal = modal;
|
||||
$scope.amazonCardDetailsModal.show();
|
||||
});
|
||||
|
||||
$scope.$on('modal.hidden', function() {
|
||||
$scope.updatePendingGiftCards();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.cardClaimCode = data.stateParams.cardClaimCode;
|
||||
$scope.network = amazonService.getNetwork();
|
||||
initAmazon();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amazonCardsController',
|
||||
function($scope, $timeout, $ionicModal, $log, $ionicScrollDelegate, lodash, amazonService, platformInfo, externalLinkService, popupService, ongoingProcess) {
|
||||
|
||||
$scope.openExternalLink = function(url) {
|
||||
externalLinkService.open(url);
|
||||
};
|
||||
|
||||
var updateGiftCards = function(cb) {
|
||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||
if (err) {
|
||||
popupService.showAlert('Could not get gift cards', err);
|
||||
if (cb) return cb();
|
||||
else return;
|
||||
}
|
||||
$scope.giftCards = gcds;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
$ionicScrollDelegate.resize();
|
||||
if (cb) return cb();
|
||||
}, 100);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.updatePendingGiftCards = lodash.debounce(function() {
|
||||
$scope.updatingPending = {};
|
||||
updateGiftCards(function() {
|
||||
var index = 0;
|
||||
var gcds = $scope.giftCards;
|
||||
lodash.forEach(gcds, function(dataFromStorage) {
|
||||
if (dataFromStorage.status == 'PENDING') {
|
||||
$log.debug("creating gift card");
|
||||
$scope.updatingPending[dataFromStorage.invoiceId] = true;
|
||||
amazonService.createGiftCard(dataFromStorage, function(err, giftCard) {
|
||||
$scope.updatingPending[dataFromStorage.invoiceId] = false;
|
||||
if (err) {
|
||||
popupService.showAlert('Error creating gift card', err);
|
||||
return;
|
||||
}
|
||||
if (giftCard.status != 'PENDING') {
|
||||
var newData = {};
|
||||
|
||||
lodash.merge(newData, dataFromStorage, giftCard);
|
||||
|
||||
if (newData.status == 'expired') {
|
||||
amazonService.savePendingGiftCard(newData, {
|
||||
remove: true
|
||||
}, function(err) {
|
||||
updateGiftCards();
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
amazonService.savePendingGiftCard(newData, null, function(err) {
|
||||
$log.debug("Saving new gift card");
|
||||
updateGiftCards();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}, 1000, {
|
||||
'leading': true
|
||||
});
|
||||
|
||||
$scope.openCardModal = function(card) {
|
||||
$scope.card = card;
|
||||
|
||||
$ionicModal.fromTemplateUrl('views/modals/amazon-card-details.html', {
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
$scope.amazonCardDetailsModal = modal;
|
||||
$scope.amazonCardDetailsModal.show();
|
||||
});
|
||||
|
||||
$scope.$on('modal.hidden', function() {
|
||||
$scope.updatePendingGiftCards();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.cardClaimCode = data.stateParams.cardClaimCode;
|
||||
updateGiftCards(function() {
|
||||
if ($scope.cardClaimCode) {
|
||||
var card = lodash.find($scope.giftCards, {
|
||||
claimCode: $scope.cardClaimCode
|
||||
});
|
||||
if (lodash.isEmpty(card)) {
|
||||
popupService.showAlert(null, 'Card not found');
|
||||
return;
|
||||
}
|
||||
$scope.openCardModal(card);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$scope.$on("$ionicView.afterEnter", function(event, data) {
|
||||
$scope.updatePendingGiftCards();
|
||||
});
|
||||
});
|
|
@ -14,14 +14,14 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
});
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.isGiftCard = data.stateParams.isGiftCard;
|
||||
|
||||
// Glidera parameters
|
||||
$scope.isGlidera = data.stateParams.isGlidera;
|
||||
$scope.glideraAccessToken = data.stateParams.glideraAccessToken;
|
||||
|
||||
// Go to...
|
||||
$scope.nextStep = data.stateParams.nextStep;
|
||||
$scope.currency = data.stateParams.currency;
|
||||
$scope.forceCurrency = data.stateParams.forceCurrency;
|
||||
|
||||
$scope.cardId = data.stateParams.cardId;
|
||||
$scope.showMenu = $ionicHistory.backView() && $ionicHistory.backView().stateName == 'tabs.send';
|
||||
|
@ -30,13 +30,13 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
$scope.toAddress = data.stateParams.toAddress;
|
||||
$scope.toName = data.stateParams.toName;
|
||||
$scope.toEmail = data.stateParams.toEmail;
|
||||
$scope.showAlternativeAmount = !!$scope.cardId || !!$scope.isGiftCard || !!$scope.isGlidera || !!$scope.nextStep;
|
||||
$scope.showAlternativeAmount = !!$scope.cardId || !!$scope.isGlidera || !!$scope.nextStep;
|
||||
$scope.toColor = data.stateParams.toColor;
|
||||
$scope.showSendMax = false;
|
||||
|
||||
$scope.customAmount = data.stateParams.customAmount;
|
||||
|
||||
if (!$scope.cardId && !$scope.isGiftCard && !$scope.isGlidera && !$scope.nextStep && !data.stateParams.toAddress) {
|
||||
if (!$scope.cardId && !$scope.isGlidera && !$scope.nextStep && !data.stateParams.toAddress) {
|
||||
$log.error('Bad params at amount')
|
||||
throw ('bad params');
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
if (data.stateParams.currency) {
|
||||
$scope.alternativeIsoCode = data.stateParams.currency;
|
||||
} else {
|
||||
$scope.alternativeIsoCode = !!$scope.cardId || !!$scope.isGiftCard ? 'USD' : config.alternativeIsoCode;
|
||||
$scope.alternativeIsoCode = !!$scope.cardId ? 'USD' : config.alternativeIsoCode;
|
||||
}
|
||||
$scope.specificAmount = $scope.specificAlternativeAmount = '';
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
|
@ -118,6 +118,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
};
|
||||
|
||||
$scope.toggleAlternative = function() {
|
||||
if ($scope.forceCurrency) return;
|
||||
$scope.showAlternativeAmount = !$scope.showAlternativeAmount;
|
||||
|
||||
if ($scope.amount && isExpression($scope.amount)) {
|
||||
|
@ -292,64 +293,6 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
});
|
||||
});
|
||||
|
||||
} else if ($scope.isGiftCard) {
|
||||
ongoingProcess.set('Preparing transaction...', true);
|
||||
// Get first wallet as UUID
|
||||
var uuid;
|
||||
try {
|
||||
uuid = profileService.getWallets({
|
||||
onlyComplete: true,
|
||||
network: amazonService.getEnvironment(),
|
||||
})[0].id;
|
||||
} catch (err) {
|
||||
ongoingProcess.set('Preparing transaction...', false);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('No wallet found!'));
|
||||
return;
|
||||
};
|
||||
var amountUSD = $scope.showAlternativeAmount ? _amount : $filter('formatFiatAmount')(toFiat(_amount));
|
||||
var dataSrc = {
|
||||
currency: 'USD',
|
||||
amount: amountUSD,
|
||||
uuid: uuid
|
||||
};
|
||||
|
||||
amazonService.createBitPayInvoice(dataSrc, function(err, dataInvoice) {
|
||||
if (err) {
|
||||
ongoingProcess.set('Preparing transaction...', false);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
amazonService.getBitPayInvoice(dataInvoice.invoiceId, function(err, invoice) {
|
||||
if (err) {
|
||||
ongoingProcess.set('Preparing transaction...', false);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
var payProUrl = invoice.paymentUrls.BIP73;
|
||||
|
||||
payproService.getPayProDetails(payProUrl, function(err, payProDetails) {
|
||||
ongoingProcess.set('Preparing transaction...', false);
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
var stateParams = {
|
||||
giftCardAmountUSD: amountUSD,
|
||||
giftCardAccessKey: dataInvoice.accessKey,
|
||||
giftCardInvoiceTime: invoice.invoiceTime,
|
||||
giftCardUUID: dataSrc.uuid,
|
||||
toAmount: payProDetails.amount,
|
||||
toAddress: payProDetails.toAddress,
|
||||
description: payProDetails.memo,
|
||||
paypro: payProDetails
|
||||
};
|
||||
|
||||
$state.transitionTo('tabs.giftcards.amazon.confirm', stateParams);
|
||||
}, true);
|
||||
});
|
||||
});
|
||||
} else if ($scope.isGlidera) {
|
||||
var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount;
|
||||
$state.transitionTo('tabs.buyandsell.glidera.confirm', {
|
||||
|
|
|
@ -0,0 +1,257 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyAmazonController', function($scope, $log, $state, $timeout, $filter, $ionicHistory, lodash, amazonService, popupService, profileService, ongoingProcess, configService, walletService, payproService, bwcError, externalLinkService, platformInfo) {
|
||||
|
||||
var amount;
|
||||
var currency;
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
|
||||
$scope.openExternalLink = function(url) {
|
||||
externalLinkService.open(url);
|
||||
};
|
||||
|
||||
var showErrorAndBack = function(msg, err) {
|
||||
$scope.sendStatus = '';
|
||||
$log.error(err);
|
||||
err = err && err.errors ? err.errors[0].message : err;
|
||||
popupService.showAlert(msg, err, function() {
|
||||
$ionicHistory.goBack();
|
||||
});
|
||||
};
|
||||
|
||||
var showError = function(msg, err) {
|
||||
$scope.sendStatus = '';
|
||||
$log.error(err);
|
||||
err = err && err.errors ? err.errors[0].message : err;
|
||||
popupService.showAlert(msg, err);
|
||||
};
|
||||
|
||||
var publishAndSign = function (wallet, txp, onSendStatusChange, cb) {
|
||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||
var err = 'No signing proposal: No private key';
|
||||
$log.info(err);
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
walletService.publishAndSign(wallet, txp, function(err, txp) {
|
||||
if (err) return cb(err);
|
||||
return cb(null, txp);
|
||||
}, onSendStatusChange);
|
||||
};
|
||||
|
||||
var statusChangeHandler = function (processName, showName, isOn) {
|
||||
$log.debug('statusChangeHandler: ', processName, showName, isOn);
|
||||
if ( processName == 'buyingGiftCard' && !isOn) {
|
||||
$scope.sendStatus = 'success';
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
}, 100);
|
||||
} else if (showName) {
|
||||
$scope.sendStatus = showName;
|
||||
}
|
||||
};
|
||||
|
||||
var checkTransaction = lodash.throttle(function(count, dataSrc) {
|
||||
amazonService.createGiftCard(dataSrc, function(err, giftCard) {
|
||||
$log.debug("creating gift card " + count);
|
||||
if (err) {
|
||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||
giftCard = {};
|
||||
giftCard.status = 'FAILURE';
|
||||
showError('Error creating gift card', err);
|
||||
}
|
||||
|
||||
if (giftCard.status == 'PENDING' && count < 3) {
|
||||
$log.debug("Waiting for payment confirmation");
|
||||
checkTransaction(count + 1, dataSrc);
|
||||
return;
|
||||
}
|
||||
|
||||
var now = moment().unix() * 1000;
|
||||
|
||||
var newData = giftCard;
|
||||
newData['invoiceId'] = dataSrc.invoiceId;
|
||||
newData['accessKey'] = dataSrc.accessKey;
|
||||
newData['invoiceUrl'] = dataSrc.invoiceUrl;
|
||||
newData['amount'] = dataSrc.amount;
|
||||
newData['date'] = dataSrc.invoiceTime || now;
|
||||
newData['uuid'] = dataSrc.uuid;
|
||||
|
||||
if (newData.status == 'expired') {
|
||||
amazonService.savePendingGiftCard(newData, {
|
||||
remove: true
|
||||
}, function(err) {
|
||||
$log.error(err);
|
||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||
showError('Gift card expired');
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
amazonService.savePendingGiftCard(newData, null, function(err) {
|
||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||
$log.debug("Saving new gift card with status: " + newData.status);
|
||||
$scope.amazonGiftCard = newData;
|
||||
});
|
||||
});
|
||||
}, 8000, {
|
||||
'leading': true
|
||||
});
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
amount = data.stateParams.amount;
|
||||
currency = data.stateParams.currency;
|
||||
|
||||
if (amount > 1000) {
|
||||
showErrorAndBack('Purchase Amount is limited to USD 1000 per day');
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.amountUnitStr = $filter('formatFiatAmount')(amount) + ' ' + currency;
|
||||
|
||||
$scope.network = amazonService.getNetwork();
|
||||
$scope.wallets = profileService.getWallets({
|
||||
m: 1, // Only 1-signature wallet
|
||||
onlyComplete: true,
|
||||
network: $scope.network
|
||||
});
|
||||
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
||||
});
|
||||
|
||||
$scope.buyConfirm = function() {
|
||||
|
||||
var message = 'Buy gift card for ' + amount + ' ' + currency;
|
||||
var okText = 'Confirm';
|
||||
var cancelText = 'Cancel';
|
||||
popupService.showConfirm(null, message, okText, cancelText, function(ok) {
|
||||
if (!ok) return;
|
||||
|
||||
var config = configService.getSync();
|
||||
var configWallet = config.wallet;
|
||||
var walletSettings = configWallet.settings;
|
||||
// Get first wallet as UUID
|
||||
var uuid = $scope.wallet.id;
|
||||
var dataSrc = {
|
||||
currency: currency,
|
||||
amount: amount,
|
||||
uuid: uuid
|
||||
};
|
||||
|
||||
ongoingProcess.set('buyingGiftCard', true, statusChangeHandler);
|
||||
amazonService.createBitPayInvoice(dataSrc, function(err, dataInvoice) {
|
||||
if (err) {
|
||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||
showError('Error creating BitPay invoice', err);
|
||||
return;
|
||||
}
|
||||
|
||||
var accessKey = dataInvoice ? dataInvoice.accessKey : null;
|
||||
|
||||
if (!accessKey) {
|
||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||
showError('No access key defined');
|
||||
return;
|
||||
}
|
||||
|
||||
amazonService.getBitPayInvoice(dataInvoice.invoiceId, function(err, invoice) {
|
||||
if (err) {
|
||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||
showError('Error getting BitPay invoice', err);
|
||||
return;
|
||||
}
|
||||
|
||||
var payProUrl = (invoice && invoice.paymentUrls) ? invoice.paymentUrls.BIP73 : null;
|
||||
|
||||
if (!payProUrl) {
|
||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||
showError('Error fetching invoice');
|
||||
return;
|
||||
}
|
||||
|
||||
payproService.getPayProDetails(payProUrl, function(err, payProDetails) {
|
||||
if (err) {
|
||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||
showError('Error fetching payment info', bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
var outputs = [];
|
||||
var toAddress = payProDetails.toAddress;
|
||||
var amountSat = payProDetails.amount;
|
||||
var comment = amount + ' ' + currency + ' Amazon.com Gift Card';
|
||||
|
||||
outputs.push({
|
||||
'toAddress': toAddress,
|
||||
'amount': amountSat,
|
||||
'message': comment
|
||||
});
|
||||
|
||||
var txp = {
|
||||
toAddress: toAddress,
|
||||
amount: amountSat,
|
||||
outputs: outputs,
|
||||
message: comment,
|
||||
payProUrl: payProUrl,
|
||||
excludeUnconfirmedUtxos: configWallet.spendUnconfirmed ? false : true,
|
||||
feeLevel: walletSettings.feeLevel || 'normal'
|
||||
};
|
||||
|
||||
walletService.createTx($scope.wallet, txp, function(err, ctxp) {
|
||||
if (err) {
|
||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||
showError('Could not create transaction', bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
publishAndSign($scope.wallet, ctxp, function() {}, function(err, txSent) {
|
||||
if (err) {
|
||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||
showError('Could not send transaction', err);
|
||||
return;
|
||||
}
|
||||
$log.debug('Transaction broadcasted. Waiting for confirmation...');
|
||||
var invoiceId = JSON.parse(payProDetails.merchant_data).invoiceId;
|
||||
var dataSrc = {
|
||||
currency: currency,
|
||||
amount: amount,
|
||||
uuid: uuid,
|
||||
accessKey: accessKey,
|
||||
invoiceId: invoice.id,
|
||||
invoiceUrl: payProUrl,
|
||||
invoiceTime: invoice.invoiceTime
|
||||
};
|
||||
checkTransaction(1, dataSrc);
|
||||
});
|
||||
});
|
||||
}, true); // Disable loader
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.showWalletSelector = function() {
|
||||
$scope.walletSelectorTitle = 'Buy from';
|
||||
$scope.showWallets = true;
|
||||
};
|
||||
|
||||
$scope.onWalletSelect = function(wallet) {
|
||||
$scope.wallet = wallet;
|
||||
};
|
||||
|
||||
$scope.goBackHome = function() {
|
||||
$scope.sendStatus = '';
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableAnimate: true,
|
||||
historyRoot: true
|
||||
});
|
||||
$ionicHistory.clearHistory();
|
||||
var claimCode = $scope.amazonGiftCard ? $scope.amazonGiftCard.claimCode : null;
|
||||
$state.go('tabs.home').then(function() {
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableAnimate: true
|
||||
});
|
||||
$state.transitionTo('tabs.giftcards.amazon').then(function() {
|
||||
$state.transitionTo('tabs.giftcards.amazon.cards', { cardClaimCode: claimCode });
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
|
@ -1,25 +1,15 @@
|
|||
'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, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, amazonService, glideraService, bwcError, bitpayCardService) {
|
||||
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, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, glideraService, bwcError, bitpayCardService) {
|
||||
var cachedTxp = {};
|
||||
var toAmount;
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
var countDown = null;
|
||||
var giftCardAmountUSD;
|
||||
var giftCardAccessKey;
|
||||
var giftCardInvoiceTime;
|
||||
var giftCardUUID;
|
||||
var cachedSendMax = {};
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$ionicConfig.views.swipeBackEnabled(false);
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
// Amazon.com Gift Card parameters
|
||||
$scope.isGiftCard = data.stateParams.isGiftCard;
|
||||
giftCardAmountUSD = data.stateParams.giftCardAmountUSD;
|
||||
giftCardAccessKey = data.stateParams.giftCardAccessKey;
|
||||
giftCardInvoiceTime = data.stateParams.giftCardInvoiceTime;
|
||||
giftCardUUID = data.stateParams.giftCardUUID;
|
||||
|
||||
// Glidera parameters
|
||||
$scope.isGlidera = data.stateParams.isGlidera;
|
||||
|
@ -59,7 +49,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
function applyButtonText(multisig) {
|
||||
$scope.buttonText = $scope.isCordova ? gettextCatalog.getString('Slide') + ' ' : gettextCatalog.getString('Click') + ' ';
|
||||
|
||||
if ($scope.isGlidera || $scope.isGiftCard || $scope.cardId) {
|
||||
if ($scope.isGlidera || $scope.cardId) {
|
||||
$scope.buttonText += gettextCatalog.getString('to complete');
|
||||
} else if ($scope.paypro) {
|
||||
$scope.buttonText += gettextCatalog.getString('to pay');
|
||||
|
@ -166,8 +156,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.displayUnit = getDisplayUnit($scope.amountStr);
|
||||
if ($scope.cardAmountUSD) {
|
||||
$scope.alternativeAmountStr = $filter('formatFiatAmount')($scope.cardAmountUSD) + ' USD';
|
||||
} else if ($scope.giftCardAmountUSD) {
|
||||
$scope.alternativeAmountStr = $filter('formatFiatAmount')($scope.giftCardAmountUSD) + ' USD';
|
||||
} else {
|
||||
txFormatService.formatAlternativeStr(toAmount, function(v) {
|
||||
$scope.alternativeAmountStr = v;
|
||||
|
@ -599,7 +587,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.onSuccessConfirm = function() {
|
||||
var previousView = $ionicHistory.viewHistory().backView && $ionicHistory.viewHistory().backView.stateName;
|
||||
var fromBitPayCard = previousView.match(/tabs.bitpayCard/) ? true : false;
|
||||
var fromAmazon = previousView.match(/tabs.giftcards.amazon/) ? true : false;
|
||||
var fromGlidera = previousView.match(/tabs.buyandsell.glidera/) ? true : false;
|
||||
|
||||
$ionicHistory.nextViewOptions({
|
||||
|
@ -614,17 +601,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
id: $stateParams.cardId
|
||||
});
|
||||
}, 100);
|
||||
} else if (fromAmazon) {
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableAnimate: true,
|
||||
historyRoot: true
|
||||
});
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.home').then(function() {
|
||||
$state.transitionTo('tabs.giftcards.amazon', {
|
||||
cardClaimCode: $scope.amazonGiftCard ? $scope.amazonGiftCard.claimCode : null
|
||||
});
|
||||
});
|
||||
} else if (fromGlidera) {
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableAnimate: true,
|
||||
|
@ -814,75 +790,9 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
|
||||
walletService.publishAndSign(wallet, txp, function(err, txp) {
|
||||
if (err) return setSendError(err);
|
||||
|
||||
var previousView = $ionicHistory.viewHistory().backView && $ionicHistory.viewHistory().backView.stateName;
|
||||
var fromAmazon = previousView.match(/tabs.giftcards.amazon/) ? true : false;
|
||||
if (fromAmazon) {
|
||||
var count = 0;
|
||||
var invoiceId = JSON.parse($scope.paypro.merchant_data).invoiceId;
|
||||
var dataSrc = {
|
||||
currency: 'USD',
|
||||
amount: giftCardAmountUSD,
|
||||
uuid: giftCardUUID,
|
||||
accessKey: giftCardAccessKey,
|
||||
invoiceId: invoiceId,
|
||||
invoiceUrl: $scope.paypro.url,
|
||||
invoiceTime: giftCardInvoiceTime
|
||||
};
|
||||
ongoingProcess.set('creatingGiftCard', true);
|
||||
debounceCreate(count, dataSrc, onSendStatusChange);
|
||||
}
|
||||
}, onSendStatusChange);
|
||||
};
|
||||
|
||||
var debounceCreate = lodash.throttle(function(count, dataSrc) {
|
||||
debounceCreateGiftCard(count, dataSrc);
|
||||
}, 8000, {
|
||||
'leading': true
|
||||
});
|
||||
|
||||
var debounceCreateGiftCard = function(count, dataSrc, onSendStatusChange) {
|
||||
amazonService.createGiftCard(dataSrc, function(err, giftCard) {
|
||||
$log.debug("creating gift card " + count);
|
||||
if (err) {
|
||||
giftCard = {};
|
||||
giftCard.status = 'FAILURE';
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
}
|
||||
|
||||
if (giftCard.status == 'PENDING' && count < 3) {
|
||||
$log.debug("pending gift card not available yet");
|
||||
debounceCreate(count + 1, dataSrc);
|
||||
return;
|
||||
}
|
||||
|
||||
var now = moment().unix() * 1000;
|
||||
|
||||
var newData = giftCard;
|
||||
newData['invoiceId'] = dataSrc.invoiceId;
|
||||
newData['accessKey'] = dataSrc.accessKey;
|
||||
newData['invoiceUrl'] = dataSrc.invoiceUrl;
|
||||
newData['amount'] = dataSrc.amount;
|
||||
newData['date'] = dataSrc.invoiceTime || now;
|
||||
newData['uuid'] = dataSrc.uuid;
|
||||
|
||||
if (newData.status == 'expired') {
|
||||
amazonService.savePendingGiftCard(newData, {
|
||||
remove: true
|
||||
}, function(err) {
|
||||
$log.error(err);
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
amazonService.savePendingGiftCard(newData, null, function(err) {
|
||||
ongoingProcess.set('creatingGiftCard', false);
|
||||
$log.debug("Saving new gift card with status: " + newData.status);
|
||||
$scope.amazonGiftCard = newData;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getRates = function() {
|
||||
var config = configService.getSync().wallet.settings;
|
||||
var unitName = config.unitName;
|
||||
|
|
|
@ -7,7 +7,7 @@ angular.module('copayApp.controllers').controller('amazonCardDetailsController',
|
|||
amazonService.cancelGiftCard($scope.card, function(err, data) {
|
||||
ongoingProcess.set('cancelingGiftCard', false);
|
||||
if (err) {
|
||||
popupService.showAlert('Error', bwcError.msg(err));
|
||||
popupService.showAlert('Error canceling gift card', bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
$scope.card.cardStatus = data.cardStatus;
|
||||
|
|
|
@ -988,44 +988,49 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*/
|
||||
|
||||
.state('tabs.giftcards.amazon', {
|
||||
url: '/amazon',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'amazonController',
|
||||
templateUrl: 'views/amazon.html'
|
||||
}
|
||||
},
|
||||
params: {
|
||||
cardClaimCode: null
|
||||
url: '/amazon',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'amazonController',
|
||||
templateUrl: 'views/amazon.html'
|
||||
}
|
||||
})
|
||||
.state('tabs.giftcards.amazon.amount', {
|
||||
url: '/amount',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'amountController',
|
||||
templateUrl: 'views/amount.html'
|
||||
}
|
||||
},
|
||||
params: {
|
||||
isGiftCard: true,
|
||||
toName: 'Amazon.com Gift Card'
|
||||
}
|
||||
})
|
||||
.state('tabs.giftcards.amazon.cards', {
|
||||
url: '/cards',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'amazonCardsController',
|
||||
templateUrl: 'views/amazonCards.html'
|
||||
}
|
||||
})
|
||||
.state('tabs.giftcards.amazon.confirm', {
|
||||
url: '/confirm/:toAmount/:toAddress/:description/:giftCardAmountUSD/:giftCardAccessKey/:giftCardInvoiceTime/:giftCardUUID',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'confirmController',
|
||||
templateUrl: 'views/confirm.html'
|
||||
}
|
||||
},
|
||||
params: {
|
||||
isGiftCard: true,
|
||||
toName: 'Amazon.com Gift Card',
|
||||
paypro: null
|
||||
},
|
||||
params: {
|
||||
cardClaimCode: null
|
||||
}
|
||||
})
|
||||
.state('tabs.giftcards.amazon.amount', {
|
||||
url: '/amount',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'amountController',
|
||||
templateUrl: 'views/amount.html'
|
||||
}
|
||||
})
|
||||
},
|
||||
params: {
|
||||
nextStep: 'tabs.giftcards.amazon.buy',
|
||||
currency: 'USD',
|
||||
forceCurrency: true
|
||||
}
|
||||
})
|
||||
.state('tabs.giftcards.amazon.buy', {
|
||||
url: '/buy/:amount/:currency',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'buyAmazonController',
|
||||
templateUrl: 'views/buyAmazon.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/*
|
||||
*
|
||||
|
|
|
@ -40,13 +40,13 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
|
|||
};
|
||||
};
|
||||
|
||||
root.getEnvironment = function() {
|
||||
root.getNetwork = function() {
|
||||
_setCredentials();
|
||||
return credentials.NETWORK;
|
||||
};
|
||||
|
||||
root.savePendingGiftCard = function(gc, opts, cb) {
|
||||
var network = root.getEnvironment();
|
||||
var network = root.getNetwork();
|
||||
storageService.getAmazonGiftCards(network, function(err, oldGiftCards) {
|
||||
if (lodash.isString(oldGiftCards)) {
|
||||
oldGiftCards = JSON.parse(oldGiftCards);
|
||||
|
@ -74,7 +74,7 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
|
|||
};
|
||||
|
||||
root.getPendingGiftCards = function(cb) {
|
||||
var network = root.getEnvironment();
|
||||
var network = root.getNetwork();
|
||||
storageService.getAmazonGiftCards(network, function(err, giftCards) {
|
||||
var _gcds = giftCards ? JSON.parse(giftCards) : null;
|
||||
return cb(err, _gcds);
|
||||
|
|
|
@ -44,7 +44,8 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
|
|||
'updatingGiftCards': 'Updating Gift Cards...',
|
||||
'updatingGiftCard': 'Updating Gift Card...',
|
||||
'cancelingGiftCard': 'Canceling Gift Card...',
|
||||
'creatingGiftCard': 'Creating Gift Card...'
|
||||
'creatingGiftCard': 'Creating Gift Card...',
|
||||
'buyingGiftCard': 'Buying Gift Card...'
|
||||
};
|
||||
|
||||
root.clear = function() {
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
#amazon {
|
||||
$item-lateral-padding: 20px;
|
||||
$item-vertical-padding: 10px;
|
||||
$item-border-color: #EFEFEF;
|
||||
$item-label-color: #6C6C6E;
|
||||
@extend .deflash-blue;
|
||||
.icon-amazon {
|
||||
background-image: url("../img/icon-amazon.svg");
|
||||
}
|
||||
.spinner svg {
|
||||
stroke: black;
|
||||
fill: black;
|
||||
}
|
||||
|
||||
.add-bottom-for-cta {
|
||||
bottom: 92px;
|
||||
}
|
||||
.head {
|
||||
padding: 30px $item-lateral-padding 4rem;
|
||||
border-top: 0;
|
||||
|
||||
.sending-label {
|
||||
display: flex;
|
||||
font-size: 18px;
|
||||
align-items: center;
|
||||
margin-bottom: 1.8rem;
|
||||
|
||||
img {
|
||||
margin-right: 1rem;
|
||||
height: 35px;
|
||||
width: 35px;
|
||||
}
|
||||
|
||||
span {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.big-icon-svg {
|
||||
margin-right: 0.6rem;
|
||||
}
|
||||
|
||||
}
|
||||
.amount-label{
|
||||
line-height: 30px;
|
||||
.amount{
|
||||
font-size: 38px;
|
||||
margin-bottom: .5rem;
|
||||
|
||||
> .unit {
|
||||
font-family: "Roboto-Light";
|
||||
}
|
||||
}
|
||||
.alternative {
|
||||
font-size: 12px;
|
||||
font-family: "Roboto-Light";
|
||||
color: #9B9B9B;
|
||||
}
|
||||
}
|
||||
}
|
||||
.item {
|
||||
border-color: $item-border-color;
|
||||
}
|
||||
.info {
|
||||
.badge {
|
||||
border-radius: 0;
|
||||
padding: .5rem;
|
||||
}
|
||||
.item {
|
||||
color: #4A4A4A;
|
||||
padding-top: $item-vertical-padding;
|
||||
padding-bottom: $item-vertical-padding;
|
||||
padding-left: $item-lateral-padding;
|
||||
|
||||
&:not(.item-icon-right) {
|
||||
padding-right: $item-lateral-padding;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 14px;
|
||||
color: $item-label-color;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.capitalized {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.wallet .big-icon-svg > .bg {
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
padding: 2px;
|
||||
box-shadow: none;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.total-amount {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
&.single-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-top: 17px;
|
||||
padding-bottom: 17px;
|
||||
|
||||
.label {
|
||||
margin: 0;
|
||||
flex-grow: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
.item-divider {
|
||||
padding-top: 1.2rem;
|
||||
color: $item-label-color;
|
||||
font-size: 15px;
|
||||
}
|
||||
.wallet {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: .2rem 0;
|
||||
margin-bottom: 5px;
|
||||
|
||||
~ .bp-arrow-right {
|
||||
top: 14px;
|
||||
}
|
||||
|
||||
> i {
|
||||
padding: 0;
|
||||
position: static;
|
||||
|
||||
> img {
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
padding: 2px;
|
||||
margin-right: .7rem;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,4 +43,5 @@
|
|||
@import "includes/walletSelector";
|
||||
@import "integrations/coinbase";
|
||||
@import "integrations/glidera";
|
||||
@import "integrations/amazon";
|
||||
@import "custom-amount";
|
||||
|
|
|
@ -11,14 +11,15 @@
|
|||
Sandbox version. Only for testing purpose
|
||||
</div>
|
||||
|
||||
<div class="m20t text-center" ng-click="updatePendingGiftCards()">
|
||||
<div class="m20t text-center">
|
||||
<img src="img/GCs-logo-cllb.png" alt="Amazon.com Gift Card" width="200">
|
||||
<div class="size-12 m10t"><b>Only</b> redeemable on www.amazon.com (USA website)</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="!giftCards" class="m20t padding text-center">
|
||||
|
||||
<button class="button button-standard button-primary" ui-sref="tabs.giftcards.amazon.amount">
|
||||
<button class="button button-standard button-primary"
|
||||
ui-sref="tabs.giftcards.amazon.amount">
|
||||
Buy now
|
||||
</button>
|
||||
|
||||
|
@ -29,13 +30,20 @@
|
|||
</div>
|
||||
|
||||
<div class="m20t" ng-if="giftCards">
|
||||
<div class="card list">
|
||||
<div class="list card">
|
||||
<a class="item item-icon-left item-icon-right" href
|
||||
ui-sref="tabs.giftcards.amazon.amount">
|
||||
<i class="icon ion-bag"></i>
|
||||
<i class="icon ion-ios-pricetags-outline"></i>
|
||||
Buy Gift Card
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
|
||||
<a class="item item-icon-right item-icon-left"
|
||||
ui-sref="tabs.giftcards.amazon.cards">
|
||||
<i class="icon ion-ios-folder-outline"></i>
|
||||
Your cards
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="size-12 p15h">
|
||||
|
@ -49,29 +57,6 @@
|
|||
of <a ng-click="openExternalLink('http://amazon.com')">Amazon.com</a>, Inc. or its affiliates.
|
||||
No expiration date or service fees.
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="item item-heading">
|
||||
Your cards
|
||||
</div>
|
||||
<div ng-repeat="(id, item) in giftCards | orderObjectBy:'date':true track by $index"
|
||||
ng-click="openCardModal(item)"
|
||||
class="item item-avatar">
|
||||
<img src="img/a-smile_color_btn.png" alt="{{id}}" width="40">
|
||||
<h2 ng-if="item.claimCode">
|
||||
{{item.amount | currency : '$ ' : 2}}
|
||||
</h2>
|
||||
<h2 ng-if="!item.claimCode">
|
||||
-
|
||||
</h2>
|
||||
<p>
|
||||
<span class="text-warning" ng-if="item.status == 'FAILURE' || item.status == 'RESEND'">Error</span>
|
||||
<span class="text-gray" ng-if="item.status == 'PENDING'">Pending to confirmation</span>
|
||||
<span class="text-gray" ng-if="item.status == 'SUCCESS' && item.cardStatus == 'Canceled'">Canceled</span>
|
||||
<span class="text-gray" ng-if="item.status == 'SUCCESS' && item.cardStatus == 'Fulfilled'">{{item.date | amTimeAgo}}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ion-content>
|
||||
</ion-view>
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<ion-view>
|
||||
<ion-nav-bar class="bar-royal">
|
||||
<ion-nav-back-button>
|
||||
</ion-nav-back-button>
|
||||
<ion-nav-title>Your cards</ion-nav-title>
|
||||
</ion-nav-bar>
|
||||
|
||||
<ion-content>
|
||||
<div class="list card">
|
||||
<div ng-repeat="(id, item) in giftCards | orderObjectBy:'date':true track by $index"
|
||||
ng-click="openCardModal(item)"
|
||||
class="item item-avatar"
|
||||
ng-hide="hideCards">
|
||||
<img src="img/a-smile_color_btn.png" alt="{{id}}" width="40">
|
||||
<ion-spinner class="spinner-dark recent right m10 size-16" icon="crescent" ng-show="updatingPending[item.invoiceId]">
|
||||
</ion-spinner>
|
||||
<h2>
|
||||
<span ng-if="item.claimCode">{{item.amount | currency : '$ ' : 2}} {{item.currency}}</span>
|
||||
<span ng-if="!item.claimCode">-</span>
|
||||
</h2>
|
||||
<p>
|
||||
<span class="assertive" ng-if="item.status == 'FAILURE' || item.status == 'RESEND'">Error</span>
|
||||
<span class="assertive" ng-if="item.status == 'expired'">Expired</span>
|
||||
<span class="text-gray" ng-if="item.status == 'PENDING'">Pending to confirmation</span>
|
||||
<span class="assertive" ng-if="item.status == 'SUCCESS' && item.cardStatus == 'Canceled'">Canceled</span>
|
||||
<span class="text-gray" ng-if="item.status == 'SUCCESS' && item.cardStatus == 'Fulfilled'">{{item.date | amTimeAgo}}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="size-12 p15h">
|
||||
* <a ng-click="openExternalLink('http://amazon.com')">Amazon.com</a> is not a sponsor of this promotion.
|
||||
Except as required by law, <a ng-click="openExternalLink('http://amazon.com')">Amazon.com</a>
|
||||
Gift Cards ("GCs") cannot be transferred for value or redeemed for cash. GCs may be used only for purchases of
|
||||
eligible goods at <a ng-click="openExternalLink('http://amazon.com')">Amazon.com</a> or certain of its
|
||||
affiliated websites. For complete terms and conditions, see
|
||||
<a ng-click="openExternalLink('https://www.amazon.com/gc-legal')">www.amazon.com/gc-legal</a>.
|
||||
GCs are issued by ACI Gift Cards, Inc., a Washington corporation. All Amazon ®, ™ & © are IP
|
||||
of <a ng-click="openExternalLink('http://amazon.com')">Amazon.com</a>, Inc. or its affiliates.
|
||||
No expiration date or service fees.
|
||||
</div>
|
||||
</ion-content>
|
||||
</ion-view>
|
|
@ -21,7 +21,7 @@
|
|||
<i class="icon big-icon-svg" ng-if="isWallet">
|
||||
<img src="img/icon-wallet.svg" ng-style="{'background-color': toColor}" class="bg"/>
|
||||
</i>
|
||||
<span ng-if="!isWallet && !isGiftCard">
|
||||
<span ng-if="!isWallet">
|
||||
<i class="icon big-icon-svg" ng-if="isChromeApp">
|
||||
<img src="img/contact-placeholder.svg" class="bg"/>
|
||||
</i>
|
||||
|
@ -30,11 +30,6 @@
|
|||
<div class="bg icon-bitpay-card"></div>
|
||||
</i>
|
||||
</span>
|
||||
<span ng-if="isGiftCard">
|
||||
<i class="icon big-icon-svg">
|
||||
<div class="bg icon-amazon"></div>
|
||||
</i>
|
||||
</span>
|
||||
<span class="m10l">{{toName || toAddress}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -45,7 +40,6 @@
|
|||
<div class="amount-bar oh">
|
||||
<div class="title">
|
||||
<span translate>Amount</span>
|
||||
<div class="size-12" ng-show="isGiftCard">Purchase Amount is limited to USD 1000 per day</div>
|
||||
<div class="size-12" ng-if="cardId" ng-init="getRates()">{{exchangeRate}}</div>
|
||||
<div ng-show="isGlidera">
|
||||
<div class="limits" ng-show="limits && isGlidera == 'buy'">
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
<ion-view id="amazon" hide-tabs>
|
||||
<ion-nav-bar class="bar-royal">
|
||||
<ion-nav-back-button>
|
||||
</ion-nav-back-button>
|
||||
<ion-nav-title>Buy</ion-nav-title>
|
||||
</ion-nav-bar>
|
||||
|
||||
<ion-content class="add-bottom-for-cta">
|
||||
<!-- BUY -->
|
||||
<div class="list">
|
||||
|
||||
<div class="item head">
|
||||
<div class="sending-label">
|
||||
<i class="icon big-icon-svg">
|
||||
<div class="bg icon-amazon"></div>
|
||||
</i>
|
||||
<span>Amazon.com Gift Card</span>
|
||||
</div>
|
||||
<div class="amount-label">
|
||||
<div class="amount">{{amountUnitStr}}</div>
|
||||
<div class="alternative">
|
||||
Purchase Amount is limited to USD 1000 per day
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="info">
|
||||
<div class="item item-icon-right" ng-click="showWalletSelector()">
|
||||
<div class="label">From</div>
|
||||
<div class="wallet">
|
||||
<i class="icon big-icon-svg">
|
||||
<img src="img/icon-wallet.svg" ng-style="{'background-color': wallet.color}" class="bg">
|
||||
</i>
|
||||
{{wallet ? wallet.name : '...'}}
|
||||
</div>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</div>
|
||||
<div class="item item-divider"></div>
|
||||
<div class="item size-12">
|
||||
* <a ng-click="openExternalLink('http://amazon.com')">Amazon.com</a> is not a sponsor of this promotion.
|
||||
Except as required by law, <a ng-click="openExternalLink('http://amazon.com')">Amazon.com</a>
|
||||
Gift Cards ("GCs") cannot be transferred for value or redeemed for cash. GCs may be used only for purchases of
|
||||
eligible goods at <a ng-click="openExternalLink('http://amazon.com')">Amazon.com</a> or certain of its
|
||||
affiliated websites. For complete terms and conditions, see
|
||||
<a ng-click="openExternalLink('https://www.amazon.com/gc-legal')">www.amazon.com/gc-legal</a>.
|
||||
GCs are issued by ACI Gift Cards, Inc., a Washington corporation. All Amazon ®, ™ & © are IP
|
||||
of <a ng-click="openExternalLink('http://amazon.com')">Amazon.com</a>, Inc. or its affiliates.
|
||||
No expiration date or service fees.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ion-content>
|
||||
|
||||
<click-to-accept
|
||||
ng-disabled="!wallet"
|
||||
ng-click="buyConfirm()"
|
||||
ng-if="!isCordova"
|
||||
click-send-status="sendStatus"
|
||||
has-wallet-chosen="wallet"
|
||||
insufficient-funds="false"
|
||||
no-matching-wallet="false">
|
||||
Confirm purchase
|
||||
</click-to-accept>
|
||||
<slide-to-accept
|
||||
ng-disabled="!wallet"
|
||||
ng-if="isCordova"
|
||||
slide-on-confirm="buyConfirm()"
|
||||
slide-send-status="sendStatus"
|
||||
has-wallet-chosen="wallet"
|
||||
insufficient-funds="false"
|
||||
no-matching-wallet="false">
|
||||
Slide to buy
|
||||
</slide-to-accept>
|
||||
<slide-to-accept-success
|
||||
slide-success-show="sendStatus === 'success'"
|
||||
slide-success-on-confirm="goBackHome()"
|
||||
slide-success-hide-on-confirm="true">
|
||||
<span ng-show="amazonGiftCard.status == 'FAILURE'">
|
||||
Your purchase could not be completed
|
||||
</span>
|
||||
<span ng-show="amazonGiftCard.status == 'PENDING'">
|
||||
Your purchase was added to the list of pending
|
||||
</span>
|
||||
<span ng-show="amazonGiftCard.status == 'SUCCESS'">
|
||||
Bought {{amazonGiftCard.amount}} {{amazonGiftCard.currency}}
|
||||
</span>
|
||||
<div class="m10 size-14" ng-show="amazonGiftCard.status == 'SUCCESS'">
|
||||
Gift card generated and ready to use.
|
||||
</div>
|
||||
</slide-to-accept-success>
|
||||
|
||||
<wallet-selector
|
||||
wallet-selector-title="walletSelectorTitle"
|
||||
wallet-selector-wallets="wallets"
|
||||
wallet-selector-selected-wallet="wallet"
|
||||
wallet-selector-show="showWallets"
|
||||
wallet-selector-on-select="onWalletSelect">
|
||||
</wallet-selector>
|
||||
</ion-view>
|
|
@ -45,6 +45,9 @@
|
|||
<span class="text-bold" ng-show="card.status == 'FAILURE' || card.status == 'RESEND'">
|
||||
FAILURE
|
||||
</span>
|
||||
<span class="text-bold" ng-show="card.status == 'expired'">
|
||||
EXPIRED
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m10t text-center">
|
||||
|
@ -96,7 +99,7 @@
|
|||
<span class="assertive">Cancel</span>
|
||||
</a>
|
||||
<a class="item" ng-show="card.status == 'FAILURE' || card.cardStatus == 'Canceled'
|
||||
|| card.cardStatus == 'Expired'" ng-click="remove()">
|
||||
|| card.cardStatus == 'Expired' || card.status == 'expired'" ng-click="remove()">
|
||||
<span class="assertive">Remove</span>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -168,7 +168,7 @@
|
|||
<i class="icon big-icon-svg">
|
||||
<div class="bg icon-amazon"></div>
|
||||
</i>
|
||||
<span translate>Buy an Amazon Gift Card</span>
|
||||
<span translate>Buy a gift card</span>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue