Bitpay card config external json
This commit is contained in:
parent
63916402a3
commit
222fbe57ff
7 changed files with 73 additions and 8 deletions
|
|
@ -1,24 +1,29 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('bitpayCardService', function($http, $log, lodash, storageService, bitauthService, platformInfo) {
|
||||
angular.module('copayApp.services').factory('bitpayCardService', function($http, $log, $window, lodash, storageService, bitauthService, platformInfo) {
|
||||
var root = {};
|
||||
var credentials = {};
|
||||
var bpSession = {};
|
||||
var pubkey, sin;
|
||||
|
||||
var _setCredentials = function() {
|
||||
if (!$window.externalServices || !$window.externalServices.bitpayCard) {
|
||||
return;
|
||||
}
|
||||
|
||||
var bitpayCard = $window.externalServices.bitpayCard;
|
||||
/*
|
||||
* Development: 'testnet'
|
||||
* Production: 'livenet'
|
||||
*/
|
||||
credentials.NETWORK = 'livenet';
|
||||
if (credentials.NETWORK == 'testnet') {
|
||||
credentials.BITPAY_PRIV_KEY = '';
|
||||
credentials.BITPAY_API_URL = 'https://test.bitpay.com';
|
||||
credentials.BITPAY_PRIV_KEY = bitpayCard.sandbox.secret;
|
||||
credentials.BITPAY_API_URL = bitpayCard.sandbox.host;
|
||||
}
|
||||
else {
|
||||
credentials.BITPAY_PRIV_KEY = '';
|
||||
credentials.BITPAY_API_URL = 'https://bitpay.com';
|
||||
credentials.BITPAY_PRIV_KEY = bitpayCard.production.secret;
|
||||
credentials.BITPAY_API_URL = bitpayCard.production.host;
|
||||
}
|
||||
try {
|
||||
pubkey = bitauthService.getPublicKeyFromPrivateKey(credentials.BITPAY_PRIV_KEY);
|
||||
|
|
@ -87,6 +92,12 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
return credentials.BITPAY_API_URL;
|
||||
};
|
||||
|
||||
root.testSession = function(cb) {
|
||||
_getSession(function(err, session) {
|
||||
return cb(err, session);
|
||||
});
|
||||
};
|
||||
|
||||
var _postBitAuth = function(endpoint, data) {
|
||||
var dataToSign = credentials.BITPAY_API_URL + endpoint + JSON.stringify(data);
|
||||
var signedData = bitauthService.sign(dataToSign, credentials.BITPAY_PRIV_KEY);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue