race condition fixed, payment inside

This commit is contained in:
root
2025-12-21 09:56:59 +01:00
parent 6741f5ed72
commit 67646c75a4
6 changed files with 714 additions and 30 deletions

View File

@@ -0,0 +1,43 @@
import { NextResponse } from 'next/server'
import { getNowPaymentsConfig } from '@/lib/nowpayments'
// GET /api/payments/currencies - Get available payment currencies from NOWPayments
export async function GET() {
try {
const nowPaymentsConfig = getNowPaymentsConfig()
// Fetch available currencies from NOWPayments
const response = await fetch(
`${nowPaymentsConfig.baseUrl}/v1/currencies?fixed_rate=true`,
{
method: 'GET',
headers: {
'x-api-key': nowPaymentsConfig.apiKey,
},
}
)
if (!response.ok) {
const error = await response.json()
console.error('NOWPayments currencies error:', error)
return NextResponse.json(
{ error: 'Failed to fetch available currencies', details: error },
{ status: 500 }
)
}
const data = await response.json()
// Return the currencies array
return NextResponse.json({
currencies: data.currencies || [],
})
} catch (error) {
console.error('Error fetching currencies:', error)
return NextResponse.json(
{ error: 'Failed to fetch currencies' },
{ status: 500 }
)
}
}