This commit is contained in:
root
2026-01-03 06:06:54 +00:00
parent d138dae2ca
commit eeaa9a66bb
16 changed files with 728 additions and 348 deletions

View File

@@ -43,10 +43,10 @@ export async function POST(request: NextRequest) {
)
}
// Validate crypto currency
if (!isAllowedCurrency(normalizedCryptoCurrency)) {
// Validate crypto currency - only USDT (SOL) is allowed for redemption
if (normalizedCryptoCurrency !== 'usdtsol') {
return NextResponse.json(
{ error: `Unsupported cryptocurrency. Allowed: ${ALLOWED_PAYMENT_CURRENCIES.join(', ')}` },
{ error: 'Only USDT (SOL) is supported for point redemption' },
{ status: 400 }
)
}
@@ -205,6 +205,7 @@ async function getCryptoExchangeRate(crypto: string, fiat: string): Promise<numb
'xrp': 0.6,
'bnbbsc': 300,
'usdterc20': 0.9, // Approximate CHF per USDT
'usdtsol': 0.9, // Approximate CHF per USDT on Solana
}
return mockRates[crypto.toLowerCase()] || null

View File

@@ -38,12 +38,31 @@ export async function GET(request: NextRequest) {
)
const settings = settingsRows as any[]
// Get EUR-based settings (preferred)
let pointsToEur = parseFloat(
settings.find(s => s.setting_key === 'points_to_eur')?.setting_value || '0'
)
let pointsPerEur = parseFloat(
settings.find(s => s.setting_key === 'points_per_eur')?.setting_value || '0'
)
// Get CHF-based settings (for backward compatibility)
const pointsToChf = parseFloat(
settings.find(s => s.setting_key === 'points_to_chf')?.setting_value || '100'
)
const pointsPerChf = parseFloat(
settings.find(s => s.setting_key === 'points_per_chf')?.setting_value || '10'
)
// If EUR settings not found, convert from CHF (1 CHF ≈ 1.0309 EUR)
const chfToEurRate = 1.030927835
if (pointsToEur === 0) {
pointsToEur = pointsToChf / chfToEurRate
}
if (pointsPerEur === 0) {
pointsPerEur = pointsPerChf * chfToEurRate
}
const pointsToCryptoChf = parseFloat(
settings.find(s => s.setting_key === 'points_to_crypto_chf')?.setting_value || '100'
)
@@ -51,15 +70,19 @@ export async function GET(request: NextRequest) {
settings.find(s => s.setting_key === 'min_redemption_points')?.setting_value || '1000'
)
// Calculate maximum discount available
const maxDiscountChf = referralPoints / pointsToChf
// Calculate maximum discount available (in EUR, then convert to CHF for display)
const maxDiscountEur = referralPoints / pointsToEur
const maxDiscountChf = maxDiscountEur * 0.97 // Convert EUR to CHF
return NextResponse.json({
referral_points: referralPoints,
points_to_chf: pointsToChf,
points_per_chf: pointsPerChf,
points_to_eur: pointsToEur,
points_per_eur: pointsPerEur,
points_to_chf: pointsToChf, // Keep for backward compatibility
points_per_chf: pointsPerChf, // Keep for backward compatibility
points_to_crypto_chf: pointsToCryptoChf,
min_redemption_points: minRedemptionPoints,
max_discount_eur: maxDiscountEur,
max_discount_chf: maxDiscountChf,
})
} catch (error) {