general event settings done

This commit is contained in:
2023-08-12 14:49:36 +02:00
parent e634ac5381
commit 029181329a
11 changed files with 101 additions and 82 deletions

View File

@@ -9,13 +9,14 @@
const posth = require( './api/postHandler.js' );
const geth = require( './api/getHandler.js' );
const postHandler = new posth();
const path = require( 'path' );
const bodyParser = require( 'body-parser' );
const mlt = require( 'multer' );
const multer = mlt();
const fs = require( 'fs' );
const getHandler = new geth( JSON.parse( fs.readFileSync( path.join( __dirname + '/../config/settings.config.json' ) ) ) );
const settings = JSON.parse( fs.readFileSync( path.join( __dirname + '/../config/settings.config.json' ) ) );
const getHandler = new geth( settings );
const postHandler = new posth( settings );
// settings is missing in arguments which shouldn't pose any problem
@@ -39,6 +40,7 @@ module.exports = ( app ) => {
postHandler.handleCall( req.params.call, req.body, req.query.lang ).then( data => {
res.send( data );
} ).catch( error => {
console.error( error );
res.status( error.code ).send( error.error );
} );
} else {

View File

@@ -8,10 +8,12 @@
*/
const db = require( '../../backend/db/db.js' );
const fs = require( 'fs' );
const path = require( 'path' );
class POSTHandler {
constructor () {
constructor ( settings ) {
this.settings = settings;
}
handleCall ( call, data, lang ) {
@@ -113,8 +115,12 @@ class POSTHandler {
} else if ( call === 'deleteAdminAccount' ) {
// TODO: Finish
} else if ( call === 'updateSettings' ) {
// TODO: Finish
this.settings[ 'twoFA' ] = data.twoFA;
this.settings[ 'currency' ] = data.currency;
this.settings[ 'payments' ] = data.payments;
fs.writeFileSync( path.join( __dirname + '/../../config/settings.config.json' ), JSON.stringify( this.settings ) );
// TODO: Parse all events and update currency
resolve( 'ok' );
} else {
reject( { 'code': 404, 'error': 'Route not found' } );
}

View File

@@ -0,0 +1,4 @@
{
"APISecret": "",
"instance": ""
}

View File

@@ -13,7 +13,7 @@ const qs = require( 'qs' );
const axios = require( 'axios' );
const Base64 = require( 'crypto-js/enc-base64' );
const hmacSHA256 = require( 'crypto-js/hmac-sha256' );
const payrexxConfig = JSON.parse( fs.readFileSync( path.join( __dirname + '/../../../../config/payments.config.secret.json' ) ) )[ 'payrexx' ];
const payrexxConfig = JSON.parse( fs.readFileSync( path.join( __dirname + '/config.payments.secret.json' ) ) );
const baseUrl = 'https://api.payrexx.com/v1.0/';
const instance = payrexxConfig.instance;

View File

@@ -7,10 +7,11 @@
*
*/
const fs = require( 'fs' );
const path = require( 'path' );
const db = require( '../../../db/db.js' );
const payrexxConfig = JSON.parse( fs.readFileSync( path.join( __dirname + '/../../../../config/payments.config.secret.json' ) ) )[ 'payrexx' ];
// const fs = require( 'fs' );
// const path = require( 'path' );
// const payrexxConfig = JSON.parse( fs.readFileSync( path.join( __dirname + '/../../../../config/payments.config.secret.json' ) ) )[ 'payrexx' ];
// TODO: Verify that it works with temporary site on webhosting account
const bodyParser = require( 'body-parser' );
const ticket = require( '../../../tickets/ticketGenerator.js' );
const payrexxModule = require( './module.payrexx.js' );
@@ -32,7 +33,6 @@ module.exports = ( app, settings ) => {
'failedRedirectUrl': settings.yourDomain + '/payments/failed',
'currency': settings.currency,
'basket': [],
'pm': payrexxConfig.paymentMethods,
'amount': 0,
};

View File

@@ -0,0 +1,4 @@
{
"APIKey": "",
"endpointSecret": ""
}

View File

@@ -10,7 +10,8 @@
const fs = require( 'fs' );
const path = require( 'path' );
const db = require( '../../../db/db.js' );
const stripeConfig = JSON.parse( fs.readFileSync( path.join( __dirname + '/../../../../config/payments.config.secret.json' ) ) )[ 'stripe' ];
// TODO: update config files to non-secret version for final version
const stripeConfig = JSON.parse( fs.readFileSync( path.join( __dirname + '/config.payments.secret.json' ) ) );
const stripe = require( 'stripe' )( stripeConfig[ 'APIKey' ] );
const bodyParser = require( 'body-parser' );
const ticket = require( '../../../tickets/ticketGenerator.js' );

View File

@@ -1,11 +0,0 @@
{
"stripe": {
"APIKey": "",
"endpointSecret": ""
},
"payrexx": {
"APISecret": "",
"instance": "",
"pm": []
}
}

View File

@@ -1,13 +1 @@
{
"init": true,
"twoFA": "allow",
"setupKey": "hello world",
"twoFAMode": "enhanced",
"db": "mysql",
"payments": "payrexx",
"name": "libreevent",
"yourDomain": "http://localhost:8080",
"mailSender": "libreevent <info@libreevent.janishutz.com>",
"maxTickets": 10,
"currency": "CHF"
}
{"init":true,"twoFA":"enforce","setupKey":"hello world","twoFAMode":"enhanced","db":"mysql","payments":"stripe","name":"libreevent","yourDomain":"http://localhost:8080","mailSender":"libreevent <info@libreevent.janishutz.com>","maxTickets":10,"currency":"CHF"}