rc 1.0
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { getNowPaymentsConfig } from '@/lib/nowpayments'
|
||||
import { ALLOWED_PAYMENT_CURRENCIES } from '@/lib/payment-currencies'
|
||||
|
||||
// GET /api/payments/currencies - Get available payment currencies from NOWPayments
|
||||
export async function GET() {
|
||||
@@ -27,10 +28,27 @@ export async function GET() {
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
// Filter currencies to only include the selected list
|
||||
const currencies = (data.currencies || []).filter((c: any) => {
|
||||
let currencyCode: string | null = null
|
||||
|
||||
// Handle object format (when fixed_rate=true)
|
||||
if (typeof c === 'object' && c !== null && c.currency) {
|
||||
currencyCode = String(c.currency).trim().toLowerCase()
|
||||
}
|
||||
// Handle string format (when fixed_rate=false)
|
||||
else if (typeof c === 'string') {
|
||||
currencyCode = c.trim().toLowerCase()
|
||||
}
|
||||
|
||||
// Check if currency is in the allowed list
|
||||
return currencyCode && ALLOWED_PAYMENT_CURRENCIES.includes(currencyCode as any)
|
||||
})
|
||||
|
||||
// Return the currencies array
|
||||
// Return the filtered currencies array
|
||||
return NextResponse.json({
|
||||
currencies: data.currencies || [],
|
||||
currencies: currencies,
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Error fetching currencies:', error)
|
||||
|
||||
Reference in New Issue
Block a user