Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var nodemailer = require('nodemailer');
- var smtpTransport = require('nodemailer-smtp-transport');
- var crypto = require('crypto');
- <<<<<<< HEAD
- var basicAuth = require('basic-auth');
- var os = require('os');
- =======
- var xml2js = require('xml2js');
- >>>>>>> user-access
- var environment = exports.environment = process.env.NODE_ENV;
- var apiEmailAddress = exports.apiEmailAddress = 'no-reply@volenday.com';
- var apiPassword = exports.apiPassword = 'GsvHkpwjhDp&XH^=&qTgk7FYE9C#j&E*qA%q68w-KuVrf&K?$NPwg2&c-eDSq9c#a*zFyn4_f_s4yRE#@&racYBnj-_hExdGxySVg7Tf5qJB*-ZWVH^Mua8Nrq?sbE?b';
- var applicationId = exports.applicationId = '523ba9e0-b5c7-11e6-9337-f9d3629af5c1';
- if (environment == "development") {
- var siteUrl = exports.siteUrl = 'http://localhost:8003/';
- var adminUrl = exports.adminUrl = 'http://admin.localhost:8003/';
- var apiUrl = exports.apiUrl = "http://localhost:3501/";
- var facebookAppId = exports.facebookAppId = "1302274103141628";
- }
- if (environment == "staging") {
- var siteUrl = exports.siteUrl = 'http://test.asia-ceo-awards.volenday.com/';
- var adminUrl = exports.adminUrl = 'http://test.admin.asia-ceo-awards.volenday.com/';
- var apiUrl = exports.apiUrl = "http://test.api.aha.volenday.com/";
- var facebookAppId = exports.facebookAppId = "1302274103141628";
- }
- if (environment == "production") {
- var siteUrl = exports.siteUrl = 'http://www.asia-ceo-awards.org/';
- var adminUrl = exports.adminUrl = 'http://admin.asia-ceo-awards.org/';
- var apiUrl = exports.apiUrl = "https://api.aha.volenday.com/";
- var facebookAppId = exports.facebookAppId = "1302271043141934";
- }
- var imageUrl = exports.imageUrl = "http://images.aha.volenday.com/" + environment + "/applications/" + applicationId + "/";
- var mailerEmail = exports.mailerEmail = 'no-reply@volenday.com';
- var mailerPassword = exports.mailerPassword = 'sYst3mAdm1n';
- var transporter = exports.transporter = nodemailer.createTransport({
- service: "Gmail",
- auth: {
- type: 'OAuth2',
- user: mailerEmail,
- clientId: "763594980831-n5nse8pgcsh2c7ugpfb5hs2gdp1clemh.apps.googleusercontent.com",
- clientSecret: "Br-0KPmNKMxJs3A6_LZq6B4K",
- refreshToken: "1/a0ZIGVipe8QPfMQNIwdr3CzhbaC6OO5m1sV-2WN_GqE"
- }
- });
- var generateXmlSignature = exports.generateXmlSignature = function (data, params) {
- var orderId = data.OrderId;
- var callbackUrl = siteUrl + 'registrations/callback';
- var responseUrl = siteUrl + 'registrations/response';
- var amount = data.TicketsCount * data.Events.RegistrationFee;
- var currency = 'PHP';
- var pageTimeout = '780';
- <<<<<<< HEAD
- var forSignature = params.MerchantPassword + params.MerchantServiceID + orderId + responseUrl + callbackUrl +
- + amount + '.00' + currency + params.ip + pageTimeout;
- var signature = crypto.createHash('sha256').update(forSignature).digest("hex");
- return signature.toUpperCase();
- };
- var authUser = exports.authUser = 'admin';
- var authPassword = exports.authPassword = 'jEhU56nM6dJ3u6Fk';
- var auth = exports.auth = function (req, res, next) {
- function unauthorized(res) {
- res.set('WWW-Authenticate', 'Basic realm=Authorization Required');
- return res.sendStatus(401);
- };
- var user = basicAuth(req);
- if (!user || !user.name || !user.pass) {
- return unauthorized(res);
- };
- if (user.name === authUser && user.pass === authPassword) {
- return next();
- } else {
- return unauthorized(res);
- };
- };
- var getIP = exports.getIP = function () {
- var interfaces = os.networkInterfaces();
- var addresses = [];
- for (var k in interfaces) {
- for (var k2 in interfaces[k]) {
- var address = interfaces[k][k2];
- if (address.family === 'IPv4' && !address.internal) {
- addresses.push(address.address);
- }
- }
- }
- return addresses[0];
- }
- =======
- return new Buffer(strxml).toString('base64');
- };
- var verifySignature = exports.verifySignature = function (data, callback) {
- var response = data.split(' ').join('+');
- response = new Buffer(response, 'base64').toString("ascii");
- xml2js.parseString(response, function (err, result) {
- var application = result.ServiceResponseWPF.application[0],
- responseStatus = result.ServiceResponseWPF.responseStatus[0];
- var forSignature = application.merchantid[0] + application.request_id[0] + application.response_id[0] +
- responseStatus.response_code[0] + responseStatus.response_message[0] + responseStatus.response_advise[0] +
- application.timestamp[0] + application.rebill_id[0];
- var signature = crypto.createHash('sha512').update(forSignature + merchantKey).digest("hex");
- if (signature == application.signature[0]) {
- if (responseStatus.response_code == "GR001" || responseStatus.response_code == "GR002") {
- callback('Successful', application.request_id[0], application.response_id[0]);
- } else if (responseStatus.response_code == "GR028" || responseStatus.response_code == "GR029" || responseStatus.response_code == "GR053") {
- callback('Cancelled', application.request_id[0], application.response_id[0]);
- } else {
- callback('Failed', application.request_id[0], application.response_id[0]);
- }
- } else {
- callback('Failed', application.request_id[0], application.response_id[0]);
- }
- });
- };
- >>>>>>> user-access
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement