From e7de57f6302807bad1143f38fc583d60de24e7b3 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 29 Nov 2016 12:08:54 -0300 Subject: [PATCH] Removes unused files --- src/js/controllers/buyAmazon.js | 224 -------------------------------- www/views/buyAmazon.html | 154 ---------------------- 2 files changed, 378 deletions(-) delete mode 100644 src/js/controllers/buyAmazon.js delete mode 100644 www/views/buyAmazon.html diff --git a/src/js/controllers/buyAmazon.js b/src/js/controllers/buyAmazon.js deleted file mode 100644 index ca2aede91..000000000 --- a/src/js/controllers/buyAmazon.js +++ /dev/null @@ -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 - }); - }); - - }); diff --git a/www/views/buyAmazon.html b/www/views/buyAmazon.html deleted file mode 100644 index 69ac4b790..000000000 --- a/www/views/buyAmazon.html +++ /dev/null @@ -1,154 +0,0 @@ - - - - - Buy - - - - -
- -
- There was an error when trying to buy gift card, but the funds were sent to BitPay Invoice. Please, contact - BitPay to refund your bitcoin -
- Amount: {{buy.errorInfo.amount}} {{buy.errorInfo.currency}}
- BitPay Invoice ID: {{buy.errorInfo.invoiceId}}. -
- -
- -
- Amazon.com Gift Card -
- Use your Amazon.com Gift Card* to shop from a huge selection of books, electronics, music, movies, software, apparel, toys, and more. -
-
- -
- -
- -
- - - -
- -
- Purchase Amount is limited to USD 500 per day -
-
-
-
- -
-
-

Gift card could not be created

-
- There was an error when trying to create the Amazon.com Gift Card. Status: {{buy.giftCard.status}} -
-
- - This is a temporary/recoverable system failure that can be - resolved retrying the request from your list of cards - - - This failure could not be recoverable. Request your refund from your list of cards - - -
-
-
-
- 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 - www.amazon.com. - You may want to print this screen for easy reference later you will need the gift card claim code below. -
- -
- Amazon.com Gift Cards -
- Gift Card Amount: - - {{buy.giftCard.amount | currency : '$ ' : 2 }} - -
-
- Claim code: {{buy.giftCard.claimCode}} -
-
- -
- -
-
- To redeem your gift card, follow these steps: - -
    -
  1. 1. Visit www.amazon.com/gc -
  2. 2. Click Apply to Account and enter the Claim Code when prompted. -
  3. 3. Gift card funds will be applied automatically to eligible orders during the checkout process. -
  4. 4. You must pay for any remaining balance on your order with another payment method. -
- -

- 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. -

- -

- If you have questions about redeeming your gift card, please visit - www.amazon.com/gc-redeem. - If you have questions regarding the BitPay Introductory offer, please contact BitPay. -

- -
-
-
- -
- * Amazon.com is not a sponsor of this promotion. - Except as required by law, Amazon.com - Gift Cards ("GCs") cannot be transferred for value or redeemed for cash. GCs may be used only for purchases of - eligible goods at Amazon.com or certain of its - affiliated websites. For complete terms and conditions, see - www.amazon.com/gc-legal. - GCs are issued by ACI Gift Cards, Inc., a Washington corporation. All Amazon ®, ™ & © are IP - of Amazon.com, Inc. or its affiliates. - No expiration date or service fees. -
- -
-