Update wallet route to use environment variables for deposit limits
This commit is contained in:
@@ -21,3 +21,5 @@ MAX_BET=500
|
|||||||
ROUND_START_DELAY_MS=3000
|
ROUND_START_DELAY_MS=3000
|
||||||
ROUND_RESET_DELAY_MS=5000
|
ROUND_RESET_DELAY_MS=5000
|
||||||
TURN_TIME_MS=15000
|
TURN_TIME_MS=15000
|
||||||
|
MIN_DEPOSIT=175
|
||||||
|
MAX_DEPOSIT=1000
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ const router = Router();
|
|||||||
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || '', {
|
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || '', {
|
||||||
apiVersion: '2024-06-20'
|
apiVersion: '2024-06-20'
|
||||||
});
|
});
|
||||||
|
const MIN_DEPOSIT = Number(process.env.MIN_DEPOSIT || 175);
|
||||||
|
const MAX_DEPOSIT = Number(process.env.MAX_DEPOSIT || 1000);
|
||||||
|
|
||||||
function ensureStripeConfigured(res) {
|
function ensureStripeConfigured(res) {
|
||||||
if (!process.env.STRIPE_SECRET_KEY) {
|
if (!process.env.STRIPE_SECRET_KEY) {
|
||||||
@@ -23,8 +25,8 @@ router.post('/api/wallet/deposit-intent', authMiddleware, async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const amount = Number(req.body.amount);
|
const amount = Number(req.body.amount);
|
||||||
if (!Number.isFinite(amount) || amount < 50 || amount > 100) {
|
if (!Number.isFinite(amount) || amount < MIN_DEPOSIT || amount > MAX_DEPOSIT) {
|
||||||
return res.status(400).json({ error: 'A feltoltes 50 es 100 Ft kozott lehet.' });
|
return res.status(400).json({ error: `A feltoltes ${MIN_DEPOSIT} es ${MAX_DEPOSIT} Ft kozott lehet.` });
|
||||||
}
|
}
|
||||||
|
|
||||||
const paymentIntent = await stripe.paymentIntents.create({
|
const paymentIntent = await stripe.paymentIntents.create({
|
||||||
|
|||||||
Reference in New Issue
Block a user