Ionic modals. Fix select wallet to buy/sell
This commit is contained in:
parent
cd87d9628d
commit
2b60bc3066
6 changed files with 243 additions and 298 deletions
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
<div
|
||||
ng-init="buy.init()"
|
||||
ng-click="openWalletsModal(buy.otherWallets)">
|
||||
ng-click="openWalletsModal(buy.allWallets)">
|
||||
<label>Pay From Copay Wallet</label>
|
||||
<div class="input">
|
||||
<input type="text" id="address" name="address" ng-disabled="buy.selectedWalletId"
|
||||
|
|
@ -73,7 +73,7 @@
|
|||
|
||||
<div class="input m20t">
|
||||
<input class="button black round expand"
|
||||
ng-disabled="buy.loading || !fiat"
|
||||
ng-disabled="!buy.selectedWalletId || buy.loading || !fiat"
|
||||
type="submit" value="Buy now">
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -111,13 +111,13 @@
|
|||
|
||||
<div class="oh m20t size-12 text-center">
|
||||
<img class="m10h" src="img/a_generic.jpg" alt="Amazon.com Gift Cards" width="230">
|
||||
<div class="m10t">
|
||||
<div class="m10t size-14">
|
||||
Gift Card Amount:
|
||||
<span class="text-bold">
|
||||
{{buy.giftCard.cardInfo.value.amount | currency : '$ ' : 2 }}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<div class="size-14">
|
||||
Claim code: <span class="text-bold enable_text_select">{{buy.giftCard.gcClaimCode}}</span>
|
||||
</div>
|
||||
<div class="m10t">
|
||||
|
|
|
|||
|
|
@ -32,9 +32,8 @@
|
|||
</li>
|
||||
<li menu-toggle href ui-sref="amazon" ng-show="index.isComplete && index.amazonEnabled">
|
||||
<i class="icon-arrow-right3 size-18 right m10t vm"></i>
|
||||
<i class="fi-shopping-cart size-24 icon vm"></i>
|
||||
<i class="fi-shopping-bag size-24 icon vm"></i>
|
||||
<div class="tu text-bold m5t">
|
||||
<div class="tu text-bold m10t">
|
||||
<span class="size-12" translate>Gift Cards</span>
|
||||
</div>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -1,154 +1,157 @@
|
|||
<nav class="tab-bar">
|
||||
<section class="left-small">
|
||||
<a ng-click="cancel()">
|
||||
<i class="icon-arrow-left3 icon-back"></i>
|
||||
<span class="text-back">Back</span>
|
||||
</a>
|
||||
</section>
|
||||
<section class="middle tab-bar-section">
|
||||
<h1 class="title ellipsis">
|
||||
Details
|
||||
</h1>
|
||||
</section>
|
||||
</nav>
|
||||
<ion-modal-view ng-controller="amazonCardDetailsController">
|
||||
<nav class="tab-bar">
|
||||
<section class="left-small">
|
||||
<a ng-click="cancel()">
|
||||
<i class="icon-arrow-left3 icon-back"></i>
|
||||
<span class="text-back">Back</span>
|
||||
</a>
|
||||
</section>
|
||||
<section class="middle tab-bar-section">
|
||||
<h1 class="title ellipsis">
|
||||
Details
|
||||
</h1>
|
||||
</section>
|
||||
</nav>
|
||||
|
||||
<div class="modal-content fix-modals-touch"
|
||||
ng-swipe-disable-mouse
|
||||
ng-swipe-right="cancel()">
|
||||
<div class="header-modal bg-gray text-center">
|
||||
<ion-content overflow-scroll="true">
|
||||
|
||||
<img src="img/a_generic.jpg" alt="Amazon.com Gift Card" width="230" ng-click="refreshGiftCard()">
|
||||
<div class="modal-content fix-modals-touch">
|
||||
<div class="header-modal bg-gray text-center">
|
||||
|
||||
<div ng-show="card.gcClaimCode">
|
||||
<div class="m10t">
|
||||
Gift Card Amount:
|
||||
<span class="text-bold">
|
||||
{{card.cardInfo.value.amount | currency : '$ ' : 2}}
|
||||
<img src="img/a_generic.jpg" alt="Amazon.com Gift Card" width="230" ng-click="refreshGiftCard()">
|
||||
|
||||
<div ng-show="card.gcClaimCode">
|
||||
<div class="m10t">
|
||||
Gift Card Amount:
|
||||
<span class="text-bold">
|
||||
{{card.cardInfo.value.amount | currency : '$ ' : 2}}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
Claim code: <span class="text-bold enable_text_select">{{card.gcClaimCode}}</span>
|
||||
</div>
|
||||
<div class="m10t">
|
||||
<button class="button black round tiny"
|
||||
ng-click="$root.openExternalLink('https://www.amazon.com/gc/redeem?claimCode=' + card.gcClaimCode)">
|
||||
Redeem Now
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="size-12 m10t text-center">
|
||||
| <a
|
||||
ng-click="$root.openExternalLink('https://www.amazon.com/gp/css/gc/payment/view-gc-balance?claimCode=' + card.gcClaimCode)">
|
||||
Apply to Account
|
||||
</a> |
|
||||
<a ng-click="$root.openExternalLink('http://www.amazon.com/gc-redeem')">How to Use</a> |
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box-notification m20b" ng-show="error" ng-click="error = null">
|
||||
<span class="text-warning">
|
||||
{{error}}
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
Claim code: <span class="text-bold enable_text_select">{{card.gcClaimCode}}</span>
|
||||
</div>
|
||||
<div class="m10t">
|
||||
<button class="button black round tiny"
|
||||
ng-click="$root.openExternalLink('https://www.amazon.com/gc/redeem?claimCode=' + card.gcClaimCode)">
|
||||
Redeem Now
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="text-center size-12" ng-show="card.status != 'SUCCESS' && !loading">
|
||||
<div ng-show="card.status == 'RESEND'">
|
||||
<div class="text-secondary m10h">
|
||||
There was a temporary/recoverable system failure that can be resolved by retrying the request
|
||||
</div>
|
||||
<button class="m10t button outline round dark-gray tiny" ng-click="refreshGiftCard()">
|
||||
Try again
|
||||
</button>
|
||||
</div>
|
||||
<div class="text-warning m10" ng-show="card.status == 'FAILURE'">
|
||||
There was a failure to the create gift card that could not be recoverable. Please, contact BitPay to refund your bitcoin
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="size-12 m10t text-center">
|
||||
| <a
|
||||
ng-click="$root.openExternalLink('https://www.amazon.com/gp/css/gc/payment/view-gc-balance?claimCode=' + card.gcClaimCode)">
|
||||
Apply to Account
|
||||
</a> |
|
||||
<a ng-click="$root.openExternalLink('http://www.amazon.com/gc-redeem')">How to Use</a> |
|
||||
<div class="m10t size-12 white line-t p10" ng-show="card.gcClaimCode">
|
||||
<div class="text-bold m10b">To redeem your gift card, follow these steps:</div>
|
||||
<ol class="size-12">
|
||||
<li>Visit <a ng-click="$root.openExternalLink('https://www.amazon.com/gc')">www.amazon.com/gc</a>.</li>
|
||||
<li>Click Apply to Account and enter the claim code when prompted.</li>
|
||||
<li>Gift card funds will be applied automatically to eligible orders during the checkout process.</li>
|
||||
<li>You must pay for any remaining balance on your order with another payment method.</li>
|
||||
</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="$root.openExternalLink('https://www.amazon.com/gc-redeem')">www.amazon.com/gc-redeem</a>.
|
||||
If you have questions regarding the BitPay offer, please contact BitPay.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box-notification m20b" ng-show="error" ng-click="error = null">
|
||||
<span class="text-warning">
|
||||
{{error}}
|
||||
</span>
|
||||
</div>
|
||||
<ul class="no-bullet size-14">
|
||||
<h4 class="title">Details</h4>
|
||||
<li class="line-b p10 oh">
|
||||
<span class="text-gray">Card status</span>
|
||||
<span class="text-success right" ng-if="card.cardInfo.cardStatus == 'Fulfilled'">Fulfilled</span>
|
||||
<span class="text-secondary right" ng-if="card.cardInfo.cardStatus == 'RefundedToPurchaser'">Refunded to purchaser</span>
|
||||
<span class="text-warning right" ng-if="card.cardInfo.cardStatus == 'Expired'">Expired</span>
|
||||
</li>
|
||||
<li class="line-b p10 oh">
|
||||
<span class="text-gray">Created at</span>
|
||||
<span class="test-gray right">{{card.date * 1000 | amDateFormat:'MM/DD/YYYY HH:mm a'}}</span>
|
||||
</li>
|
||||
<li class="line-b p10 oh">
|
||||
<span class="text-gray">Creation status</span>
|
||||
<span class="text-success right" ng-if="card.status == 'SUCCESS'">Success</span>
|
||||
<span class="text-secondary right" ng-if="card.status == 'RESEND'">Resend is required</span>
|
||||
<span class="text-warning right" ng-if="card.status == 'FAILURE'">Error</span>
|
||||
<span class="text-warning right" ng-if="card.status == 'REFUND'">Refunded</span>
|
||||
</li>
|
||||
<li class="line-b p10 oh pointer" ng-click="$root.openExternalLink(card.bitpayInvoiceUrl)">
|
||||
<i class="icon-arrow-right3 size-24 right text-gray"></i>
|
||||
<span class="text-gray">BitPay Invoice</span>
|
||||
<span class="text-gray right enable_text_select">{{card.bitpayInvoiceId}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="text-center size-12" ng-show="card.status != 'SUCCESS' && !loading">
|
||||
<div ng-show="card.status == 'RESEND'">
|
||||
<div class="text-secondary m10h">
|
||||
There was a temporary/recoverable system failure that can be resolved by retrying the request
|
||||
<div class="row m20t"
|
||||
ng-show="card.status == 'FAILURE' || card.cardInfo.cardStatus == 'RefundedToPurchaser' || card.cardInfo.cardStatus == 'Expired'">
|
||||
<div class="columns text-center">
|
||||
<p class="size-12 text-gray">
|
||||
This action will remove the gift card
|
||||
</p>
|
||||
<button class="button outline round dark-gray tiny"
|
||||
ng-click="remove();"
|
||||
ng-disabled="loading">
|
||||
<i class="fi-x"></i>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<button class="m10t button outline round dark-gray tiny" ng-click="refreshGiftCard()">
|
||||
Try again
|
||||
</button>
|
||||
|
||||
<div class="row m20t" ng-show="card.status == 'SUCCESS' && card.cardInfo.cardStatus == 'Fulfilled'">
|
||||
<div class="columns text-center">
|
||||
<p class="size-12 text-gray">
|
||||
This action will cancel the gift card
|
||||
</p>
|
||||
<button class="button outline round dark-gray tiny"
|
||||
ng-click="cancelGiftCard()"
|
||||
ng-disabled="loading">
|
||||
<i class="fi-x"></i>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="size-12 white p15 m20t">
|
||||
*Amazon.com Gift Cards ("GCs") sold by BitPay, Inc., an authorized and independent
|
||||
reseller of Amazon.com Gift Cards. Except as required by law, 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. Purchases are
|
||||
deducted from the GC balance. To redeem or view a GC balance, visit “Your Account” at Amazon.com. Amazon is
|
||||
not responsible if a GC is lost, stolen, destroyed or used without permission. See
|
||||
<a ng-click="$root.openExternalLink('https://www.amazon.com/gc-legal')">www.amazon.com/gc-legal</a> for complete terms,
|
||||
restrictions and exceptions. For any other questions, see
|
||||
<a ng-click="$root.openExternalLink('https://www.amazon.com/gc')">www.amazon.com/gc</a>. 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.
|
||||
</div>
|
||||
|
||||
<div class="extra-margin-bottom"></div>
|
||||
</div>
|
||||
<div class="text-warning m10" ng-show="card.status == 'FAILURE'">
|
||||
There was a failure to the create gift card that could not be recoverable. Please, contact BitPay to refund your bitcoin
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="m10t size-12 white line-t p10" ng-show="card.gcClaimCode">
|
||||
<div class="text-bold m10b">To redeem your gift card, follow these steps:</div>
|
||||
<ol class="size-12">
|
||||
<li>Visit <a ng-click="$root.openExternalLink('https://www.amazon.com/gc')">www.amazon.com/gc</a>.</li>
|
||||
<li>Click Apply to Account and enter the claim code when prompted.</li>
|
||||
<li>Gift card funds will be applied automatically to eligible orders during the checkout process.</li>
|
||||
<li>You must pay for any remaining balance on your order with another payment method.</li>
|
||||
</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="$root.openExternalLink('https://www.amazon.com/gc-redeem')">www.amazon.com/gc-redeem</a>.
|
||||
If you have questions regarding the BitPay offer, please contact BitPay.</p>
|
||||
</div>
|
||||
|
||||
<ul class="no-bullet size-14">
|
||||
<h4 class="title">Details</h4>
|
||||
<li class="line-b p10 oh">
|
||||
<span class="text-gray">Card status</span>
|
||||
<span class="text-success right" ng-if="card.cardInfo.cardStatus == 'Fulfilled'">Fulfilled</span>
|
||||
<span class="text-secondary right" ng-if="card.cardInfo.cardStatus == 'RefundedToPurchaser'">Refunded to purchaser</span>
|
||||
<span class="text-warning right" ng-if="card.cardInfo.cardStatus == 'Expired'">Expired</span>
|
||||
</li>
|
||||
<li class="line-b p10 oh">
|
||||
<span class="text-gray">Created at</span>
|
||||
<span class="test-gray right">{{card.date * 1000 | amDateFormat:'MM/DD/YYYY HH:mm a'}}</span>
|
||||
</li>
|
||||
<li class="line-b p10 oh">
|
||||
<span class="text-gray">Creation status</span>
|
||||
<span class="text-success right" ng-if="card.status == 'SUCCESS'">Success</span>
|
||||
<span class="text-secondary right" ng-if="card.status == 'RESEND'">Resend is required</span>
|
||||
<span class="text-warning right" ng-if="card.status == 'FAILURE'">Error</span>
|
||||
<span class="text-warning right" ng-if="card.status == 'REFUND'">Refunded</span>
|
||||
</li>
|
||||
<li class="line-b p10 oh pointer" ng-click="$root.openExternalLink(card.bitpayInvoiceUrl)">
|
||||
<i class="icon-arrow-right3 size-24 right text-gray"></i>
|
||||
<span class="text-gray">BitPay Invoice</span>
|
||||
<span class="text-gray right enable_text_select">{{card.bitpayInvoiceId}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="row m20t"
|
||||
ng-show="card.status == 'FAILURE' || card.cardInfo.cardStatus == 'RefundedToPurchaser' || card.cardInfo.cardStatus == 'Expired'">
|
||||
<div class="columns text-center">
|
||||
<p class="size-12 text-gray">
|
||||
This action will remove the gift card
|
||||
</p>
|
||||
<button class="button outline round dark-gray tiny"
|
||||
ng-click="remove();"
|
||||
ng-disabled="loading">
|
||||
<i class="fi-x"></i>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row m20t" ng-show="card.status == 'SUCCESS' && card.cardInfo.cardStatus == 'Fulfilled'">
|
||||
<div class="columns text-center">
|
||||
<p class="size-12 text-gray">
|
||||
This action will cancel the gift card
|
||||
</p>
|
||||
<button class="button outline round dark-gray tiny"
|
||||
ng-click="cancelGiftCard()"
|
||||
ng-disabled="loading">
|
||||
<i class="fi-x"></i>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="size-12 white p15 m20t">
|
||||
*Amazon.com Gift Cards ("GCs") sold by BitPay, Inc., an authorized and independent
|
||||
reseller of Amazon.com Gift Cards. Except as required by law, 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. Purchases are
|
||||
deducted from the GC balance. To redeem or view a GC balance, visit “Your Account” at Amazon.com. Amazon is
|
||||
not responsible if a GC is lost, stolen, destroyed or used without permission. See
|
||||
<a ng-click="$root.openExternalLink('https://www.amazon.com/gc-legal')">www.amazon.com/gc-legal</a> for complete terms,
|
||||
restrictions and exceptions. For any other questions, see
|
||||
<a ng-click="$root.openExternalLink('https://www.amazon.com/gc')">www.amazon.com/gc</a>. 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.
|
||||
</div>
|
||||
|
||||
<div class="extra-margin-bottom"></div>
|
||||
</div>
|
||||
</ion-content>
|
||||
</ion-modal-view>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amazonController',
|
||||
function($rootScope, $scope, $timeout, $modal, profileService, configService, amazonService, animationService, lodash) {
|
||||
|
||||
window.ignoreMobilePause = true;
|
||||
function($scope, $timeout, $ionicModal, configService, amazonService) {
|
||||
|
||||
this.init = function() {
|
||||
var self = this;
|
||||
|
|
@ -21,90 +19,15 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
this.openCardModal = function(card) {
|
||||
$rootScope.modalOpened = true;
|
||||
var self = this;
|
||||
var fc = profileService.focusedClient;
|
||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
$scope.card = card;
|
||||
$scope.card = card;
|
||||
|
||||
$scope.cancelGiftCard = function() {
|
||||
$scope.refresh = true;
|
||||
var dataSrc = {
|
||||
creationRequestId: $scope.card.creationRequestId,
|
||||
gcId: $scope.card.gcId,
|
||||
bitpayInvoiceId: $scope.card.bitpayInvoiceId,
|
||||
bitpayInvoiceUrl: $scope.card.bitpayInvoiceUrl,
|
||||
date: $scope.card.date
|
||||
};
|
||||
$scope.loading = true;
|
||||
amazonService.cancelGiftCard(dataSrc, function(err, data) {
|
||||
$scope.loading = null;
|
||||
if (err || data.status != 'SUCCESS') {
|
||||
$scope.error = err || data.status;
|
||||
return;
|
||||
}
|
||||
$scope.refreshGiftCard();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.remove = function() {
|
||||
amazonService.saveGiftCard($scope.card, {remove: true}, function(err) {
|
||||
$modalInstance.close(true);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.refreshGiftCard = function() {
|
||||
$scope.refresh = true;
|
||||
var dataSrc = {
|
||||
creationRequestId: $scope.card.creationRequestId,
|
||||
amount: $scope.card.cardInfo.value.amount,
|
||||
currencyCode: $scope.card.cardInfo.value.currencyCode,
|
||||
bitpayInvoiceId: $scope.card.bitpayInvoiceId,
|
||||
bitpayInvoiceUrl: $scope.card.bitpayInvoiceUrl,
|
||||
date: $scope.card.date
|
||||
};
|
||||
$scope.loading = true;
|
||||
amazonService.createGiftCard(dataSrc, function(err, data) {
|
||||
$scope.loading = null;
|
||||
if (err) {
|
||||
$scope.error = err;
|
||||
return;
|
||||
}
|
||||
$scope.card = data;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = lodash.debounce(function() {
|
||||
$modalInstance.close($scope.refresh);
|
||||
}, 0, 1000);
|
||||
|
||||
};
|
||||
|
||||
var modalInstance = $modal.open({
|
||||
templateUrl: 'views/modals/amazon-card-details.html',
|
||||
windowClass: animationService.modalAnimated.slideRight,
|
||||
controller: ModalInstanceCtrl,
|
||||
$ionicModal.fromTemplateUrl('views/modals/amazon-card-details.html', {
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
$scope.amazonCardDetailsModal = modal;
|
||||
$scope.amazonCardDetailsModal.show();
|
||||
});
|
||||
|
||||
var disableCloseModal = $rootScope.$on('closeModal', function() {
|
||||
modalInstance.close($scope.refresh);
|
||||
});
|
||||
|
||||
modalInstance.result.finally(function() {
|
||||
$rootScope.modalOpened = false;
|
||||
disableCloseModal();
|
||||
var m = angular.element(document.getElementsByClassName('reveal-modal'));
|
||||
m.addClass(animationService.modalAnimated.slideOutRight);
|
||||
});
|
||||
|
||||
modalInstance.result.then(function(refresh) {
|
||||
if (refresh) self.init();
|
||||
}, function() {});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,22 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('buyAmazonController',
|
||||
function($rootScope, $scope, $modal, $log, $timeout, lodash, profileService, animationService, bwsError, configService, walletService, fingerprintService, amazonService) {
|
||||
function($rootScope, $scope, $ionicModal, $log, $timeout, lodash, profileService, bwsError, configService, walletService, fingerprintService, amazonService) {
|
||||
|
||||
window.ignoreMobilePause = true;
|
||||
var self = this;
|
||||
var fc;
|
||||
var client;
|
||||
var minimumAmount = 5;
|
||||
var stepAmount = 1;
|
||||
var multiplierAmount = 5;
|
||||
var maximumAmount = 500;
|
||||
|
||||
var otherWallets = function(network) {
|
||||
return lodash.filter(profileService.getWallets(network), function(w) {
|
||||
return w.network == network && w.m == 1;
|
||||
});
|
||||
};
|
||||
|
||||
var handleEncryptedWallet = function(client, cb) {
|
||||
if (!walletService.isEncrypted(client)) return cb();
|
||||
$rootScope.$emit('Local/NeedsPassword', false, function(err, password) {
|
||||
|
|
@ -31,68 +24,38 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
amazonService.setCredentials(network);
|
||||
amazonService.healthCheckRequest();
|
||||
amazonService.initUuid();
|
||||
self.otherWallets = otherWallets(network);
|
||||
// Choose focused wallet
|
||||
try {
|
||||
var currentWalletId = profileService.focusedClient.credentials.walletId;
|
||||
lodash.find(self.otherWallets, function(w) {
|
||||
if (w.id == currentWalletId) {
|
||||
$timeout(function() {
|
||||
self.selectedWalletId = w.id;
|
||||
self.selectedWalletName = w.name;
|
||||
fc = profileService.getClient(w.id);
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
$log.debug(e);
|
||||
};
|
||||
self.allWallets = profileService.getWallets(network, 1);
|
||||
client = profileService.focusedClient;
|
||||
if (client && client.credentials.m == 1) {
|
||||
$timeout(function() {
|
||||
self.selectedWalletId = client.credentials.walletId;
|
||||
self.selectedWalletName = client.credentials.walletName;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.openWalletsModal = function(wallets) {
|
||||
if (self.loading) return;
|
||||
self.error = null;
|
||||
self.errorInfo = null;
|
||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
$scope.type = 'SELL';
|
||||
$scope.wallets = wallets;
|
||||
$scope.noColor = true;
|
||||
$scope.cancel = function() {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
|
||||
$scope.selectWallet = function(walletId, walletName) {
|
||||
if (!profileService.getClient(walletId).isComplete()) {
|
||||
self.error = bwsError.msg('WALLET_NOT_COMPLETE');
|
||||
$modalInstance.dismiss('cancel');
|
||||
return;
|
||||
}
|
||||
$modalInstance.close({
|
||||
'walletId': walletId,
|
||||
'walletName': walletName,
|
||||
});
|
||||
};
|
||||
};
|
||||
$scope.type = 'SELL';
|
||||
$scope.wallets = wallets;
|
||||
|
||||
var modalInstance = $modal.open({
|
||||
templateUrl: 'views/modals/wallets.html',
|
||||
windowClass: animationService.modalAnimated.slideUp,
|
||||
controller: ModalInstanceCtrl,
|
||||
$ionicModal.fromTemplateUrl('views/modals/wallets.html', {
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
$scope.walletsModal = modal;
|
||||
$scope.walletsModal.show();
|
||||
});
|
||||
|
||||
modalInstance.result.finally(function() {
|
||||
var m = angular.element(document.getElementsByClassName('reveal-modal'));
|
||||
m.addClass(animationService.modalAnimated.slideOutDown);
|
||||
});
|
||||
|
||||
modalInstance.result.then(function(obj) {
|
||||
$scope.$on('walletSelected', function(ev, obj) {
|
||||
$timeout(function() {
|
||||
self.selectedWalletId = obj.walletId;
|
||||
self.selectedWalletName = obj.walletName;
|
||||
fc = profileService.getClient(obj.walletId);
|
||||
client = obj.client;
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
$scope.walletsModal.hide();
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -156,7 +119,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
};
|
||||
|
||||
self.loading = 'Creating transaction...';
|
||||
walletService.createTx(fc, txp, function(err, createdTxp) {
|
||||
walletService.createTx(client, txp, function(err, createdTxp) {
|
||||
self.loading = null;
|
||||
if (err) {
|
||||
self.loading = null;
|
||||
|
|
@ -204,38 +167,38 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
|
||||
this.confirmTx = function(txp, cb) {
|
||||
|
||||
fingerprintService.check(fc, function(err) {
|
||||
fingerprintService.check(client, function(err) {
|
||||
if (err) {
|
||||
$log.debug(err);
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
handleEncryptedWallet(fc, function(err) {
|
||||
handleEncryptedWallet(client, function(err) {
|
||||
if (err) {
|
||||
$log.debug(err);
|
||||
return bwsError.cb(err, null, cb);
|
||||
}
|
||||
|
||||
walletService.publishTx(fc, txp, function(err, publishedTxp) {
|
||||
walletService.publishTx(client, txp, function(err, publishedTxp) {
|
||||
if (err) {
|
||||
$log.debug(err);
|
||||
return bwsError.cb(err, null, cb);
|
||||
}
|
||||
|
||||
walletService.signTx(fc, publishedTxp, function(err, signedTxp) {
|
||||
walletService.lock(fc);
|
||||
walletService.signTx(client, publishedTxp, function(err, signedTxp) {
|
||||
walletService.lock(client);
|
||||
if (err) {
|
||||
$log.debug(err);
|
||||
walletService.removeTx(fc, signedTxp, function(err) {
|
||||
walletService.removeTx(client, signedTxp, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
return bwsError.cb(err, null, cb);
|
||||
}
|
||||
|
||||
walletService.broadcastTx(fc, signedTxp, function(err, broadcastedTxp) {
|
||||
walletService.broadcastTx(client, signedTxp, function(err, broadcastedTxp) {
|
||||
if (err) {
|
||||
$log.debug(err);
|
||||
walletService.removeTx(fc, broadcastedTxp, function(err) {
|
||||
walletService.removeTx(client, broadcastedTxp, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
return bwsError.cb(err, null, cb);
|
||||
|
|
|
|||
57
src/js/controllers/modals/amazonCardDetails.js
Normal file
57
src/js/controllers/modals/amazonCardDetails.js
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $timeout, amazonService) {
|
||||
|
||||
$scope.cancelGiftCard = function() {
|
||||
var dataSrc = {
|
||||
creationRequestId: $scope.card.creationRequestId,
|
||||
gcId: $scope.card.gcId,
|
||||
bitpayInvoiceId: $scope.card.bitpayInvoiceId,
|
||||
bitpayInvoiceUrl: $scope.card.bitpayInvoiceUrl,
|
||||
date: $scope.card.date
|
||||
};
|
||||
$scope.loading = true;
|
||||
amazonService.cancelGiftCard(dataSrc, function(err, data) {
|
||||
$scope.loading = null;
|
||||
if (err || data.status != 'SUCCESS') {
|
||||
$scope.error = err || data.status;
|
||||
return;
|
||||
}
|
||||
$scope.refreshGiftCard();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.remove = function() {
|
||||
amazonService.saveGiftCard($scope.card, {remove: true}, function(err) {
|
||||
$scope.cancel();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.refreshGiftCard = function() {
|
||||
var dataSrc = {
|
||||
creationRequestId: $scope.card.creationRequestId,
|
||||
amount: $scope.card.cardInfo.value.amount,
|
||||
currencyCode: $scope.card.cardInfo.value.currencyCode,
|
||||
bitpayInvoiceId: $scope.card.bitpayInvoiceId,
|
||||
bitpayInvoiceUrl: $scope.card.bitpayInvoiceUrl,
|
||||
date: $scope.card.date
|
||||
};
|
||||
$scope.loading = true;
|
||||
amazonService.createGiftCard(dataSrc, function(err, data) {
|
||||
$scope.loading = null;
|
||||
if (err) {
|
||||
$scope.error = err;
|
||||
return;
|
||||
}
|
||||
$scope.card = data;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$scope.amazonCardDetailsModal.hide();
|
||||
};
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue