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 posth = require( './api/postHandler.js' );
const geth = require( './api/getHandler.js' ); const geth = require( './api/getHandler.js' );
const postHandler = new posth();
const path = require( 'path' ); const path = require( 'path' );
const bodyParser = require( 'body-parser' ); const bodyParser = require( 'body-parser' );
const mlt = require( 'multer' ); const mlt = require( 'multer' );
const multer = mlt(); const multer = mlt();
const fs = require( 'fs' ); 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 // 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 => { postHandler.handleCall( req.params.call, req.body, req.query.lang ).then( data => {
res.send( data ); res.send( data );
} ).catch( error => { } ).catch( error => {
console.error( error );
res.status( error.code ).send( error.error ); res.status( error.code ).send( error.error );
} ); } );
} else { } else {

View File

@@ -8,10 +8,12 @@
*/ */
const db = require( '../../backend/db/db.js' ); const db = require( '../../backend/db/db.js' );
const fs = require( 'fs' );
const path = require( 'path' );
class POSTHandler { class POSTHandler {
constructor () { constructor ( settings ) {
this.settings = settings;
} }
handleCall ( call, data, lang ) { handleCall ( call, data, lang ) {
@@ -113,8 +115,12 @@ class POSTHandler {
} else if ( call === 'deleteAdminAccount' ) { } else if ( call === 'deleteAdminAccount' ) {
// TODO: Finish // TODO: Finish
} else if ( call === 'updateSettings' ) { } 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 // TODO: Parse all events and update currency
resolve( 'ok' );
} else { } else {
reject( { 'code': 404, 'error': 'Route not found' } ); 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 axios = require( 'axios' );
const Base64 = require( 'crypto-js/enc-base64' ); const Base64 = require( 'crypto-js/enc-base64' );
const hmacSHA256 = require( 'crypto-js/hmac-sha256' ); 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 baseUrl = 'https://api.payrexx.com/v1.0/';
const instance = payrexxConfig.instance; 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 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 bodyParser = require( 'body-parser' );
const ticket = require( '../../../tickets/ticketGenerator.js' ); const ticket = require( '../../../tickets/ticketGenerator.js' );
const payrexxModule = require( './module.payrexx.js' ); const payrexxModule = require( './module.payrexx.js' );
@@ -32,7 +33,6 @@ module.exports = ( app, settings ) => {
'failedRedirectUrl': settings.yourDomain + '/payments/failed', 'failedRedirectUrl': settings.yourDomain + '/payments/failed',
'currency': settings.currency, 'currency': settings.currency,
'basket': [], 'basket': [],
'pm': payrexxConfig.paymentMethods,
'amount': 0, 'amount': 0,
}; };

View File

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

View File

@@ -10,7 +10,8 @@
const fs = require( 'fs' ); const fs = require( 'fs' );
const path = require( 'path' ); const path = require( 'path' );
const db = require( '../../../db/db.js' ); 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 stripe = require( 'stripe' )( stripeConfig[ 'APIKey' ] );
const bodyParser = require( 'body-parser' ); const bodyParser = require( 'body-parser' );
const ticket = require( '../../../tickets/ticketGenerator.js' ); 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":"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"}
"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"
}

View File

@@ -26,6 +26,7 @@
</td> </td>
</tr> </tr>
</table> </table>
<button @click="save()">Save</button>
<p>Detailed explanation of payment gateways can be found <a href="https://libreevent.janishutz.com/docs/payments" target="_blank">here</a>. You may install more payment gateway integrations in the plugins section. Only one may be used at any given time.</p> <p>Detailed explanation of payment gateways can be found <a href="https://libreevent.janishutz.com/docs/payments" target="_blank">here</a>. You may install more payment gateway integrations in the plugins section. Only one may be used at any given time.</p>
<div class="admin-settings"> <div class="admin-settings">
@@ -42,6 +43,7 @@
</div> </div>
<rightClickMenu ref="rclk" @command="( command ) => { executeCommand( command ) }"></rightClickMenu> <rightClickMenu ref="rclk" @command="( command ) => { executeCommand( command ) }"></rightClickMenu>
<popups ref="popup" size="big" @data="( data ) => { handlePopupReturns( data ); }"></popups> <popups ref="popup" size="big" @data="( data ) => { handlePopupReturns( data ); }"></popups>
<notifications ref="notification" location="topright" size="bigger"></notifications>
</div> </div>
</template> </template>
@@ -49,6 +51,7 @@
import settings from '@/components/settings/settings.vue'; import settings from '@/components/settings/settings.vue';
import popups from '@/components/notifications/popups.vue'; import popups from '@/components/notifications/popups.vue';
import rightClickMenu from '@/components/settings/rightClickMenu.vue'; import rightClickMenu from '@/components/settings/rightClickMenu.vue';
import notifications from '@/components/notifications/notifications.vue';
export default { export default {
name: 'adminSettingsView', name: 'adminSettingsView',
@@ -56,6 +59,7 @@
settings, settings,
popups, popups,
rightClickMenu, rightClickMenu,
notifications,
}, },
data () { data () {
return { return {
@@ -66,44 +70,44 @@
'display': 'Require Two-Factor-Authentication of user', 'display': 'Require Two-Factor-Authentication of user',
'id': '2fa', 'id': '2fa',
'tooltip':'Control whether or not users are required to use Two-Factor-Authentication. Defaults to "User can decide", which is recommended', 'tooltip':'Control whether or not users are required to use Two-Factor-Authentication. Defaults to "User can decide", which is recommended',
'value': 'always', 'value': 'enforce',
'type': 'select', 'type': 'select',
'restrictions': { 'restrictions': {
'always': { 'enforce': {
'displayName':'Always require', 'displayName':'Always require',
'value': 'always' 'value': 'enforce'
}, },
'userDecided': { 'allow': {
'displayName':'User can decide', 'displayName':'User can decide',
'value': 'userDecided' 'value': 'allow'
}, },
'never': { 'disable': {
'displayName':'Disable', 'displayName':'Disable',
'value': 'never' 'value': 'disable'
}, },
} }
}, },
'addressRequired': { // 'addressRequired': {
'display': 'Require user to provide address?', // 'display': 'Require user to provide address?',
'id': 'addressRequired', // 'id': 'addressRequired',
'tooltip':'With this toggle you may specify whether or not a user has to provide their address when purchasing something. (Keep GDPR in mind when processing data!)', // 'tooltip':'With this toggle you may specify whether or not a user has to provide their address when purchasing something. (Keep GDPR in mind when processing data!)',
'value': false, // 'value': false,
'type': 'toggle', // 'type': 'toggle',
}, // },
'phoneNumberRequired': { // 'phoneNumberRequired': {
'display': 'Require user to provide phone number?', // 'display': 'Require user to provide phone number?',
'id': 'phoneNumberRequired', // 'id': 'phoneNumberRequired',
'tooltip':'With this toggle you may specify whether or not a user has to provide their phone number when purchasing something. (Keep GDPR in mind when processing data!)', // 'tooltip':'With this toggle you may specify whether or not a user has to provide their phone number when purchasing something. (Keep GDPR in mind when processing data!)',
'value': false, // 'value': false,
'type': 'toggle', // 'type': 'toggle',
}, // },
'dobRequired': { // 'dobRequired': {
'display': 'Require user to provide their birth date?', // 'display': 'Require user to provide their birth date?',
'id': 'dobRequired', // 'id': 'dobRequired',
'tooltip':'With this toggle you may specify whether or not a user has to provide their date of birth when purchasing something. (Keep GDPR in mind when processing data!)', // 'tooltip':'With this toggle you may specify whether or not a user has to provide their date of birth when purchasing something. (Keep GDPR in mind when processing data!)',
'value': false, // 'value': false,
'type': 'toggle', // 'type': 'toggle',
}, // },
'currency': { 'currency': {
'display': 'Currency', 'display': 'Currency',
'id': 'currency', 'id': 'currency',
@@ -118,14 +122,14 @@
'value': 'stripe', 'value': 'stripe',
'type': 'select', 'type': 'select',
'restrictions': { 'restrictions': {
'payrexx': {
'displayName':'Payrexx',
'value': 'payrexx'
},
'stripe': { 'stripe': {
'displayName':'Stripe', 'displayName':'Stripe',
'value': 'stripe' 'value': 'stripe'
}, },
'adyen': {
'displayName':'Payrexx',
'value': 'payrexx'
},
} }
}, },
} }
@@ -162,21 +166,12 @@
'value': false, 'value': false,
'type': 'toggle', 'type': 'toggle',
}, },
'entryControl': {
'display': 'Entry control',
'id': 'entryControl',
'tooltip':'Change this setting to allow or disallow the selected user to execute entry control at the entrance to your event location.',
'value': true,
'type': 'toggle',
},
} }
, 'settings' ); , 'settings' );
}, },
showPaymentSettings () { showPaymentSettings () {
this.$refs.popup.openPopup( 'Payment gateway settings', { // TODO: Load payment gateway settings from server
'link': '/payments/settings', this.$refs.popup.openPopup( 'Payment gateway settings', {}, 'string' );
}
, 'iframe' );
}, },
createAccount() { createAccount() {
this.$refs.popup.openPopup( 'Create new admin user', { this.$refs.popup.openPopup( 'Create new admin user', {
@@ -240,7 +235,37 @@
openRightClickMenu( id, event ) { openRightClickMenu( id, event ) {
this.$refs.rclk.openRightClickMenu( event, { 'edit': { 'command': 'openPermissions', 'symbol': 'edit', 'display': 'Edit permissions' }, 'delete': { 'command': 'deleteUser', 'symbol': 'delete', 'display': 'Delete User' } } ) this.$refs.rclk.openRightClickMenu( event, { 'edit': { 'command': 'openPermissions', 'symbol': 'edit', 'display': 'Edit permissions' }, 'delete': { 'command': 'deleteUser', 'symbol': 'delete', 'display': 'Delete User' } } )
this.currentlyOpenMenu = id; this.currentlyOpenMenu = id;
},
loadData() {
fetch( '/admin/getAPI/getSettings' ).then( res => {
if ( res.status === 200 ) {
res.json().then( json => {
this.settings[ '2fa' ].value = json.twoFA;
this.settings.currency.value = json.currency;
this.settings.paymentGateway.value = json.payments;
} );
}
} );
},
save() {
let fetchOptions = {
method: 'post',
body: JSON.stringify( { 'twoFA': this.settings[ '2fa' ].value, 'currency': this.settings.currency.value, 'payments': this.settings.paymentGateway.value } ),
headers: {
'Content-Type': 'application/json',
'charset': 'utf-8'
}
};
fetch( localStorage.getItem( 'url' ) + '/admin/API/updateSettings', fetchOptions ).then( res => {
if ( res.status === 200 ) {
this.$refs.notification.createNotification( 'Saved settings successfully. Restart libreevent to apply changes', 20, 'ok', 'normal' );
this.loadData();
}
} );
} }
},
created () {
this.loadData();
} }
}; };
// TODO: Load gateways and settings in general from server. // TODO: Load gateways and settings in general from server.

View File

@@ -1,13 +1,13 @@
# Payments # Payments
Including many payment methods can help the user choose the one that fits them best, but can also be overwhelming and a pain to set up. So please try to use as few different payment gateways as possible. Our recommendation is either *Stripe* or *adyen* as they are the most flexible. Including many payment methods can help the user choose the one that fits them best, but can also be overwhelming and a pain to set up. So please try to use as few different payment gateways as possible. Officially, libreevent supports *Stripe* and *Payrexx*. More payment gateways might come in the future as a plugin which can be installed by following our guide [here](&/plugins/install#payments)
## Advantages / Disadvantages of each payment gateway ## Advantages / Disadvantages of each payment gateway
### payrexx ### payrexx
Payrexx is a lesser known payment gateway and it is not ideal for you if you expect to have a low sales volume, as their basic plan costs you EUR 15 a month. If your sales volume is fairly high, it may be worth is as their per-transaction fees are quite a bit lower than Stripe's and they offer more payment options. Payrexx is a Swiss, lesser known payment gateway and it is not ideal for you if you expect to have a low sales volume, as their basic plan costs you EUR 15 a month. If your sales volume is fairly high, it may be worth it as their per-transaction fees are quite a bit lower than Stripe's and they offer more payment options.
See payrexx [pricing here](https://www.payrexx.com/en/pricing/) and sign up [here](https://signup.payrexx.com). You can find a full list of supported payment methods as they should be entered in the GUI [here](https://docs.payrexx.com/developer/general-info/payment-method) See payrexx [pricing here](https://www.payrexx.com/en/pricing/) and sign up [here](https://signup.payrexx.com). You can find a full list of supported payment methods [here](https://payrexx.com/en/paymentmethods)
### Stripe ### Stripe
Stripe is one of the most well known payment gateways out there and it is really easy to get started. Stripe is one of the most well known payment gateways out there and it is really easy to get started. See all their payment methods [here](https://stripe.com/en-ch/payments/payment-methods). If you choose to use Stripe, you may follow their guides on how to set up more payment options [here](https://stripe.com/docs/payments/payment-methods/overview)
See [here](https://stripe.com/en-gb/pricing) for pricing information and sign up [here](https://dashboard.stripe.com/register) See [here](https://stripe.com/en-gb/pricing) for pricing information and sign up [here](https://dashboard.stripe.com/register)