mirror of https://github.com/BTCPrivate/copay.git
paypro: misc work.
This commit is contained in:
parent
6e9eaf7d9d
commit
7b678a91b5
65
app.js
65
app.js
|
@ -14,73 +14,24 @@ app.start = function(port, callback) {
|
|||
|
||||
if (process.env.USE_HTTPS) {
|
||||
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var bc = path.dirname(require.resolve('bitcore/package.json'));
|
||||
var server = require('https').createServer({
|
||||
key: fs.readFileSync(bc + '/test/data/x509.key'),
|
||||
cert: fs.readFileSync(bc + '/test/data/x509.crt')
|
||||
});
|
||||
// var fs = require('fs');
|
||||
// var server = require('https').createServer({
|
||||
// key: fs.readFileSync(bc + '/test/data/x509.key'),
|
||||
// cert: fs.readFileSync(bc + '/test/data/x509.crt')
|
||||
// });
|
||||
var pserver = require(bc + '/examples/PayPro/server.js');
|
||||
pserver.removeListener('request', pserver.app);
|
||||
pserver.on('request', function(req, res) {
|
||||
var statusCode = res.statusCode;
|
||||
|
||||
var headers = Object.keys(res._headers || {}).reduce(function(out, key) {
|
||||
out[key] = res._headers[key];
|
||||
return out;
|
||||
}, {});
|
||||
|
||||
var headerNames = Object.keys(res._headerNames || {}).reduce(function(out, key) {
|
||||
out[key] = res._headerNames[key];
|
||||
return out;
|
||||
}, {});
|
||||
|
||||
var writeHead = res.writeHead;
|
||||
var write = res.write;
|
||||
var end = res.end;
|
||||
var status;
|
||||
|
||||
res.writeHead = function(s) {
|
||||
status = s;
|
||||
if (status > 400) {
|
||||
return;
|
||||
}
|
||||
return writeHead.apply(this, arguments);
|
||||
};
|
||||
|
||||
res.write = function() {
|
||||
if (status && status > 400) {
|
||||
return true;
|
||||
}
|
||||
return write.apply(this, arguments);
|
||||
};
|
||||
|
||||
res.end = function() {
|
||||
var self = this;
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
process.nextTick(function() {
|
||||
self.statusCode = statusCode;
|
||||
self._headers = headers;
|
||||
self._headerNames = headerNames;
|
||||
self.writeHead = writeHead;
|
||||
self.write = write;
|
||||
self.end = end;
|
||||
if ((status || self.statusCode) > 400) {
|
||||
return pserver.app(req, res);
|
||||
}
|
||||
return end.apply(self, args);
|
||||
});
|
||||
return true;
|
||||
};
|
||||
|
||||
if (req.url.indexOf('/-/') === 0) {
|
||||
return pserver.app(req, res);
|
||||
}
|
||||
return app(req, res);
|
||||
});
|
||||
|
||||
pserver.listen(port, function() {
|
||||
callback('https://localhost:' + port);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,9 +53,10 @@ angular.module('copayApp.directives')
|
|||
+ expires.toISOString()
|
||||
+ '): ' + memo);
|
||||
|
||||
ctrl.$setValidity('validAddress', true);
|
||||
// ctrl.$setValidity('validAddress', true);
|
||||
});
|
||||
|
||||
ctrl.$setValidity('validAddress', true);
|
||||
return 'Merchant: '+ uri.merchant;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@ if (typeof window !== 'undefined') {
|
|||
}
|
||||
|
||||
if (typeof angular !== 'undefined') {
|
||||
var $http = G.$http || angular.bootstrap().get('$http');
|
||||
G.$http = G.$http || angular.bootstrap().get('$http');
|
||||
}
|
||||
|
||||
var $http = G.$http || function $http(options, callback) {
|
||||
G.$http = function $http(options, callback) {
|
||||
if (typeof options === 'string') {
|
||||
options = { uri: options };
|
||||
}
|
||||
|
@ -84,11 +84,11 @@ var $http = G.$http || function $http(options, callback) {
|
|||
// Newer browsers:
|
||||
xhr.responseType = 'arraybuffer';
|
||||
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == 4) {
|
||||
;
|
||||
}
|
||||
};
|
||||
// xhr.onreadystatechange = function() {
|
||||
// if (xhr.readyState == 4) {
|
||||
// ;
|
||||
// }
|
||||
// };
|
||||
|
||||
xhr.onload = function(event) {
|
||||
var response = xhr.response;
|
||||
|
|
Loading…
Reference in New Issue