amazon cancel gift card feature

This commit is contained in:
Gabriel Bazán 2016-08-03 10:05:20 -03:00 committed by Gustavo Maximiliano Cortez
parent 54fa81e975
commit de6107206e
No known key found for this signature in database
GPG Key ID: 15EDAD8D9F2EB1AF
3 changed files with 32 additions and 0 deletions

View File

@ -81,6 +81,9 @@
</div>
<ul class="no-bullet size-14 m30v text-center">
<li class="line-b p10 oh pointer" ng-show="card.status == 'SUCCESS' && card.cardStatus == 'Fulfilled'" ng-click="cancelGiftCard()">
<span class="text-warning">Cancel gift card</span>
</li>
<li class="line-b p10 oh pointer" ng-show="card.status == 'FAILURE' || card.cardStatus == 'RefundedToPurchaser'
|| card.cardStatus == 'Expired'" ng-click="remove()">
<span class="text-warning">Remove gift card</span>

View File

@ -2,6 +2,18 @@
angular.module('copayApp.controllers').controller('amazonCardDetailsController', function($scope, $log, $timeout, bwcError, amazonService, lodash, ongoingProcess) {
$scope.cancelGiftCard = function() {
ongoingProcess.set('Canceling gift card...', true);
amazonService.cancelGiftCard($scope.card, function(err, data) {
ongoingProcess.set('Canceling gift card...', false);
if (err) {
$scope.error = bwcError.msg(err);
return;
}
$scope.$emit('UpdateAmazonList');
});
};
$scope.remove = function() {
amazonService.savePendingGiftCard($scope.card, {
remove: true

View File

@ -114,6 +114,23 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
});
};
root.cancelGiftCard = function(data, cb) {
var dataSrc = {
"clientId": data.uuid,
"invoiceId": data.invoiceId,
"accessKey": data.accessKey
};
$http(_postBitPay('/amazon-gift/cancel', dataSrc)).then(function(data) {
$log.info('Amazon.com Gift Card Cancel: SUCCESS');
return cb(null, data.data);
}, function(data) {
$log.error('Amazon.com Gift Card Cancel: ' + data.data.message);
return cb(data.data);
});
};
return root;
});