Merge pull request #5115 from cmgustavo/feat/amazon-new-send-flow
New send flow for the Amazon integration
This commit is contained in:
commit
ee0bec9b06
12 changed files with 217 additions and 396 deletions
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amazonController',
|
||||
function($scope, $timeout, $ionicModal, $log, lodash, bwcError, amazonService, platformInfo, externalLinkService, popupService) {
|
||||
function($scope, $timeout, $ionicModal, $log, lodash, amazonService, platformInfo, externalLinkService, popupService, gettextCatalog) {
|
||||
|
||||
$scope.network = amazonService.getEnvironment();
|
||||
|
||||
|
|
@ -19,6 +19,14 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
if ($scope.cardClaimCode) {
|
||||
var card = lodash.find($scope.giftCards, { claimCode: $scope.cardClaimCode });
|
||||
if (lodash.isEmpty(card)) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Card not found'));
|
||||
return;
|
||||
}
|
||||
$scope.openCardModal(card);
|
||||
}
|
||||
});
|
||||
$scope.updatePendingGiftCards();
|
||||
};
|
||||
|
|
@ -26,12 +34,16 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
$scope.updatePendingGiftCards = lodash.debounce(function() {
|
||||
|
||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||
$timeout(function() {
|
||||
$scope.giftCards = gcds;
|
||||
$scope.$digest();
|
||||
});
|
||||
lodash.forEach(gcds, function(dataFromStorage) {
|
||||
if (dataFromStorage.status == 'PENDING') {
|
||||
$log.debug("creating gift card");
|
||||
amazonService.createGiftCard(dataFromStorage, function(err, giftCard) {
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
if (giftCard.status != 'PENDING') {
|
||||
|
|
@ -84,6 +96,7 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.cardClaimCode = data.stateParams.cardClaimCode;
|
||||
initAmazon();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService) {
|
||||
angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, amazonService, profileService) {
|
||||
|
||||
var unitToSatoshi;
|
||||
var satToUnit;
|
||||
|
|
@ -16,17 +16,18 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
|
||||
$scope.isGiftCard = data.stateParams.isGiftCard;
|
||||
$scope.isWallet = data.stateParams.isWallet;
|
||||
$scope.cardId = data.stateParams.cardId;
|
||||
$scope.toAddress = data.stateParams.toAddress;
|
||||
$scope.toName = data.stateParams.toName;
|
||||
$scope.toEmail = data.stateParams.toEmail;
|
||||
$scope.showAlternativeAmount = !!$scope.cardId;
|
||||
$scope.showAlternativeAmount = !!$scope.cardId || !!$scope.isGiftCard;
|
||||
$scope.toColor = data.stateParams.toColor;
|
||||
|
||||
$scope.customAmount = data.stateParams.customAmount;
|
||||
|
||||
if (!$scope.cardId && !data.stateParams.toAddress) {
|
||||
if (!$scope.cardId && !$scope.isGiftCard && !data.stateParams.toAddress) {
|
||||
$log.error('Bad params at amount')
|
||||
throw ('bad params');
|
||||
}
|
||||
|
|
@ -201,6 +202,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
amount: amountUSD,
|
||||
currency: 'USD'
|
||||
};
|
||||
|
||||
ongoingProcess.set('Preparing transaction...', true);
|
||||
$timeout(function() {
|
||||
|
||||
|
|
@ -240,6 +242,62 @@ 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: 'livenet',
|
||||
})[0].id;
|
||||
} catch(err) {
|
||||
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) {
|
||||
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 {
|
||||
var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount;
|
||||
if ($scope.customAmount) {
|
||||
|
|
|
|||
|
|
@ -1,224 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyAmazonController',
|
||||
function($scope, $log, $timeout, $state, lodash, profileService, bwcError, gettextCatalog, configService, walletService, amazonService, ongoingProcess, platformInfo, externalLinkService, popupService) {
|
||||
|
||||
var self = this;
|
||||
var network = amazonService.getEnvironment();
|
||||
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, optIn, title, message, okText, cancelText) {
|
||||
externalLinkService.open(url, optIn, title, message, okText, cancelText);
|
||||
};
|
||||
|
||||
this.confirm = function() {
|
||||
var message = gettextCatalog.getString('Amazon.com Gift Card purchase for ${{amount}} USD', {
|
||||
amount: $scope.formData.fiat
|
||||
});
|
||||
var ok = gettextCatalog.getString('Buy');
|
||||
popupService.showConfirm(null, message, ok, null, function(res) {
|
||||
if (res) self.createTx();
|
||||
});
|
||||
};
|
||||
|
||||
this.createTx = function() {
|
||||
self.errorInfo = null;
|
||||
|
||||
if (lodash.isEmpty(wallet)) return;
|
||||
|
||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||
$log.info('No signing proposal: No private key');
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg('MISSING_PRIVATE_KEY'));
|
||||
return;
|
||||
}
|
||||
|
||||
var dataSrc = {
|
||||
currency: 'USD',
|
||||
amount: $scope.formData.fiat,
|
||||
uuid: wallet.id
|
||||
};
|
||||
var outputs = [];
|
||||
var config = configService.getSync();
|
||||
var configWallet = config.wallet;
|
||||
var walletSettings = configWallet.settings;
|
||||
|
||||
|
||||
ongoingProcess.set('Processing Transaction...', true);
|
||||
$timeout(function() {
|
||||
amazonService.createBitPayInvoice(dataSrc, function(err, dataInvoice) {
|
||||
if (err) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
amazonService.getBitPayInvoice(dataInvoice.invoiceId, function(err, invoice) {
|
||||
if (err) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
|
||||
$log.debug('Fetch PayPro Request...', invoice.paymentUrls.BIP73);
|
||||
|
||||
wallet.fetchPayPro({
|
||||
payProUrl: invoice.paymentUrls.BIP73,
|
||||
}, function(err, paypro) {
|
||||
|
||||
if (err) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
$log.warn('Could not fetch payment request:', err);
|
||||
var msg = err.toString();
|
||||
if (msg.match('HTTP')) {
|
||||
msg = gettextCatalog.getString('Could not fetch payment information');
|
||||
}
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!paypro.verified) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
$log.warn('Failed to verify payment protocol signatures');
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Payment Protocol Invalid'));
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var address, comment, amount, url;
|
||||
|
||||
address = paypro.toAddress;
|
||||
amount = paypro.amount;
|
||||
url = paypro.url;
|
||||
comment = 'Amazon.com Gift Card';
|
||||
|
||||
outputs.push({
|
||||
'toAddress': address,
|
||||
'amount': amount,
|
||||
'message': comment
|
||||
});
|
||||
|
||||
var txp = {
|
||||
toAddress: address,
|
||||
amount: amount,
|
||||
outputs: outputs,
|
||||
message: comment,
|
||||
payProUrl: url,
|
||||
excludeUnconfirmedUtxos: configWallet.spendUnconfirmed ? false : true,
|
||||
feeLevel: walletSettings.feeLevel || 'normal'
|
||||
};
|
||||
|
||||
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
return;
|
||||
}
|
||||
walletService.publishAndSign(wallet, createdTxp, function(err, tx) {
|
||||
if (err) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
walletService.removeTx(wallet, tx, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
return;
|
||||
}
|
||||
var count = 0;
|
||||
ongoingProcess.set('Processing Transaction...', true);
|
||||
|
||||
dataSrc.accessKey = dataInvoice.accessKey;
|
||||
dataSrc.invoiceId = invoice.id;
|
||||
dataSrc.invoiceUrl = invoice.url;
|
||||
dataSrc.invoiceTime = invoice.invoiceTime;
|
||||
|
||||
self.debounceCreate(count, dataSrc);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}, 100);
|
||||
};
|
||||
|
||||
self.debounceCreate = lodash.throttle(function(count, dataSrc) {
|
||||
self.debounceCreateGiftCard(count, dataSrc);
|
||||
}, 8000, {
|
||||
'leading': true
|
||||
});
|
||||
|
||||
self.debounceCreateGiftCard = function(count, dataSrc) {
|
||||
|
||||
amazonService.createGiftCard(dataSrc, function(err, giftCard) {
|
||||
$log.debug("creating gift card " + count);
|
||||
if (err) {
|
||||
giftCard = {};
|
||||
giftCard.status = 'FAILURE';
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
self.errorInfo = dataSrc;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
}
|
||||
|
||||
if (giftCard.status == 'PENDING' && count < 3) {
|
||||
$log.debug("pending gift card not available yet");
|
||||
self.debounceCreate(count + 1, dataSrc, 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) {
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
amazonService.savePendingGiftCard(newData, null, function(err) {
|
||||
ongoingProcess.set('Processing Transaction...', false);
|
||||
$log.debug("Saving new gift card with status: " + newData.status);
|
||||
|
||||
self.giftCard = newData;
|
||||
if (newData.status == 'PENDING') $state.transitionTo('tabs.giftcards.amazon');
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.enter", function(event, data) {
|
||||
$scope.formData = {
|
||||
fiat: null
|
||||
};
|
||||
$scope.wallets = profileService.getWallets({
|
||||
network: network,
|
||||
onlyComplete: true
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -1,13 +1,25 @@
|
|||
'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, gettext, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService) {
|
||||
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, gettext, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, amazonService) {
|
||||
var cachedTxp = {};
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
var countDown = null;
|
||||
var giftCardAmountUSD;
|
||||
var giftCardAccessKey;
|
||||
var giftCardInvoiceTime;
|
||||
var giftCardUUID;
|
||||
$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;
|
||||
|
||||
$scope.isWallet = data.stateParams.isWallet;
|
||||
$scope.cardId = data.stateParams.cardId;
|
||||
$scope.toAmount = data.stateParams.toAmount;
|
||||
|
|
@ -49,6 +61,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
var wallets = profileService.getWallets({
|
||||
onlyComplete: true,
|
||||
network: networkName,
|
||||
n: $scope.isGiftCard ? true : false
|
||||
});
|
||||
|
||||
if (!wallets || !wallets.length) {
|
||||
|
|
@ -373,6 +386,7 @@ 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;
|
||||
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableAnimate: true
|
||||
|
|
@ -386,6 +400,17 @@ 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 {
|
||||
$state.go('tabs.send');
|
||||
}
|
||||
|
|
@ -394,6 +419,71 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
function publishAndSign(wallet, txp, onSendStatusChange) {
|
||||
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
|
||||
};
|
||||
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) {
|
||||
$log.debug("Saving new gift card with status: " + newData.status);
|
||||
$scope.amazonGiftCard = newData;
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -965,16 +965,36 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
controller: 'amazonController',
|
||||
templateUrl: 'views/amazon.html'
|
||||
}
|
||||
},
|
||||
params: {
|
||||
cardClaimCode: null
|
||||
}
|
||||
})
|
||||
.state('tabs.giftcards.amazon.buy', {
|
||||
url: '/buy',
|
||||
.state('tabs.giftcards.amazon.amount', {
|
||||
url: '/amount',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'buyAmazonController',
|
||||
controllerAs: 'buy',
|
||||
templateUrl: 'views/buyAmazon.html'
|
||||
controller: 'amountController',
|
||||
templateUrl: 'views/amount.html'
|
||||
}
|
||||
},
|
||||
params: {
|
||||
isGiftCard: true,
|
||||
toName: 'Amazon.com Gift Card'
|
||||
}
|
||||
})
|
||||
.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
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
};
|
||||
|
||||
root.bitAuthPair = function(obj, cb) {
|
||||
var deviceName = 'Unknow device';
|
||||
var deviceName = 'Unknown device';
|
||||
if (platformInfo.isNW) {
|
||||
deviceName = require('os').platform();
|
||||
} else if (platformInfo.isCordova) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@
|
|||
.icon-bitpay-card {
|
||||
background-image: url("../img/icon-bitpay.svg");
|
||||
}
|
||||
.icon-amazon {
|
||||
background-image: url("../img/icon-amazon.svg");
|
||||
}
|
||||
@media(max-width: 480px) {
|
||||
.bitcoin-address {
|
||||
.icon {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
#view-confirm {
|
||||
@extend .deflash-blue;
|
||||
.icon-amazon {
|
||||
background-image: url("../img/icon-amazon.svg");
|
||||
}
|
||||
.tx-details-content > .scroll {
|
||||
padding-bottom: .25rem;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
<div ng-if="!giftCards" class="m20t padding text-center">
|
||||
|
||||
<button class="button button-standard button-primary" ui-sref="tabs.giftcards.amazon.buy">
|
||||
<button class="button button-standard button-primary" ui-sref="tabs.giftcards.amazon.amount">
|
||||
Buy now
|
||||
</button>
|
||||
|
||||
|
|
@ -30,7 +30,8 @@
|
|||
|
||||
<div class="m20t" ng-if="giftCards">
|
||||
<div class="list">
|
||||
<a class="item item-icon-left item-icon-right" href ui-sref="tabs.giftcards.amazon.buy">
|
||||
<a class="item item-icon-left item-icon-right" href
|
||||
ui-sref="tabs.giftcards.amazon.amount">
|
||||
<i class="icon ion-bag"></i>
|
||||
Buy Gift Card
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
|
|
|
|||
|
|
@ -16,20 +16,28 @@
|
|||
<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">
|
||||
<span ng-if="!isWallet && !isGiftCard">
|
||||
<gravatar ng-if="!cardId" class="send-gravatar" name="{{toName}}" width="30" email="{{toEmail}}"></gravatar>
|
||||
<i ng-if="cardId" class="icon big-icon-svg">
|
||||
<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>
|
||||
|
||||
<div ng-class="{'amount-pane-send': !customAmount, 'amount-pane-receive': customAmount}">
|
||||
|
||||
<div class="amount-bar">
|
||||
<div class="title" translate>Amount</div>
|
||||
<div class="amount-bar oh">
|
||||
<div class="title">
|
||||
<span translate>Amount</span>
|
||||
<span ng-show="isGiftCard" class="size-12">(Purchase Amount is limited to USD 500 per day)</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="amount">
|
||||
|
|
|
|||
|
|
@ -1,154 +0,0 @@
|
|||
<ion-view>
|
||||
<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>
|
||||
|
||||
<div ng-show="!buy.giftCard">
|
||||
|
||||
<div class="box-notification error" ng-show="buy.errorInfo" ng-click="buy.errorInfo = null">
|
||||
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
|
||||
<div>
|
||||
Amount: {{buy.errorInfo.amount}} {{buy.errorInfo.currency}}<br>
|
||||
BitPay Invoice ID: {{buy.errorInfo.invoiceId}}.
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<a ng-click="openExternalLink(buy.errorInfo.invoiceUrl)">Open invoice</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="padding text-center">
|
||||
<img src="img/a_generic.jpg" alt="Amazon.com Gift Card" width="180">
|
||||
<div class="text-center size-12 m10t">
|
||||
Use your Amazon.com Gift Card* to shop from a huge selection of books, electronics, music, movies, software, apparel, toys, and more.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form class="m20t"
|
||||
name="buyAmazonForm"
|
||||
ng-submit="buy.confirm()"
|
||||
novalidate>
|
||||
|
||||
<div class="list card">
|
||||
<label class="item item-input item-stacked-label">
|
||||
<span class="input-label">Amount</span>
|
||||
<input type="number"
|
||||
id="fiat"
|
||||
name="fiat"
|
||||
ng-attr-placeholder="{{'Amount in USD'}}"
|
||||
min="0.01"
|
||||
max="500"
|
||||
ng-model="formData.fiat"
|
||||
ng-pattern="/^[0-9]+(\.[0-9]{1,2})?$/"
|
||||
step="0.01"
|
||||
autocomplete="off" ignore-mouse-wheel required>
|
||||
<a class="postfix">USD</a>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<wallets ng-if="wallets[0]" wallets="wallets"></wallets>
|
||||
|
||||
<div class="padding">
|
||||
<button class="button button-standard button-primary"
|
||||
ng-disabled="!formData.fiat"
|
||||
type="submit">
|
||||
Buy now
|
||||
</button>
|
||||
<div class="size-10 text-gray text-center">
|
||||
Purchase Amount is limited to USD 500 per day
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="m10t" ng-show="buy.giftCard">
|
||||
<div class="m10h" ng-show="buy.giftCard.status != 'SUCCESS' && buy.giftCard.status != 'PENDING'">
|
||||
<h1 class="text-center">Gift card could not be created</h1>
|
||||
<div class="box-notification error">
|
||||
There was an error when trying to create the Amazon.com Gift Card. Status: {{buy.giftCard.status}}
|
||||
</div>
|
||||
<div class="text-gray size-12 m20t">
|
||||
<span ng-show="buy.giftCard.status == 'RESEND'">
|
||||
This is a temporary/recoverable system failure that can be
|
||||
resolved retrying the request from your list of cards
|
||||
</span>
|
||||
<span ng-show="buy.giftCard.status == 'FAILURE'">
|
||||
This failure could not be recoverable. Request your refund from your list of cards
|
||||
</span>
|
||||
<button class="button button-standard button-primary" ng-click="$root.go('amazon')">
|
||||
Back
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div ng-show="buy.giftCard.status == 'SUCCESS'">
|
||||
<div class="size-12 p15h">
|
||||
Thank you for participating in the BitPay offer. It is our pleasure to send
|
||||
you this Amazon.com Gift Card* that can be redeemed towards millions of items at
|
||||
<a ng-click="openExternalLink('https://www.amazon.com')">www.amazon.com</a>.
|
||||
You may want to print this screen for easy reference later you will need the gift card claim code below.
|
||||
</div>
|
||||
|
||||
<div class="oh m20t p15 white size-12 text-center">
|
||||
<img class="m10h" src="img/a_generic.jpg" alt="Amazon.com Gift Cards" width="200">
|
||||
<div class="m10t size-14">
|
||||
Gift Card Amount:
|
||||
<span class="text-bold">
|
||||
{{buy.giftCard.amount | currency : '$ ' : 2 }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="size-14">
|
||||
Claim code: <span class="text-bold" copy-to-clipboard="buy.giftCard.claimCode">{{buy.giftCard.claimCode}}</span>
|
||||
</div>
|
||||
<div class="m10t">
|
||||
<button class="button button-primary"
|
||||
ng-click="openExternalLink('https://www.amazon.com/gc/redeem?claimCode=' + buy.giftCard.claimCode)">
|
||||
Redeem Now
|
||||
</button>
|
||||
</div>
|
||||
<div class="m10t text-center">
|
||||
<a class="button button-clear button-calm" ng-click="openExternalLink(buy.giftCard.invoiceUrl)">See invoice</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh m20t p15h size-12">
|
||||
To redeem your gift card, follow these steps:
|
||||
|
||||
<ol class="m10t size-12">
|
||||
<li>1. Visit <a ng-click="openExternalLink('https://www.amazon.com/gc')">www.amazon.com/gc</a>
|
||||
<li>2. Click Apply to Account and enter the Claim Code when prompted.
|
||||
<li>3. Gift card funds will be applied automatically to eligible orders during the checkout process.
|
||||
<li>4. You must pay for any remaining balance on your order with another payment method.
|
||||
</ol>
|
||||
|
||||
<p class="size-12">
|
||||
Your gift card claim code may also be entered when prompted during checkout. To redeem your gift card using
|
||||
the Amazon.com 1-Click® service, first add the gift card funds to Your Account.
|
||||
</p>
|
||||
|
||||
<p class="size-12">
|
||||
If you have questions about redeeming your gift card, please visit
|
||||
<a ng-click="openExternalLink('https://www.amazon.com/gc-redeem')">www.amazon.com/gc-redeem</a>.
|
||||
If you have questions regarding the BitPay Introductory offer, please contact BitPay.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="size-12 white p15 m20t">
|
||||
* <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>
|
||||
|
|
@ -28,8 +28,11 @@
|
|||
<div class="item">
|
||||
<span class="label" translate>To</span>
|
||||
<span class="payment-proposal-to">
|
||||
<img ng-if="!cardId" src="img/icon-bitcoin-small.svg">
|
||||
<img ng-if="!cardId && !isGiftCard" src="img/icon-bitcoin-small.svg">
|
||||
<img ng-if="cardId" src="img/icon-card.svg" width="34">
|
||||
<i ng-if="isGiftCard" class="icon big-icon-svg">
|
||||
<div class="bg icon-amazon"></div>
|
||||
</i>
|
||||
|
||||
<div copy-to-clipboard="toAddress" ng-if="!paypro" class="ellipsis">
|
||||
<contact ng-if="!toName" address="{{toAddress}}"></contact>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue