diff --git a/public/views/buyGlidera.html b/public/views/buyGlidera.html index 91276a18a..cffc679b5 100644 --- a/public/views/buyGlidera.html +++ b/public/views/buyGlidera.html @@ -6,6 +6,20 @@
+ +
+
+
+
+
+
+
+
+
+ Sending request to Glidera... +
+
+
@@ -26,42 +40,49 @@ ng-click="showAlternative = true; qty = null; buy.buyPrice = null">BTC USD - + +
+ Buy + ${{buy.buyPrice.subtotal}} {{buy.buyPrice.currency}} in Bitcoin + {{buy.buyPrice.qty}} BTC + at ${{buy.buyPrice.price}} {{buy.buyPrice.currency}} +
+ +
- -
- Buy - ${{buy.buyPrice.subtotal}} {{buy.buyPrice.currency}} in Bitcoin - {{buy.buyPrice.qty}} BTC - at ${{buy.buyPrice.price}} {{buy.buyPrice.currency}} -
+
-

- The purchase price of ${{buy.buyPrice.price}} USD will be immediately withdrawn from your bank account. +

+ The purchase price of ${{buy.buyPrice.price}} {{buy.buyPrice.currency}} will be immediately withdrawn from your bank account.

-

+

The total of {{buy.buyPrice.qty}} BTC will be purchased and deposited in your bitcoin wallet ({{index.walletName}}) in 2-4 business days.

-

+ ng-submit="buy.sendRequest(index.glideraToken, index.glideraPermissions, twoFaCode)" novalidate> - +
-
{{buy.error}}
+
+ + {{buy.error|translate}} + +

Purchase complete

-

+

A transfer has been initiated from your bank account. Your bitcoin should arrive in your wallet in 4-6 business days.

+ ng-click="$root.go('glidera')"> + Finish +
diff --git a/public/views/glidera.html b/public/views/glidera.html index 732fa4400..822bdc503 100644 --- a/public/views/glidera.html +++ b/public/views/glidera.html @@ -79,7 +79,7 @@
{{index.glideraEmail}}
- {{index.glideraPersonalInfo.firstName}} {{index.glideraPersonalInfo.lastName}} {{index.glideraPersonalInfo.personalInfoState}} + {{index.glideraPersonalInfo.firstName}} {{index.glideraPersonalInfo.lastName}}
diff --git a/src/js/controllers/buyGlidera.js b/src/js/controllers/buyGlidera.js index b7813054b..481a8e047 100644 --- a/src/js/controllers/buyGlidera.js +++ b/src/js/controllers/buyGlidera.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('buyGlideraController', - function($scope, $timeout, profileService, addressService, glideraService) { + function($scope, $timeout, profileService, addressService, glideraService, gettext) { this.addr = {}; this.show2faCodeInput = null; @@ -14,27 +14,44 @@ angular.module('copayApp.controllers').controller('buyGlideraController', this.buyPrice = null; return; } - glideraService.buyPrice(token, price, function(error, buyPrice) { - self.buyPrice = buyPrice; + glideraService.buyPrice(token, price, function(err, buyPrice) { + if (err) { + self.error = gettext('Glidera could not get pricing to buy bitcoin'); + } + else { + self.buyPrice = buyPrice; + } }); }; this.get2faCode = function(token) { var self = this; + this.loading = true; $timeout(function() { - glideraService.get2faCode(token, function(error, sent) { - self.show2faCodeInput = sent; + glideraService.get2faCode(token, function(err, sent) { + self.loading = false; + if (err) { + self.error = gettext('Glidera could not the 2FA code to your phone'); + } + else { + self.show2faCodeInput = sent; + } }); }, 100); }; - this.sendRequest = function(token, twoFaCode) { + this.sendRequest = function(token, permissions, twoFaCode) { var fc = profileService.focusedClient; if (!fc) return; - this.loading = true; var self = this; + self.error = null; addressService.getAddress(fc.credentials.walletId, null, function(err, addr) { - if (addr) { + if (!addr) { + self.error = gettext('Could not get the bitcoin address'); + $scope.$apply(); + } + else { + self.loading = true; var data = { destinationAddress: addr, qty: self.buyPrice.qty, @@ -42,15 +59,18 @@ angular.module('copayApp.controllers').controller('buyGlideraController', useCurrentPrice: false, ip: null }; - glideraService.buy(token, twoFaCode, data, function(error, data) { - self.loading = false; - if (error) { - self.error = error; - } - else { - self.success = data - } - }); + $timeout(function() { + glideraService.buy(token, twoFaCode, data, function(err, data) { + self.loading = false; + if (err) { + self.error = gettext('Could not buy bitcoin'); + } + else { + self.success = data; + $scope.$emit('Local/GlideraUpdated', token, permissions); + } + }); + }, 100); } }); };