Merge pull request #6256 from cmgustavo/feat/top-up-invoice-01

Debit card: topup improvements
This commit is contained in:
Gabriel Edgardo Bazán 2017-06-22 09:51:53 -03:00 committed by GitHub
commit 2f2c905a0e
6 changed files with 398 additions and 162 deletions

View file

@ -53,6 +53,7 @@ msgid "Accepted"
msgstr ""
#: www/views/preferencesInformation.html:66
#: www/views/topup.html:52
msgid "Account"
msgstr ""
@ -192,7 +193,7 @@ msgstr ""
msgid "Amount too big"
msgstr ""
#: src/js/controllers/tab-home.js:143
#: src/js/controllers/tab-home.js:141
msgid "An update to this app is available. For your security, please update to the latest version."
msgstr ""
@ -366,7 +367,7 @@ msgstr ""
msgid "Buy & Sell Bitcoin"
msgstr ""
#: www/views/tab-send.html:31
#: www/views/tab-send.html:35
msgid "Buy Bitcoin"
msgstr ""
@ -379,6 +380,7 @@ msgid "Calculating fee"
msgstr ""
#: src/js/controllers/confirm.js:498
#: src/js/controllers/topup.js:142
#: src/js/services/popupService.js:59
#: www/views/addressbook.add.html:10
#: www/views/feedback/send.html:5
@ -400,6 +402,10 @@ msgstr ""
msgid "Cannot join the same wallet more that once"
msgstr ""
#: www/views/topup.html:46
msgid "Card"
msgstr ""
#: www/views/includes/bitpayCardsCard.html:4
msgid "Cards"
msgstr ""
@ -463,6 +469,7 @@ msgstr ""
#: src/js/controllers/confirm.js:497
#: src/js/controllers/copayers.js:55
#: src/js/controllers/topup.js:197
#: www/views/backup.html:53
#: www/views/backup.html:72
#: www/views/confirm.html:4
@ -516,10 +523,11 @@ msgstr ""
msgid "Connection reset by peer"
msgstr ""
#: www/views/tab-send.html:41
#: www/views/tab-send.html:45
msgid "Contacts"
msgstr ""
#: src/js/controllers/topup.js:141
#: www/views/onboarding/notifications.html:9
msgid "Continue"
msgstr ""
@ -587,6 +595,14 @@ msgstr ""
msgid "Could not create address"
msgstr ""
#: src/js/controllers/topup.js:59
msgid "Could not create the invoice"
msgstr ""
#: src/js/controllers/topup.js:186
msgid "Could not create transaction"
msgstr ""
#: src/js/services/profileService.js:342
msgid "Could not create using the specified extended private key"
msgstr ""
@ -599,7 +615,7 @@ msgstr ""
msgid "Could not create: Invalid wallet recovery phrase"
msgstr ""
#: src/js/controllers/import.js:83
#: src/js/controllers/import.js:99
msgid "Could not decrypt file, check your password"
msgstr ""
@ -615,13 +631,17 @@ msgstr ""
msgid "Could not get dynamic fee for level: {{feeLevel}}"
msgstr ""
#: src/js/controllers/topup.js:66
msgid "Could not get the invoice"
msgstr ""
#: src/js/controllers/bitpayCard.js:69
msgid "Could not get transactions"
msgstr ""
#: src/js/services/profileService.js:595
#: src/js/services/profileService.js:627
#: src/js/services/profileService.js:650
#: src/js/services/profileService.js:629
#: src/js/services/profileService.js:652
msgid "Could not import"
msgstr ""
@ -654,6 +674,10 @@ msgstr ""
msgid "Could not send payment"
msgstr ""
#: src/js/controllers/topup.js:210
msgid "Could not send transaction"
msgstr ""
#: www/views/walletDetails.html:197
msgid "Could not update transaction history"
msgstr ""
@ -679,7 +703,7 @@ msgstr ""
#: www/views/onboarding/tour.html:51
#: www/views/tab-home.html:76
#: www/views/tab-send.html:32
#: www/views/tab-send.html:36
msgid "Create bitcoin wallet"
msgstr ""
@ -704,6 +728,10 @@ msgstr ""
msgid "Creating Wallet..."
msgstr ""
#: src/js/services/onGoingProcess.js:49
msgid "Creating invoice..."
msgstr ""
#: src/js/services/onGoingProcess.js:17
msgid "Creating transaction"
msgstr ""
@ -747,6 +775,10 @@ msgstr ""
msgid "Deleting payment proposal"
msgstr ""
#: www/views/topup.html:42
msgid "Deposit into"
msgstr ""
#: www/views/join.html:138
#: www/views/tab-create-personal.html:109
#: www/views/tab-create-shared.html:138
@ -880,24 +912,24 @@ msgstr ""
#: src/js/controllers/export.js:47
#: src/js/controllers/export.js:53
#: src/js/controllers/feedback/send.js:23
#: src/js/controllers/import.js:100
#: src/js/controllers/import.js:118
#: src/js/controllers/import.js:168
#: src/js/controllers/import.js:196
#: src/js/controllers/import.js:205
#: src/js/controllers/import.js:220
#: src/js/controllers/import.js:232
#: src/js/controllers/import.js:243
#: src/js/controllers/import.js:253
#: src/js/controllers/import.js:266
#: src/js/controllers/import.js:278
#: src/js/controllers/import.js:288
#: src/js/controllers/import.js:298
#: src/js/controllers/import.js:322
#: src/js/controllers/import.js:334
#: src/js/controllers/import.js:54
#: src/js/controllers/import.js:67
#: src/js/controllers/import.js:88
#: src/js/controllers/import.js:104
#: src/js/controllers/import.js:116
#: src/js/controllers/import.js:134
#: src/js/controllers/import.js:185
#: src/js/controllers/import.js:213
#: src/js/controllers/import.js:222
#: src/js/controllers/import.js:237
#: src/js/controllers/import.js:249
#: src/js/controllers/import.js:260
#: src/js/controllers/import.js:270
#: src/js/controllers/import.js:294
#: src/js/controllers/import.js:307
#: src/js/controllers/import.js:317
#: src/js/controllers/import.js:327
#: src/js/controllers/import.js:351
#: src/js/controllers/import.js:364
#: src/js/controllers/import.js:70
#: src/js/controllers/import.js:83
#: src/js/controllers/join.js:120
#: src/js/controllers/join.js:134
#: src/js/controllers/join.js:141
@ -911,8 +943,10 @@ msgstr ""
#: src/js/controllers/preferencesBitpayServices.js:50
#: src/js/controllers/preferencesDelete.js:37
#: src/js/controllers/preferencesExternal.js:20
#: src/js/controllers/tab-home.js:170
#: src/js/controllers/tab-home.js:168
#: src/js/controllers/tabsController.js:7
#: src/js/controllers/topup.js:11
#: src/js/controllers/topup.js:21
#: src/js/controllers/tx-details.js:106
#: src/js/services/incomingData.js:98
msgid "Error"
@ -926,6 +960,14 @@ msgstr ""
msgid "Error creating wallet"
msgstr ""
#: src/js/controllers/topup.js:159
msgid "Error fetching invoice"
msgstr ""
#: src/js/controllers/topup.js:152
msgid "Error in Payment Protocol"
msgstr ""
#: src/js/controllers/bitpayCardIntro.js:14
msgid "Error pairing BitPay Account"
msgstr ""
@ -946,6 +988,10 @@ msgstr ""
msgid "Exceeded daily limit of $500 per user"
msgstr ""
#: www/views/topup.html:62
msgid "Expire in"
msgstr ""
#: src/js/controllers/confirm.js:342
#: www/views/confirm.html:27
#: www/views/modals/txp-details.html:120
@ -997,6 +1043,7 @@ msgid "Family vacation funds"
msgstr ""
#: www/views/modals/txp-details.html:101
#: www/views/topup.html:69
#: www/views/tx-details.html:81
msgid "Fee"
msgstr ""
@ -1039,6 +1086,7 @@ msgstr ""
#: www/views/confirm.html:65
#: www/views/modals/txp-details.html:74
#: www/views/topup.html:32
#: www/views/tx-details.html:52
msgid "From"
msgstr ""
@ -1047,6 +1095,10 @@ msgstr ""
msgid "From BitPay account"
msgstr ""
#: www/views/tab-import-phrase.html:54
msgid "From Hardware Wallet"
msgstr ""
#: www/views/tab-export-qrCode.html:5
msgid "From the destination device, go to Add wallet > Import wallet and scan this QR code"
msgstr ""
@ -1063,6 +1115,10 @@ msgstr ""
msgid "Funds transferred"
msgstr ""
#: www/views/topup.html:113
msgid "Funds were added to debit card"
msgstr ""
#: www/views/paperWallet.html:22
msgid "Funds will be transferred to"
msgstr ""
@ -1100,12 +1156,12 @@ msgstr ""
msgid "Getting fee levels..."
msgstr ""
#: src/js/controllers/bitpayCard.js:171
#: src/js/controllers/bitpayCard.js:181
#: src/js/controllers/bitpayCard.js:179
#: src/js/controllers/bitpayCard.js:189
#: src/js/controllers/onboarding/terms.js:23
#: src/js/controllers/preferencesAbout.js:16
#: src/js/controllers/preferencesLanguage.js:14
#: src/js/controllers/tab-home.js:145
#: src/js/controllers/tab-home.js:143
#: src/js/controllers/tab-settings.js:48
#: src/js/controllers/tx-details.js:169
msgid "Go Back"
@ -1140,7 +1196,7 @@ msgstr ""
msgid "Help & Support"
msgstr ""
#: src/js/controllers/bitpayCard.js:169
#: src/js/controllers/bitpayCard.js:177
#: src/js/controllers/tab-settings.js:46
msgid "Help and support information is available at the website."
msgstr ""
@ -1249,7 +1305,7 @@ msgid "If you take a screenshot, your backup may be viewed by other apps. You ca
msgstr ""
#: www/views/tab-import-hardware.html:42
#: www/views/tab-import-phrase.html:63
#: www/views/tab-import-phrase.html:77
msgid "Import"
msgstr ""
@ -1293,10 +1349,11 @@ msgid "Incorrect address network"
msgstr ""
#. Trying to import a malformed wallet export QR code
#: src/js/controllers/import.js:54
#: src/js/controllers/import.js:70
msgid "Incorrect code format"
msgstr ""
#: src/js/controllers/topup.js:115
#: src/js/services/bwcError.js:44
#: www/views/confirm.html:99
msgid "Insufficient funds"
@ -1310,8 +1367,12 @@ msgstr ""
msgid "Invalid"
msgstr ""
#: src/js/controllers/topup.js:152
msgid "Invalid URL"
msgstr ""
#: src/js/controllers/create.js:175
#: src/js/controllers/import.js:298
#: src/js/controllers/import.js:327
#: src/js/controllers/join.js:141
msgid "Invalid account number"
msgstr ""
@ -1325,7 +1386,7 @@ msgid "Invalid data"
msgstr ""
#: src/js/controllers/create.js:155
#: src/js/controllers/import.js:232
#: src/js/controllers/import.js:249
#: src/js/controllers/join.js:120
msgid "Invalid derivation path"
msgstr ""
@ -1334,6 +1395,14 @@ msgstr ""
msgid "Invitation to share a {{appName}} Wallet"
msgstr ""
#: www/views/topup.html:58
msgid "Invoice"
msgstr ""
#: src/js/controllers/topup.js:257
msgid "Invoice Expired"
msgstr ""
#: src/js/controllers/feedback/send.js:79
msgid "Is there anything we could do better?"
msgstr ""
@ -1544,6 +1613,10 @@ msgstr ""
msgid "No backup, no bitcoin."
msgstr ""
#: src/js/controllers/topup.js:94
msgid "No card selected"
msgstr ""
#: www/views/addressbook.html:19
msgid "No contacts yet"
msgstr ""
@ -1564,6 +1637,10 @@ msgstr ""
msgid "No recent transactions"
msgstr ""
#: src/js/controllers/topup.js:30
msgid "No signing proposal: No private key"
msgstr ""
#: www/views/walletDetails.html:191
msgid "No transactions yet"
msgstr ""
@ -1662,7 +1739,7 @@ msgstr ""
msgid "On this screen you can see all your wallets, accounts, and assets."
msgstr ""
#: src/js/controllers/bitpayCard.js:170
#: src/js/controllers/bitpayCard.js:178
#: src/js/controllers/tab-settings.js:47
msgid "Open"
msgstr ""
@ -1679,7 +1756,7 @@ msgstr ""
msgid "Open GitHub Project"
msgstr ""
#: src/js/controllers/bitpayCard.js:180
#: src/js/controllers/bitpayCard.js:188
#: src/js/controllers/tx-details.js:168
msgid "Open Insight"
msgstr ""
@ -1715,7 +1792,7 @@ msgstr ""
msgid "Password"
msgstr ""
#: src/js/controllers/import.js:67
#: src/js/controllers/import.js:83
msgid "Password required. Make sure to enter your password in advanced options"
msgstr ""
@ -1795,10 +1872,6 @@ msgstr ""
msgid "Payment request"
msgstr ""
#: www/views/includes/cardActivity.html:41
msgid "Pending"
msgstr ""
#: www/views/proposals.html:5
msgid "Pending Proposals"
msgstr ""
@ -1819,7 +1892,7 @@ msgstr ""
msgid "Please connect a camera to get started."
msgstr ""
#: src/js/controllers/import.js:243
#: src/js/controllers/import.js:260
msgid "Please enter the recovery phrase"
msgstr ""
@ -1840,7 +1913,7 @@ msgstr ""
msgid "Please upgrade Copay to perform this action"
msgstr ""
#: src/js/controllers/import.js:205
#: src/js/controllers/import.js:222
msgid "Please, select your backup file"
msgstr ""
@ -1965,7 +2038,7 @@ msgid "Recent Transactions"
msgstr ""
#: www/views/amount.html:18
#: www/views/tab-send.html:8
#: www/views/tab-send.html:9
msgid "Recipient"
msgstr ""
@ -2083,6 +2156,10 @@ msgstr ""
msgid "Scan addresses for funds"
msgstr ""
#: www/views/modals/fingerprintCheck.html:11
msgid "Scan again"
msgstr ""
#: src/js/services/fingerprintService.js:56
msgid "Scan your fingerprint please"
msgstr ""
@ -2099,7 +2176,7 @@ msgstr ""
msgid "Search Transactions"
msgstr ""
#: www/views/tab-send.html:11
#: www/views/tab-send.html:13
msgid "Search or enter bitcoin address"
msgstr ""
@ -2196,8 +2273,13 @@ msgstr ""
msgid "Sending {{amountStr}} from your {{name}} wallet"
msgstr ""
#: src/js/controllers/topup.js:190
msgid "Sending {{amountStr}} from {{walletName}}"
msgstr ""
#: www/views/includes/walletHistory.html:37
#: www/views/modals/tx-status.html:9
#: www/views/topup.html:110
#: www/views/tx-details.html:17
msgid "Sent"
msgstr ""
@ -2267,11 +2349,11 @@ msgstr ""
msgid "Show advanced options"
msgstr ""
#: www/views/tab-send.html:33
#: www/views/tab-send.html:37
msgid "Show bitcoin address"
msgstr ""
#: www/views/tab-send.html:55
#: www/views/tab-send.html:59
msgid "Show more"
msgstr ""
@ -2319,7 +2401,7 @@ msgstr ""
msgid "Spending Password needed"
msgstr ""
#: www/views/tab-send.html:24
#: www/views/tab-send.html:28
msgid "Start sending bitcoin"
msgstr ""
@ -2331,6 +2413,10 @@ msgstr ""
msgid "Startup Lock"
msgstr ""
#: www/views/topup.html:111
msgid "Success"
msgstr ""
#: src/js/services/feeService.js:12
msgid "Super Economy"
msgstr ""
@ -2377,7 +2463,7 @@ msgid "Terms of Use"
msgstr ""
#: www/views/tab-create-personal.html:116
#: www/views/tab-import-phrase.html:58
#: www/views/tab-import-phrase.html:65
msgid "Testnet"
msgstr ""
@ -2483,9 +2569,9 @@ msgstr ""
msgid "There is a new version of {{appName}} available"
msgstr ""
#: src/js/controllers/import.js:196
#: src/js/controllers/import.js:220
#: src/js/controllers/import.js:288
#: src/js/controllers/import.js:213
#: src/js/controllers/import.js:237
#: src/js/controllers/import.js:317
msgid "There is an error in the form"
msgstr ""
@ -2506,6 +2592,10 @@ msgstr ""
msgid "This bitcoin payment request has expired."
msgstr ""
#: src/js/controllers/topup.js:257
msgid "This invoice has expired. An invoice is only valid for 15 minutes."
msgstr ""
#: www/views/join.html:130
#: www/views/tab-create-personal.html:101
#: www/views/tab-create-shared.html:130
@ -2539,15 +2629,24 @@ msgstr ""
msgid "To"
msgstr ""
#: www/views/tab-send.html:28
#: www/views/tab-send.html:32
msgid "To get started, buy bitcoin or share your address. You can receive bitcoin from any wallet or service."
msgstr ""
#: www/views/tab-send.html:29
#: www/views/tab-send.html:33
msgid "To get started, you'll need to create a bitcoin wallet and get some bitcoin."
msgstr ""
#: src/js/services/onGoingProcess.js:48
msgid "Top up in progress..."
msgstr ""
#: src/js/controllers/topup.js:137
msgid "Top up {{amountStr}} to debit card ({{cardLastNumber}})"
msgstr ""
#: www/views/modals/wallet-balance.html:23
#: www/views/topup.html:75
msgid "Total"
msgstr ""
@ -2581,12 +2680,16 @@ msgstr ""
msgid "Transaction created"
msgstr ""
#: www/views/topup.html:114
msgid "Transaction initiated"
msgstr ""
#: src/js/controllers/tx-details.js:106
msgid "Transaction not available at this time"
msgstr ""
#: src/js/controllers/activity.js:45
#: src/js/controllers/tab-home.js:170
#: src/js/controllers/tab-home.js:168
msgid "Transaction not found"
msgstr ""
@ -2594,7 +2697,7 @@ msgstr ""
msgid "Transfer to"
msgstr ""
#: www/views/tab-send.html:63
#: www/views/tab-send.html:67
msgid "Transfer to Wallet"
msgstr ""
@ -2634,7 +2737,7 @@ msgstr ""
msgid "Unused Addresses Limit"
msgstr ""
#: src/js/controllers/tab-home.js:142
#: src/js/controllers/tab-home.js:140
msgid "Update Available"
msgstr ""
@ -2662,6 +2765,10 @@ msgstr ""
msgid "Validating recovery phrase..."
msgstr ""
#: www/views/modals/fingerprintCheck.html:4
msgid "Verify your identity"
msgstr ""
#: www/views/preferencesAbout.html:14
#: www/views/preferencesExternal.html:25
msgid "Version"
@ -2679,12 +2786,12 @@ msgstr ""
msgid "View Terms of Service"
msgstr ""
#: src/js/controllers/bitpayCard.js:179
#: src/js/controllers/bitpayCard.js:187
#: src/js/controllers/tx-details.js:167
msgid "View Transaction on Insight"
msgstr ""
#: src/js/controllers/tab-home.js:144
#: src/js/controllers/tab-home.js:142
msgid "View Update"
msgstr ""
@ -2783,7 +2890,7 @@ msgid "Wallet Recovery Phrase is invalid"
msgstr ""
#: www/views/preferencesAdvanced.html:25
#: www/views/tab-import-phrase.html:53
#: www/views/tab-import-phrase.html:70
msgid "Wallet Service URL"
msgstr ""
@ -2792,6 +2899,7 @@ msgid "Wallet Settings"
msgstr ""
#: www/views/tab-import-hardware.html:11
#: www/views/tab-import-phrase.html:58
msgid "Wallet Type"
msgstr ""
@ -2841,7 +2949,7 @@ msgstr ""
msgid "Wallet not found"
msgstr ""
#: src/js/controllers/tab-home.js:216
#: src/js/controllers/tab-home.js:214
msgid "Wallet not registered"
msgstr ""
@ -2926,7 +3034,7 @@ msgstr ""
msgid "Would you like to receive push notifications about payments?"
msgstr ""
#: src/js/controllers/import.js:253
#: src/js/controllers/import.js:270
msgid "Wrong number of recovery words:"
msgstr ""
@ -3067,6 +3175,7 @@ msgid "{{appName}} depends on Bitcore Wallet Service (BWS) for blockchain inform
msgstr ""
#: src/js/controllers/confirm.js:211
#: src/js/controllers/topup.js:194
msgid "{{fee}} will be deducted for bitcoin networking fees."
msgstr ""

View file

@ -1,24 +1,14 @@
'use strict';
angular.module('copayApp.controllers').controller('topUpController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicConfig, lodash, popupService, profileService, ongoingProcess, walletService, configService, platformInfo, bitpayService, bitpayCardService, payproService, bwcError, txFormatService, sendMaxService) {
angular.module('copayApp.controllers').controller('topUpController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicConfig, lodash, popupService, profileService, ongoingProcess, walletService, configService, platformInfo, bitpayService, bitpayCardService, payproService, bwcError, txFormatService, sendMaxService, gettextCatalog) {
var amount;
var currency;
var dataSrc = {};
var cardId;
var sendMax;
$scope.isCordova = platformInfo.isCordova;
$scope.$on("$ionicView.beforeLeave", function(event, data) {
$ionicConfig.views.swipeBackEnabled(true);
});
$scope.$on("$ionicView.enter", function(event, data) {
$ionicConfig.views.swipeBackEnabled(false);
});
var configWallet = configService.getSync().wallet;
var showErrorAndBack = function(title, msg) {
title = title || 'Error';
title = title || gettextCatalog.getString('Error');
$scope.sendStatus = '';
$log.error(msg);
msg = msg.errors ? msg.errors[0].message : msg;
@ -28,7 +18,7 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
};
var showError = function(title, msg) {
title = title || 'Error';
title = title || gettextCatalog.getString('Error');
$scope.sendStatus = '';
$log.error(msg);
msg = msg.errors ? msg.errors[0].message : msg;
@ -37,7 +27,7 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
var publishAndSign = function (wallet, txp, onSendStatusChange, cb) {
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
var err = 'No signing proposal: No private key';
var err = gettextCatalog.getString('No signing proposal: No private key');
$log.info(err);
return cb(err);
}
@ -50,7 +40,7 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
var statusChangeHandler = function (processName, showName, isOn) {
$log.debug('statusChangeHandler: ', processName, showName, isOn);
if ( processName == 'topup' && !isOn) {
if ( processName == 'sendingTx' && !isOn) {
$scope.sendStatus = 'success';
$timeout(function() {
$scope.$digest();
@ -60,21 +50,57 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
}
};
var createInvoice = function() {
$scope.expirationTime = null;
ongoingProcess.set('creatingInvoice', true);
bitpayCardService.topUp(cardId, dataSrc, function(err, invoiceId) {
if (err) {
ongoingProcess.set('creatingInvoice', false);
showErrorAndBack(gettextCatalog.getString('Could not create the invoice'), err);
return;
}
bitpayCardService.getInvoice(invoiceId, function(err, inv) {
ongoingProcess.set('creatingInvoice', false);
if (err) {
showError(gettextCatalog.getString('Could not get the invoice'), err);
return;
}
$scope.invoice = inv;
$scope.expirationTime = ($scope.invoice.expirationTime - $scope.invoice.invoiceTime) / 1000;
$timeout(function() {
$scope.$digest();
}, 1);
});
});
};
$scope.$on("$ionicView.beforeLeave", function(event, data) {
$ionicConfig.views.swipeBackEnabled(true);
});
$scope.$on("$ionicView.enter", function(event, data) {
$ionicConfig.views.swipeBackEnabled(false);
});
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.wallet = null;
$scope.isCordova = platformInfo.isCordova;
cardId = data.stateParams.id;
sendMax = data.stateParams.useSendMax;
if (!cardId) {
showErrorAndBack(null, 'No card selected');
showErrorAndBack(null, gettextCatalog.getString('No card selected'));
return;
}
var parsedAmount = txFormatService.parseAmount(
data.stateParams.amount,
data.stateParams.amount,
data.stateParams.currency);
amount = parsedAmount.amount;
currency = parsedAmount.currency;
dataSrc['amount'] = parsedAmount.amount;
dataSrc['currency'] = parsedAmount.currency;
$scope.amountUnitStr = parsedAmount.amountUnitStr;
$scope.network = bitpayService.getEnvironment().network;
@ -86,7 +112,7 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
});
if (lodash.isEmpty($scope.wallets)) {
showErrorAndBack(null, 'Insufficient funds');
showErrorAndBack(null, gettextCatalog.getString('Insufficient funds'));
return;
}
$scope.onWalletSelect($scope.wallets[0]); // Default first wallet
@ -107,90 +133,88 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
});
$scope.topUpConfirm = function() {
var config = configService.getSync();
var configWallet = config.wallet;
var walletSettings = configWallet.settings;
var message = 'Add ' + amount + ' ' + currency + ' to debit card';
var okText = 'Confirm';
var cancelText = 'Cancel';
popupService.showConfirm(null, message, okText, cancelText, function(ok) {
var title;
var message = gettextCatalog.getString("Top up {{amountStr}} to debit card ({{cardLastNumber}})", {
amountStr: $scope.amountUnitStr,
cardLastNumber: $scope.cardInfo.lastFourDigits
});
var okText = gettextCatalog.getString('Continue');
var cancelText = gettextCatalog.getString('Cancel');
popupService.showConfirm(title, message, okText, cancelText, function(ok) {
if (!ok) return;
var dataSrc = {
amount: amount,
currency: currency
};
ongoingProcess.set('topup', true, statusChangeHandler);
bitpayCardService.topUp(cardId, dataSrc, function(err, invoiceId) {
var payProUrl = ($scope.invoice && $scope.invoice.paymentUrls) ? $scope.invoice.paymentUrls.BIP73 : null;
if (!payProUrl) {
ongoingProcess.set('topup', false, statusChangeHandler);
showError(gettextCatalog.getString('Error in Payment Protocol'), gettextCatalog.getString('Invalid URL'));
return;
}
payproService.getPayProDetails(payProUrl, function(err, payProDetails) {
if (err) {
ongoingProcess.set('topup', false, statusChangeHandler);
showErrorAndBack('Could not create the invoice', err);
showError(gettextCatalog.getString('Error fetching invoice'), err);
return;
}
bitpayCardService.getInvoice(invoiceId, function(err, invoice) {
var outputs = [];
var toAddress = payProDetails.toAddress;
var amountSat = payProDetails.amount;
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($scope.wallet, txp, function(err, ctxp) {
if (err) {
ongoingProcess.set('topup', false, statusChangeHandler);
showError('Could not get the invoice', err);
showError(gettextCatalog.getString('Could not create transaction'), bwcError.msg(err));
return;
}
var payProUrl = (invoice && invoice.paymentUrls) ? invoice.paymentUrls.BIP73 : null;
if (!payProUrl) {
title = gettextCatalog.getString('Sending {{amountStr}} from {{walletName}}', {
amountStr: txFormatService.formatAmountStr(ctxp.amount, true),
walletName: $scope.wallet.name
});
message = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees.", {
fee: txFormatService.formatAmountStr(ctxp.fee)
});
okText = gettextCatalog.getString('Confirm');
popupService.showConfirm(title, message, okText, cancelText, function(ok) {
ongoingProcess.set('topup', false, statusChangeHandler);
showError('Error in Payment Protocol', 'Invalid URL');
return;
}
payproService.getPayProDetails(payProUrl, function(err, payProDetails) {
if (err) {
ongoingProcess.set('topup', false, statusChangeHandler);
showError('Error fetching invoice', err);
if (!ok) {
$scope.sendStatus = '';
return;
}
var outputs = [];
var toAddress = payProDetails.toAddress;
var amountSat = payProDetails.amount;
var comment = 'Top up ' + amount + ' ' + currency + ' to Debit Card (' + $scope.cardInfo.lastFourDigits + ')';
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) {
$scope.expirationTime = null; // Disable countdown
ongoingProcess.set('sendingTx', true, statusChangeHandler);
publishAndSign($scope.wallet, ctxp, function() {}, function(err, txSent) {
ongoingProcess.set('sendingTx', false, statusChangeHandler);
if (err) {
ongoingProcess.set('topup', false, statusChangeHandler);
showError('Could not create transaction', bwcError.msg(err));
showError(gettextCatalog.getString('Could not send transaction'), err);
return;
}
publishAndSign($scope.wallet, ctxp, function() {}, function(err, txSent) {
ongoingProcess.set('topup', false, statusChangeHandler);
if (err) {
showError('Could not send transaction', err);
return;
}
});
});
}, true); // Disable loader
});
});
});
});
}, true); // Disable loader
});
};
$scope.showWalletSelector = function() {
@ -199,6 +223,7 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
};
$scope.onWalletSelect = function(wallet) {
if ($scope.wallet && (wallet.id == $scope.wallet.id)) return;
$scope.wallet = wallet;
if (sendMax) {
ongoingProcess.set('retrievingInputs', true);
@ -208,23 +233,30 @@ angular.module('copayApp.controllers').controller('topUpController', function($s
showErrorAndBack(null, err);
return;
}
var config = configService.getSync().wallet.settings;
var unitName = config.unitName;
var unitName = configWallet.settings.unitName;
var amountUnit = txFormatService.satToUnit(values.amount);
var parsedAmount = txFormatService.parseAmount(
amountUnit,
amountUnit,
unitName);
amount = parsedAmount.amount;
currency = parsedAmount.currency;
dataSrc['amount'] = parsedAmount.amount;
dataSrc['currency'] = parsedAmount.currency;
$scope.amountUnitStr = parsedAmount.amountUnitStr;
createInvoice();
$timeout(function() {
$scope.$digest();
}, 100);
});
} else {
createInvoice();
}
};
$scope.invoiceExpired = function() {
$scope.sendStatus = '';
showErrorAndBack(gettextCatalog.getString('Invoice Expired'), gettextCatalog.getString('This invoice has expired. An invoice is only valid for 15 minutes.'));
};
$scope.goBackHome = function() {
$scope.sendStatus = '';
$ionicHistory.nextViewOptions({

View file

@ -0,0 +1,67 @@
'use strict';
angular.module('copayApp.directives')
.directive('timer', function() {
return {
restrict: 'EAC',
replace: false,
scope: {
countdown: "=",
interval: "=",
active: "=",
onZeroCallback: "="
},
template:"{{formatted}}",
controller: function ($scope, $attrs, $timeout, lodash) {
$scope.format = $attrs.outputFormat;
var queueTick = function () {
$scope.timer = $timeout(function () {
if ($scope.countdown > 0) {
$scope.countdown -= 1;
if ($scope.countdown > 0) {
queueTick();
} else {
$scope.countdown = 0;
$scope.active = false;
if (!lodash.isUndefined($scope.onZeroCallback)) {
$scope.onZeroCallback();
}
}
}
}, $scope.interval);
};
if ($scope.active) {
queueTick();
}
$scope.$watch('active', function (newValue, oldValue) {
if (newValue !== oldValue) {
if (newValue === true) {
if ($scope.countdown > 0) {
queueTick();
} else {
$scope.active = false;
}
} else {
$timeout.cancel($scope.timer);
}
}
});
$scope.$watch('countdown', function () {
updateFormatted();
});
var updateFormatted = function () {
$scope.formatted = moment($scope.countdown * $scope.interval).format($scope.format);
};
updateFormatted();
$scope.$on('$destroy', function () {
$timeout.cancel($scope.timer);
});
}
};
});

View file

@ -45,7 +45,8 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
'cancelingGiftCard': 'Canceling Gift Card...',
'creatingGiftCard': 'Creating Gift Card...',
'buyingGiftCard': 'Buying Gift Card...',
'topup': 'Top up in progress...'
'topup': gettext('Top up in progress...'),
'creatingInvoice': gettext('Creating invoice...')
};
root.clear = function() {

View file

@ -101,6 +101,9 @@
color: $v-bitcoin-orange;
}
}
.total {
font-weight: bold;
}
}
.tx-icon {
margin-right: 25px;

View file

@ -19,7 +19,7 @@
<div class="amount-label">
<div class="amount-final">{{amountUnitStr}}</div>
<div class="alternative">
<span ng-if="rate">@
<span ng-if="rate">@
{{rate | currency:cardInfo.currencySymbol:2}} per BTC</span>
<span ng-if="!rate">...</span>
</div>
@ -29,7 +29,7 @@
<div class="info">
<div class="item item-icon-right" ng-click="showWalletSelector()">
<div class="label">From</div>
<div class="label" translate>From</div>
<div class="wallet">
<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">
@ -39,21 +39,45 @@
<i class="icon bp-arrow-right"></i>
</div>
<div class="item item-divider">
<div class="item item-divider" translate>
Deposit into
</div>
<div class="item">
Card
<span translate>Card</span>
<span class="item-note">
xxxx-xxxx-xxxx-{{cardInfo.lastFourDigits}}
</span>
</div>
<div class="item">
Account
<span translate>Account</span>
<span class="item-note">
{{cardInfo.email}}
</span>
</div>
<div class="item item-divider" translate>
Invoice
</div>
<div class="item">
<span translate>Expire in</span>
<span class="item-note" ng-if="expirationTime">
<timer countdown="expirationTime" interval="1000" active="true" output-format="mm:ss"
on-zero-callback="invoiceExpired">{{formatted}}</timer>
</span>
</div>
<div class="item">
<span translate>Fee</span>
<span class="item-note">
{{invoice.buyerPaidBtcMinerFee}}
</span>
</div>
<div class="item">
<span translate>Total</span>
<span class="item-note total">
{{invoice.buyerTotalBtcAmount}}
</span>
</div>
<div class="item item-divider"></div>
</div>
</div>
@ -83,11 +107,11 @@
slide-success-show="sendStatus === 'success'"
slide-success-on-confirm="goBackHome()"
slide-success-hide-on-confirm="true">
<span ng-if="wallet.credentials.m == 1">Sent</span>
<span ng-if="wallet.credentials.m > 1">Success</span>
<span ng-if="wallet.credentials.m == 1" translate>Sent</span>
<span ng-if="wallet.credentials.m > 1" translate>Success</span>
<div class="m10 size-14">
<span ng-if="wallet.credentials.m == 1">Funds were added to debit card</span>
<span ng-if="wallet.credentials.m > 1">Transaction initiated</span>
<span ng-if="wallet.credentials.m == 1" translate>Funds were added to debit card</span>
<span ng-if="wallet.credentials.m > 1" translate>Transaction initiated</span>
</div>
</slide-to-accept-success>