mirror of https://github.com/BTCPrivate/copay.git
changing random uuid for wallet id
This commit is contained in:
parent
c099816e71
commit
c474cca890
|
@ -17,7 +17,6 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
this.init = function() {
|
||||
var network = configService.getSync().amazon.testnet ? 'testnet' : 'livenet';
|
||||
amazonService.setCredentials(network);
|
||||
amazonService.initAmazonUUID(network);
|
||||
self.allWallets = profileService.getWallets(network, 1);
|
||||
client = profileService.focusedClient;
|
||||
if (client && client.credentials.m == 1 && client.credentials.network == network) {
|
||||
|
@ -62,7 +61,8 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
var currency_code = configService.getSync().amazon.testnet ? window.amazon_sandbox_currency_code : window.amazon_currency_code;
|
||||
var dataSrc = {
|
||||
currency: currency_code,
|
||||
amount: $scope.fiat
|
||||
amount: $scope.fiat,
|
||||
uuid: self.selectedWalletId
|
||||
};
|
||||
var outputs = [];
|
||||
var config = configService.getSync();
|
||||
|
@ -185,6 +185,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
|
|||
newData['invoiceUrl'] = dataSrc.invoiceUrl;
|
||||
newData['amount'] = dataSrc.amount;
|
||||
newData['date'] = dataSrc.invoiceTime || now;
|
||||
newData['uuid'] = dataSrc.uuid;
|
||||
|
||||
if (newData.status == 'expired') {
|
||||
amazonService.savePendingGiftCard(newData, {
|
||||
|
|
|
@ -13,27 +13,6 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
|
|||
};
|
||||
};
|
||||
|
||||
root.initAmazonUUID = function(network) {
|
||||
storageService.getAmazonUUID(network, function(err, uuid) {
|
||||
if (err) $log.error(err);
|
||||
if (uuid) return;
|
||||
var now = moment().unix();
|
||||
var random = Math.floor((Math.random() * 100) + 1);
|
||||
var generateUUID = now + random;
|
||||
storageService.setAmazonUUID(network, generateUUID, function(err) {
|
||||
if (err) $log.error(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var _getUUID = function(cb) {
|
||||
var network = configService.getSync().amazon.testnet ? 'testnet' : 'livenet';
|
||||
storageService.getAmazonUUID(network, function(err, uuid) {
|
||||
if (err) $log.error(err);
|
||||
return cb(uuid);
|
||||
});
|
||||
};
|
||||
|
||||
var _getBitPay = function(endpoint) {
|
||||
return {
|
||||
method: 'GET',
|
||||
|
@ -90,22 +69,19 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
|
|||
};
|
||||
|
||||
root.createBitPayInvoice = function(data, cb) {
|
||||
_getUUID(function(uuid) {
|
||||
if (lodash.isEmpty(uuid)) return cb('CAN_NOT_GET_UUID');
|
||||
|
||||
var dataSrc = {
|
||||
currency: data.currency,
|
||||
amount: data.amount,
|
||||
clientId: uuid
|
||||
};
|
||||
var dataSrc = {
|
||||
currency: data.currency,
|
||||
amount: data.amount,
|
||||
clientId: data.uuid
|
||||
};
|
||||
|
||||
$http(_postBitPay('/amazon-gift/pay', dataSrc)).then(function(data) {
|
||||
$log.info('BitPay Create Invoice: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('BitPay Create Invoice: ERROR ' + data.data.message);
|
||||
return cb(data.data);
|
||||
});
|
||||
$http(_postBitPay('/amazon-gift/pay', dataSrc)).then(function(data) {
|
||||
$log.info('BitPay Create Invoice: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('BitPay Create Invoice: ERROR ' + data.data.message);
|
||||
return cb(data.data);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -119,28 +95,25 @@ angular.module('copayApp.services').factory('amazonService', function($http, $lo
|
|||
});
|
||||
};
|
||||
|
||||
root.createGiftCard = function(dataInvoice, cb) {
|
||||
_getUUID(function(uuid) {
|
||||
if (lodash.isEmpty(uuid)) return cb('CAN_NOT_GET_UUID');
|
||||
root.createGiftCard = function(data, cb) {
|
||||
|
||||
var dataSrc = {
|
||||
"clientId": uuid,
|
||||
"invoiceId": dataInvoice.invoiceId,
|
||||
"accessKey": dataInvoice.accessKey
|
||||
};
|
||||
var dataSrc = {
|
||||
"clientId": data.uuid,
|
||||
"invoiceId": data.invoiceId,
|
||||
"accessKey": data.accessKey
|
||||
};
|
||||
|
||||
$http(_postBitPay('/amazon-gift/redeem', dataSrc)).then(function(data) {
|
||||
var status = data.data.status == ('new' || 'paid') ? 'PENDING' : data.data.status;
|
||||
data.data.status = status;
|
||||
data.data.clientId = uuid;
|
||||
$log.info('Amazon.com Gift Card Create/Update: ' + status);
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Amazon.com Gift Card Create/Update: ' + data.data.message);
|
||||
return cb(data.data);
|
||||
});
|
||||
$http(_postBitPay('/amazon-gift/redeem', dataSrc)).then(function(data) {
|
||||
var status = data.data.status == ('new' || 'paid') ? 'PENDING' : data.data.status;
|
||||
data.data.status = status;
|
||||
$log.info('Amazon.com Gift Card Create/Update: ' + status);
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Amazon.com Gift Card Create/Update: ' + data.data.message);
|
||||
return cb(data.data);
|
||||
});
|
||||
};
|
||||
|
||||
return root;
|
||||
|
||||
});
|
||||
|
|
|
@ -268,11 +268,11 @@ angular.module('copayApp.services')
|
|||
root.checkQuota = function() {
|
||||
var block = '';
|
||||
// 50MB
|
||||
for (var i = 0; i < 1024*1024; ++ i){
|
||||
for (var i = 0; i < 1024 * 1024; ++i) {
|
||||
block += '12345678901234567890123456789012345678901234567890';
|
||||
}
|
||||
storage.set('test', block, function(err) {
|
||||
$log.error('CheckQuota Return:'+ err);
|
||||
$log.error('CheckQuota Return:' + err);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -330,13 +330,5 @@ angular.module('copayApp.services')
|
|||
storage.remove('amazonGiftCards-' + network, cb);
|
||||
};
|
||||
|
||||
root.setAmazonUUID = function(network, uuid, cb) {
|
||||
storage.set('amazonUUID-' + network, uuid, cb);
|
||||
};
|
||||
|
||||
root.getAmazonUUID = function(network, cb) {
|
||||
storage.get('amazonUUID-' + network, cb);
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue