mirror of https://github.com/BTCPrivate/copay.git
amazon cancel gift card feature
This commit is contained in:
parent
54fa81e975
commit
de6107206e
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue