diff --git a/public/views/buyGlidera.html b/public/views/buyGlidera.html index 76b21b9d5..91276a18a 100644 --- a/public/views/buyGlidera.html +++ b/public/views/buyGlidera.html @@ -1,52 +1,69 @@
+ ng-init="titleSection='Buy Bitcoin'; goBackToState = 'glidera'">
-
+
-
- -

Buy Bitcoin

- -
- - - - - -
- -

Buy Price

-
    -
  • qty: {{buy.buyPrice.qty}} -
  • price: {{buy.buyPrice.price}} -
  • subtotal: {{buy.buyPrice.subtotal}} -
  • fees: {{buy.buyPrice.fees}} -
  • total: {{buy.buyPrice.total}} -
  • currency: {{buy.buyPrice.currency}} -
  • expires: {{buy.buyPrice.expires}} -
  • priceUuid: {{buy.buyPrice.priceUuid}} -
- -
- destinationAddress: {{buy.addr[index.walletId]}}
+
+
+
+ +
+ + + + + BTC + USD + +
+
+
+ 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 total of {{buy.buyPrice.qty}} BTC will be purchased and deposited in your bitcoin wallet ({{index.walletName}}) in 2-4 business days. +

+

+

+ + + +
+
+
{{buy.error}}
+
+

Purchase complete

+

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

-

Send 2FA Code

- - -

Buy

-
- - -
- + +
-
+
diff --git a/public/views/glidera.html b/public/views/glidera.html index f1c7bc764..549803a51 100644 --- a/public/views/glidera.html +++ b/public/views/glidera.html @@ -99,7 +99,7 @@
Completed - Pending + Processing Error
diff --git a/public/views/modals/glidera-tx-details.html b/public/views/modals/glidera-tx-details.html index 02135444a..ca7396496 100644 --- a/public/views/modals/glidera-tx-details.html +++ b/public/views/modals/glidera-tx-details.html @@ -20,9 +20,9 @@
{{tx.subtotal}} {{tx.currency}}
-
+
Completed - Pending + Processing Error
@@ -38,22 +38,22 @@
  • Price: - {{tx.price}} + ${{tx.price}} {{tx.currency}}
  • Subtotal: - {{tx.subtotal}} + ${{tx.subtotal}} {{tx.currency}}
  • Fees: - {{tx.fees}} + ${{tx.fees}} {{tx.currency}}
  • Total: - {{tx.total}} + ${{tx.total}} {{tx.currency}}
  • diff --git a/src/js/controllers/buyGlidera.js b/src/js/controllers/buyGlidera.js index 931f36711..b362fb769 100644 --- a/src/js/controllers/buyGlidera.js +++ b/src/js/controllers/buyGlidera.js @@ -4,6 +4,9 @@ angular.module('copayApp.controllers').controller('buyGlideraController', function($scope, $timeout, profileService, addressService, glideraService) { this.addr = {}; + this.show2faCodeInput = null; + this.error = null; + this.success = null; this.setDestinationAddress = function() { var self = this; @@ -14,7 +17,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController', $timeout(function() { addressService.getAddress(fc.credentials.walletId, null, function(err, addr) { if (err) { - self.addrError = err; + return; } else { if (addr) self.addr[fc.credentials.walletId] = addr; } @@ -25,36 +28,51 @@ angular.module('copayApp.controllers').controller('buyGlideraController', this.getBuyPrice = function(token, price) { var self = this; - this.buyAmount = price.qty; + if (!price || (price && !price.qty && !price.fiat)) { + this.buyPrice = null; + return; + } glideraService.buyPrice(token, price, function(error, buyPrice) { self.buyPrice = buyPrice; - self.setDestinationAddress(); }); }; - this.get2faCode = function(token, cb) { + this.get2faCode = function(token) { var self = this; - glideraService.get2faCode(token, function(error, sent) { - self.show2faCodeInput = sent; + $timeout(function() { + glideraService.get2faCode(token, function(error, sent) { + self.show2faCodeInput = sent; + }); + }, 100); + }; + + this.sendRequest = function(token, twoFaCode) { + var fc = profileService.focusedClient; + if (!fc) return; + this.loading = true; + var self = this; + addressService.getAddress(fc.credentials.walletId, null, function(err, addr) { + if (addr) { + var data = { + destinationAddress: addr, + qty: self.buyPrice.qty, + priceUuid: self.buyPrice.priceUuid, + useCurrentPrice: false, + ip: null + }; +console.log('[sellGlidera.js:128]',token, twoFaCode, addr, data); //TODO + glideraService.buy(token, twoFaCode, data, function(error, data) { +console.log('[sellGlidera.js:116]', error, data); //TODO + self.loading = false; + if (error) { + self.error = error; + } + else { + self.success = data + } + }); + } }); }; - this.send = function(token, twoFaCode) { - var fc = profileService.focusedClient; - var self = this; - var data = { - destinationAddress: self.addr[fc.credentials.walletId], - qty: self.buyPrice.qty, - priceUuid: self.buyPrice.priceUuid, - useCurrentPrice: false, - ip: null - }; -console.log('[sellGlidera.js:128]',token, twoFaCode, data); //TODO - glideraService.buy(token, twoFaCode, data, function(error, data) { -console.log('[sellGlidera.js:116]',data); //TODO - - }); - - }; - }); diff --git a/src/js/services/glideraService.js b/src/js/services/glideraService.js index 478909423..26576417d 100644 --- a/src/js/services/glideraService.js +++ b/src/js/services/glideraService.js @@ -224,7 +224,7 @@ console.log('[glideraService.js:168]',data); //TODO }; $http(_post('/buy', token, twoFaCode, data)).then(function(data) { $log.info('Glidera Buy: SUCCESS'); - return cb(null, data); + return cb(null, data.data); }, function(data) { $log.error('Glidera Buy: ERROR ' + data.statusText); return cb(data.statusText);