mirror of https://github.com/BTCPrivate/copay.git
Ref: amazon integration
This commit is contained in:
parent
3141feef27
commit
59d668f292
|
@ -51,8 +51,8 @@ angular.module('copayApp.controllers').controller('amazonCardsController',
|
||||||
remove: true
|
remove: true
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
updateGiftCards();
|
updateGiftCards();
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
amazonService.savePendingGiftCard(newData, null, function(err) {
|
amazonService.savePendingGiftCard(newData, null, function(err) {
|
||||||
|
@ -85,11 +85,11 @@ angular.module('copayApp.controllers').controller('amazonCardsController',
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
$scope.cardClaimCode = data.stateParams.cardClaimCode;
|
$scope.invoiceId = data.stateParams.invoiceId;
|
||||||
updateGiftCards(function() {
|
updateGiftCards(function() {
|
||||||
if ($scope.cardClaimCode) {
|
if ($scope.invoiceId) {
|
||||||
var card = lodash.find($scope.giftCards, {
|
var card = lodash.find($scope.giftCards, {
|
||||||
claimCode: $scope.cardClaimCode
|
invoiceId: $scope.invoiceId
|
||||||
});
|
});
|
||||||
if (lodash.isEmpty(card)) {
|
if (lodash.isEmpty(card)) {
|
||||||
popupService.showAlert(null, 'Card not found');
|
popupService.showAlert(null, 'Card not found');
|
||||||
|
|
|
@ -1,29 +1,41 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('buyAmazonController', function($scope, $log, $state, $timeout, $filter, $ionicHistory, $ionicConfig, lodash, amazonService, popupService, profileService, ongoingProcess, configService, walletService, payproService, bwcError, externalLinkService, platformInfo) {
|
angular.module('copayApp.controllers').controller('buyAmazonController', function($scope, $log, $state, $timeout, $filter, $ionicHistory, $ionicConfig, lodash, amazonService, popupService, profileService, ongoingProcess, configService, walletService, payproService, bwcError, externalLinkService, platformInfo, gettextCatalog, txFormatService) {
|
||||||
|
|
||||||
var amount;
|
var amount;
|
||||||
var currency;
|
var currency;
|
||||||
$scope.isCordova = platformInfo.isCordova;
|
var createdTx;
|
||||||
|
var message;
|
||||||
|
var invoiceId;
|
||||||
|
var configWallet = configService.getSync().wallet;
|
||||||
|
$scope.isCordova = platformInfo.isCordova;
|
||||||
|
|
||||||
$scope.openExternalLink = function(url) {
|
$scope.openExternalLink = function(url) {
|
||||||
externalLinkService.open(url);
|
externalLinkService.open(url);
|
||||||
};
|
};
|
||||||
|
|
||||||
var showErrorAndBack = function(msg, err) {
|
var _resetValues = function() {
|
||||||
|
$scope.totalAmountStr = $scope.amount = $scope.invoiceFee = $scope.networkFee = $scope.totalAmount = $scope.wallet = null;
|
||||||
|
createdTx = message = invoiceId = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
var showErrorAndBack = function(title, msg) {
|
||||||
|
title = title || gettextCatalog.getString('Error');
|
||||||
$scope.sendStatus = '';
|
$scope.sendStatus = '';
|
||||||
$log.error(err);
|
$log.error(msg);
|
||||||
err = err && err.errors ? err.errors[0].message : err;
|
msg = (msg && msg.errors) ? msg.errors[0].message : msg;
|
||||||
popupService.showAlert(msg, err, function() {
|
popupService.showAlert(title, msg, function() {
|
||||||
$ionicHistory.goBack();
|
$ionicHistory.goBack();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var showError = function(msg, err) {
|
var showError = function(title, msg, cb) {
|
||||||
|
cb = cb || function() {};
|
||||||
|
title = title || gettextCatalog.getString('Error');
|
||||||
$scope.sendStatus = '';
|
$scope.sendStatus = '';
|
||||||
$log.error(err);
|
$log.error(msg);
|
||||||
err = err && err.errors ? err.errors[0].message : (err || '');
|
msg = (msg && msg.errors) ? msg.errors[0].message : msg;
|
||||||
popupService.showAlert(msg, err);
|
popupService.showAlert(title, msg, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
var publishAndSign = function(wallet, txp, onSendStatusChange, cb) {
|
var publishAndSign = function(wallet, txp, onSendStatusChange, cb) {
|
||||||
|
@ -51,6 +63,111 @@ angular.module('copayApp.controllers').controller('buyAmazonController', functio
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var satToFiat = function(sat, cb) {
|
||||||
|
txFormatService.toFiat(sat, $scope.currencyIsoCode, function(value) {
|
||||||
|
return cb(value);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var setTotalAmount = function(amountSat, invoiceFeeSat, networkFeeSat) {
|
||||||
|
satToFiat(amountSat, function(a) {
|
||||||
|
$scope.amount = Number(a);
|
||||||
|
|
||||||
|
satToFiat(invoiceFeeSat, function(i) {
|
||||||
|
$scope.invoiceFee = Number(i);
|
||||||
|
|
||||||
|
satToFiat(networkFeeSat, function(n) {
|
||||||
|
$scope.networkFee = Number(n);
|
||||||
|
$scope.totalAmount = $scope.amount + $scope.invoiceFee + $scope.networkFee;
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.$digest();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var createInvoice = function(data, cb) {
|
||||||
|
amazonService.createBitPayInvoice(data, function(err, dataInvoice) {
|
||||||
|
if (err) {
|
||||||
|
var err_title = gettextCatalog.getString('Error creating the invoice');
|
||||||
|
var err_msg;
|
||||||
|
if (err && err.message && err.message.match(/suspended/i)) {
|
||||||
|
err_title = gettextCatalog.getString('Service not available');
|
||||||
|
err_msg = gettextCatalog.getString('Amazon.com Gift Card Service is not available at this moment. Please try back later.');
|
||||||
|
} else if (err && err.message) {
|
||||||
|
err_msg = err.message;
|
||||||
|
} else {
|
||||||
|
err_msg = gettextCatalog.getString('Could not access Gift Card Service');
|
||||||
|
};
|
||||||
|
|
||||||
|
return cb({
|
||||||
|
title: err_title,
|
||||||
|
message: err_msg
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var accessKey = dataInvoice ? dataInvoice.accessKey : null;
|
||||||
|
|
||||||
|
if (!accessKey) {
|
||||||
|
return cb({
|
||||||
|
message: gettextCatalog.getString('No access key defined')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
amazonService.getBitPayInvoice(dataInvoice.invoiceId, function(err, invoice) {
|
||||||
|
if (err) {
|
||||||
|
return cb({
|
||||||
|
message: gettextCatalog.getString('Could not get the invoice')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return cb(null, invoice, accessKey);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var createTx = function(wallet, invoice, message, cb) {
|
||||||
|
var payProUrl = (invoice && invoice.paymentUrls) ? invoice.paymentUrls.BIP73 : null;
|
||||||
|
|
||||||
|
if (!payProUrl) {
|
||||||
|
return cb({
|
||||||
|
title: gettextCatalog.getString('Error in Payment Protocol'),
|
||||||
|
message: gettextCatalog.getString('Invalid URL')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var outputs = [];
|
||||||
|
var toAddress = invoice.bitcoinAddress;
|
||||||
|
var amountSat = parseInt(invoice.btcDue * 100000000); // BTC to Satoshi
|
||||||
|
|
||||||
|
outputs.push({
|
||||||
|
'toAddress': toAddress,
|
||||||
|
'amount': amountSat,
|
||||||
|
'message': message
|
||||||
|
});
|
||||||
|
|
||||||
|
var txp = {
|
||||||
|
toAddress: toAddress,
|
||||||
|
amount: amountSat,
|
||||||
|
outputs: outputs,
|
||||||
|
message: message,
|
||||||
|
payProUrl: payProUrl,
|
||||||
|
excludeUnconfirmedUtxos: configWallet.spendUnconfirmed ? false : true,
|
||||||
|
feeLevel: configWallet.settings.feeLevel || 'normal'
|
||||||
|
};
|
||||||
|
|
||||||
|
walletService.createTx(wallet, txp, function(err, ctxp) {
|
||||||
|
if (err) {
|
||||||
|
return cb({
|
||||||
|
title: gettextCatalog.getString('Could not create transaction'),
|
||||||
|
message: bwcError.msg(err)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return cb(null, ctxp);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var checkTransaction = lodash.throttle(function(count, dataSrc) {
|
var checkTransaction = lodash.throttle(function(count, dataSrc) {
|
||||||
amazonService.createGiftCard(dataSrc, function(err, giftCard) {
|
amazonService.createGiftCard(dataSrc, function(err, giftCard) {
|
||||||
$log.debug("creating gift card " + count);
|
$log.debug("creating gift card " + count);
|
||||||
|
@ -58,7 +175,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController', functio
|
||||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||||
giftCard = {};
|
giftCard = {};
|
||||||
giftCard.status = 'FAILURE';
|
giftCard.status = 'FAILURE';
|
||||||
showError('Error creating gift card', err);
|
showError(gettextCatalog.getString('Error creating gift card'), err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (giftCard.status == 'PENDING' && count < 3) {
|
if (giftCard.status == 'PENDING' && count < 3) {
|
||||||
|
@ -83,9 +200,9 @@ angular.module('copayApp.controllers').controller('buyAmazonController', functio
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
$log.error(err);
|
$log.error(err);
|
||||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||||
showError('Gift card expired');
|
showError(null, gettextCatalog.getString('Gift card expired'));
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
amazonService.savePendingGiftCard(newData, null, function(err) {
|
amazonService.savePendingGiftCard(newData, null, function(err) {
|
||||||
|
@ -98,6 +215,57 @@ angular.module('copayApp.controllers').controller('buyAmazonController', functio
|
||||||
'leading': true
|
'leading': true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var initialize = function(wallet) {
|
||||||
|
var parsedAmount = txFormatService.parseAmount(amount, currency);
|
||||||
|
$scope.currencyIsoCode = parsedAmount.alternativeIsoCode;
|
||||||
|
$scope.amountUnitStr = parsedAmount.amountUnitStr;
|
||||||
|
var dataSrc = {
|
||||||
|
amount: parsedAmount.amount,
|
||||||
|
currency: parsedAmount.currency,
|
||||||
|
uuid: wallet.id
|
||||||
|
};
|
||||||
|
ongoingProcess.set('loadingTxInfo', true);
|
||||||
|
createInvoice(dataSrc, function(err, invoice, accessKey) {
|
||||||
|
if (err) {
|
||||||
|
ongoingProcess.set('loadingTxInfo', false);
|
||||||
|
showErrorAndBack(err.title, err.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Sometimes API does not return this element;
|
||||||
|
invoice['buyerPaidBtcMinerFee'] = invoice.buyerPaidBtcMinerFee || 0;
|
||||||
|
var invoiceFeeSat = (invoice.buyerPaidBtcMinerFee * 100000000).toFixed();
|
||||||
|
|
||||||
|
message = gettextCatalog.getString("Amazon.con Gift Card {{amountStr}}", {
|
||||||
|
amountStr: $scope.amountUnitStr
|
||||||
|
});
|
||||||
|
|
||||||
|
createTx(wallet, invoice, message, function(err, ctxp) {
|
||||||
|
ongoingProcess.set('loadingTxInfo', false);
|
||||||
|
if (err) {
|
||||||
|
_resetValues();
|
||||||
|
showError(err.title, err.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save in memory
|
||||||
|
createdTx = ctxp;
|
||||||
|
invoiceId = invoice.id;
|
||||||
|
|
||||||
|
createdTx['giftData'] = {
|
||||||
|
currency: dataSrc.currency,
|
||||||
|
amount: dataSrc.amount,
|
||||||
|
uuid: dataSrc.uuid,
|
||||||
|
accessKey: accessKey,
|
||||||
|
invoiceId: invoice.id,
|
||||||
|
invoiceUrl: invoice.url,
|
||||||
|
invoiceTime: invoice.invoiceTime
|
||||||
|
};
|
||||||
|
$scope.totalAmountStr = txFormatService.formatAmountStr(ctxp.amount);
|
||||||
|
setTotalAmount(parsedAmount.amountSat, invoiceFeeSat, ctxp.fee);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeLeave", function(event, data) {
|
$scope.$on("$ionicView.beforeLeave", function(event, data) {
|
||||||
$ionicConfig.views.swipeBackEnabled(true);
|
$ionicConfig.views.swipeBackEnabled(true);
|
||||||
});
|
});
|
||||||
|
@ -111,12 +279,10 @@ angular.module('copayApp.controllers').controller('buyAmazonController', functio
|
||||||
currency = data.stateParams.currency;
|
currency = data.stateParams.currency;
|
||||||
|
|
||||||
if (amount > 1000) {
|
if (amount > 1000) {
|
||||||
showErrorAndBack('Purchase Amount is limited to USD 1000 per day');
|
showErrorAndBack(null, gettextCatalog.getString('Purchase Amount is limited to USD 1000 per day'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.amountUnitStr = $filter('formatFiatAmount')(amount) + ' ' + currency;
|
|
||||||
|
|
||||||
$scope.network = amazonService.getNetwork();
|
$scope.network = amazonService.getNetwork();
|
||||||
$scope.wallets = profileService.getWallets({
|
$scope.wallets = profileService.getWallets({
|
||||||
onlyComplete: true,
|
onlyComplete: true,
|
||||||
|
@ -124,135 +290,47 @@ angular.module('copayApp.controllers').controller('buyAmazonController', functio
|
||||||
hasFunds: true
|
hasFunds: true
|
||||||
});
|
});
|
||||||
if (lodash.isEmpty($scope.wallets)) {
|
if (lodash.isEmpty($scope.wallets)) {
|
||||||
showErrorAndBack('No wallets with funds');
|
showErrorAndBack(null, gettextCatalog.getString('No wallets available'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$scope.wallet = $scope.wallets[0]; // Default first wallet
|
$scope.onWalletSelect($scope.wallets[0]); // Default first wallet
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.buyConfirm = function() {
|
$scope.buyConfirm = function() {
|
||||||
|
if (!createdTx) {
|
||||||
var message = 'Buy gift card for ' + amount + ' ' + currency;
|
showError(null, gettextCatalog.getString('Transaction has not been created'));
|
||||||
var okText = 'Confirm';
|
return;
|
||||||
var cancelText = 'Cancel';
|
}
|
||||||
popupService.showConfirm(null, message, okText, cancelText, function(ok) {
|
var title = gettextCatalog.getString('Confirm');
|
||||||
if (!ok) return;
|
var okText = gettextCatalog.getString('Ok');
|
||||||
|
var cancelText = gettextCatalog.getString('Cancel');
|
||||||
var config = configService.getSync();
|
popupService.showConfirm(title, message, okText, cancelText, function(ok) {
|
||||||
var configWallet = config.wallet;
|
if (!ok) {
|
||||||
var walletSettings = configWallet.settings;
|
$scope.sendStatus = '';
|
||||||
// Get first wallet as UUID
|
return;
|
||||||
var uuid = $scope.wallet.id;
|
}
|
||||||
var dataSrc = {
|
|
||||||
currency: currency,
|
|
||||||
amount: amount,
|
|
||||||
uuid: uuid
|
|
||||||
};
|
|
||||||
|
|
||||||
ongoingProcess.set('buyingGiftCard', true, statusChangeHandler);
|
ongoingProcess.set('buyingGiftCard', true, statusChangeHandler);
|
||||||
amazonService.createBitPayInvoice(dataSrc, function(err, dataInvoice) {
|
publishAndSign($scope.wallet, createdTx, function() {}, function(err, txSent) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
_resetValues();
|
||||||
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
|
||||||
|
showError(gettextCatalog.getString('Could not send transaction'), err);
|
||||||
if (err && err.message && err.message.match(/suspended/i)) {
|
|
||||||
showError('Service not available', 'Amazon Gift Card Service is not available at this moment. Please try back later.');
|
|
||||||
} else {
|
|
||||||
showError('Could not access Gift Card Service', err);
|
|
||||||
};
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
checkTransaction(1, createdTx.giftData);
|
||||||
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.showWalletSelector = function() {
|
||||||
$scope.walletSelectorTitle = 'Buy from';
|
$scope.walletSelectorTitle = gettextCatalog.getString('Buy from');
|
||||||
$scope.showWallets = true;
|
$scope.showWallets = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.onWalletSelect = function(wallet) {
|
$scope.onWalletSelect = function(wallet) {
|
||||||
$scope.wallet = wallet;
|
$scope.wallet = wallet;
|
||||||
|
initialize(wallet);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.goBackHome = function() {
|
$scope.goBackHome = function() {
|
||||||
|
@ -262,14 +340,13 @@ angular.module('copayApp.controllers').controller('buyAmazonController', functio
|
||||||
historyRoot: true
|
historyRoot: true
|
||||||
});
|
});
|
||||||
$ionicHistory.clearHistory();
|
$ionicHistory.clearHistory();
|
||||||
var claimCode = $scope.amazonGiftCard ? $scope.amazonGiftCard.claimCode : null;
|
|
||||||
$state.go('tabs.home').then(function() {
|
$state.go('tabs.home').then(function() {
|
||||||
$ionicHistory.nextViewOptions({
|
$ionicHistory.nextViewOptions({
|
||||||
disableAnimate: true
|
disableAnimate: true
|
||||||
});
|
});
|
||||||
$state.transitionTo('tabs.giftcards.amazon').then(function() {
|
$state.transitionTo('tabs.giftcards.amazon').then(function() {
|
||||||
$state.transitionTo('tabs.giftcards.amazon.cards', {
|
$state.transitionTo('tabs.giftcards.amazon.cards', {
|
||||||
cardClaimCode: claimCode
|
invoiceId: invoiceId
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1049,7 +1049,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
cardClaimCode: null
|
invoiceId: null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.state('tabs.giftcards.amazon.amount', {
|
.state('tabs.giftcards.amazon.amount', {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<ion-nav-bar class="bar-royal">
|
<ion-nav-bar class="bar-royal">
|
||||||
<ion-nav-back-button>
|
<ion-nav-back-button>
|
||||||
</ion-nav-back-button>
|
</ion-nav-back-button>
|
||||||
<ion-nav-title>Buy</ion-nav-title>
|
<ion-nav-title>{{'Buy'|translate}}</ion-nav-title>
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
|
|
||||||
<ion-content class="add-bottom-for-cta">
|
<ion-content class="add-bottom-for-cta">
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="amount-label">
|
<div class="amount-label">
|
||||||
<div class="amount">{{amountUnitStr}}</div>
|
<div class="amount">{{amountUnitStr}}</div>
|
||||||
<div class="alternative">
|
<div class="alternative" translate>
|
||||||
Purchase Amount is limited to USD 1000 per day
|
Purchase Amount is limited to USD 1000 per day
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<div class="item item-icon-right" ng-click="showWalletSelector()">
|
<div class="item item-icon-right" ng-click="showWalletSelector()">
|
||||||
<div class="label">From</div>
|
<div class="label" translate>From</div>
|
||||||
<div class="wallet">
|
<div class="wallet">
|
||||||
<i class="icon big-icon-svg">
|
<i class="icon big-icon-svg">
|
||||||
<img src="img/icon-wallet.svg" ng-class="{'wallet-background-color-default': !wallet.color}" ng-style="{'background-color': wallet.color}" class="bg">
|
<img src="img/icon-wallet.svg" ng-class="{'wallet-background-color-default': !wallet.color}" ng-style="{'background-color': wallet.color}" class="bg">
|
||||||
|
@ -35,6 +35,36 @@
|
||||||
</div>
|
</div>
|
||||||
<i class="icon bp-arrow-right"></i>
|
<i class="icon bp-arrow-right"></i>
|
||||||
</div>
|
</div>
|
||||||
|
<div ng-show="totalAmountStr">
|
||||||
|
<div class="item item-divider" translate>
|
||||||
|
Details
|
||||||
|
</div>
|
||||||
|
<div class="item">
|
||||||
|
<span translate>Gift card</span>
|
||||||
|
<span class="item-note">
|
||||||
|
{{amount | currency:'$ ':2}}<span ng-if="amount"> {{currencyIsoCode}}</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="item">
|
||||||
|
<span translate>Invoice Fee</span>
|
||||||
|
<span class="item-note">
|
||||||
|
<span>{{invoiceFee | currency:'$ ':2}}<span ng-if="invoiceFee"> {{currencyIsoCode}}</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="item">
|
||||||
|
<span translate>Network Fee</span>
|
||||||
|
<span class="item-note">
|
||||||
|
<span>{{networkFee | currency:'$ ':2}}<span ng-if="networkFee"> {{currencyIsoCode}}</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="item">
|
||||||
|
<span translate>Total</span>
|
||||||
|
<span class="item-note">
|
||||||
|
<span ng-if="totalAmount">{{totalAmount | currency:'$ ':2}} {{currencyIsoCode}}</span>
|
||||||
|
<span ng-if="totalAmountStr">({{totalAmountStr}})</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="item item-divider"></div>
|
<div class="item item-divider"></div>
|
||||||
<div class="item size-12">
|
<div class="item size-12">
|
||||||
* <a ng-click="openExternalLink('http://amazon.com')">Amazon.com</a> is not a sponsor of this promotion.
|
* <a ng-click="openExternalLink('http://amazon.com')">Amazon.com</a> is not a sponsor of this promotion.
|
||||||
|
@ -56,30 +86,29 @@
|
||||||
ng-click="buyConfirm()"
|
ng-click="buyConfirm()"
|
||||||
ng-if="!isCordova"
|
ng-if="!isCordova"
|
||||||
click-send-status="sendStatus"
|
click-send-status="sendStatus"
|
||||||
is-disabled="!wallet">
|
is-disabled="!wallet || !totalAmountStr">
|
||||||
Confirm purchase
|
{{'Confirm purchase'|translate}}
|
||||||
</click-to-accept>
|
</click-to-accept>
|
||||||
<slide-to-accept
|
<slide-to-accept
|
||||||
ng-if="isCordova"
|
ng-if="isCordova && wallet && totalAmountStr"
|
||||||
slide-on-confirm="buyConfirm()"
|
slide-on-confirm="buyConfirm()"
|
||||||
slide-send-status="sendStatus"
|
slide-send-status="sendStatus">
|
||||||
is-disabled="!wallet">
|
{{'Slide to buy'|translate}}
|
||||||
Slide to buy
|
|
||||||
</slide-to-accept>
|
</slide-to-accept>
|
||||||
<slide-to-accept-success
|
<slide-to-accept-success
|
||||||
slide-success-show="sendStatus === 'success'"
|
slide-success-show="sendStatus === 'success'"
|
||||||
slide-success-on-confirm="goBackHome()"
|
slide-success-on-confirm="goBackHome()"
|
||||||
slide-success-hide-on-confirm="true">
|
slide-success-hide-on-confirm="true">
|
||||||
<span ng-show="amazonGiftCard.status == 'FAILURE'">
|
<span ng-show="amazonGiftCard.status == 'FAILURE'" translate>
|
||||||
Your purchase could not be completed
|
Your purchase could not be completed
|
||||||
</span>
|
</span>
|
||||||
<span ng-show="amazonGiftCard.status == 'PENDING'">
|
<span ng-show="amazonGiftCard.status == 'PENDING'" translate>
|
||||||
Your purchase was added to the list of pending
|
Your purchase was added to the list of pending
|
||||||
</span>
|
</span>
|
||||||
<span ng-show="amazonGiftCard.status == 'SUCCESS'">
|
<span ng-show="amazonGiftCard.status == 'SUCCESS'" translate>
|
||||||
Bought {{amazonGiftCard.amount}} {{amazonGiftCard.currency}}
|
Bought {{amountUnitStr}}
|
||||||
</span>
|
</span>
|
||||||
<div class="m10 size-14" ng-show="amazonGiftCard.status == 'SUCCESS'">
|
<div class="m10 size-14" ng-show="amazonGiftCard.status == 'SUCCESS'" translate>
|
||||||
Gift card generated and ready to use.
|
Gift card generated and ready to use.
|
||||||
</div>
|
</div>
|
||||||
</slide-to-accept-success>
|
</slide-to-accept-success>
|
||||||
|
|
Loading…
Reference in New Issue