mirror of https://github.com/BTCPrivate/copay.git
paypro: stop using global $http.
This commit is contained in:
parent
d51c1c552f
commit
052e2522be
|
@ -25,10 +25,6 @@ var TxProposals = require('./TxProposals');
|
|||
var PrivateKey = require('./PrivateKey');
|
||||
var copayConfig = require('../../../config');
|
||||
|
||||
var G = typeof window !== 'undefined'
|
||||
? window
|
||||
: global;
|
||||
|
||||
function Wallet(opts) {
|
||||
var self = this;
|
||||
|
||||
|
@ -804,7 +800,7 @@ Wallet.prototype.createPaymentTx = function(options, cb) {
|
|||
return;
|
||||
}
|
||||
|
||||
return $http({
|
||||
return Wallet.request({
|
||||
method: options.method || 'POST',
|
||||
url: options.uri,
|
||||
headers: {
|
||||
|
@ -1041,7 +1037,7 @@ Wallet.prototype.sendPaymentTx = function(ntxid, options, cb) {
|
|||
view[i] = pay[i];
|
||||
}
|
||||
|
||||
return $http({
|
||||
return Wallet.request({
|
||||
method: 'POST',
|
||||
url: txp.merchant.pr.pd.payment_url,
|
||||
headers: {
|
||||
|
@ -1719,10 +1715,10 @@ Wallet.prototype.verifySignedJson = function(senderId, payload, signature) {
|
|||
// deviates from BIP-70.
|
||||
|
||||
// if (typeof angular !== 'undefined') {
|
||||
// G.$http = G.$http || angular.bootstrap().get('$http');
|
||||
// var $http = angular.bootstrap().get('$http');
|
||||
// }
|
||||
|
||||
G.$http = G.$http || function $http(options, callback) {
|
||||
Wallet.request = function(options, callback) {
|
||||
if (typeof options === 'string') {
|
||||
options = { uri: options };
|
||||
}
|
||||
|
|
|
@ -4,9 +4,7 @@ var is_browser = typeof process == 'undefined'
|
|||
|| typeof process.versions === 'undefined';
|
||||
var bitcore = bitcore || require('bitcore');
|
||||
var PayPro = bitcore.PayPro;
|
||||
|
||||
var G = is_browser ? window : global;
|
||||
G.SSL_UNTRUSTED = true;
|
||||
var Wallet = require('../../js/models/core/Wallet');
|
||||
|
||||
var x509 = {
|
||||
priv: ''
|
||||
|
@ -93,17 +91,14 @@ x509.der = new Buffer(x509.der, 'base64');
|
|||
x509.pem = new Buffer(x509.pem, 'base64');
|
||||
|
||||
function startServer(cb) {
|
||||
if (G.$http && G.$http.__server) {
|
||||
if (Wallet.request._server) {
|
||||
setTimeout(function() {
|
||||
return cb(null, G.$http.__server);
|
||||
return cb(null, Wallet.request._server);
|
||||
}, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
var old;
|
||||
if (G.$http) {
|
||||
old = G.$http;
|
||||
}
|
||||
var old = Wallet.request;
|
||||
|
||||
var server = {
|
||||
POST: {
|
||||
|
@ -283,12 +278,12 @@ function startServer(cb) {
|
|||
if (cb) return cb();
|
||||
},
|
||||
close: function(cb) {
|
||||
if (old) G.$http = old;
|
||||
Wallet.request = old;
|
||||
return cb();
|
||||
}
|
||||
};
|
||||
|
||||
G.$http = function(options) {
|
||||
Wallet.request = function(options) {
|
||||
var ret = {
|
||||
success: function(cb) {
|
||||
this._success = cb;
|
||||
|
@ -332,7 +327,7 @@ function startServer(cb) {
|
|||
return ret;
|
||||
};
|
||||
|
||||
G.$http.__server = server;
|
||||
Wallet.request._server = server;
|
||||
|
||||
setTimeout(function() {
|
||||
return cb(null, server);
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
var chai = chai || require('chai');
|
||||
var should = chai.should();
|
||||
var sinon = require('sinon');
|
||||
var is_browser = (typeof process == 'undefined' || typeof process.versions === 'undefined');
|
||||
var is_browser = typeof process == 'undefined'
|
||||
|| typeof process.versions === 'undefined';
|
||||
if (is_browser) {
|
||||
var copay = require('copay'); //browser
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue