Adds schema-based input validation across helcim, events, members, series, admin, and updates API endpoints. Removes the peer-support debug test endpoint. Adds validation test coverage.
41 lines
No EOL
1.1 KiB
JavaScript
41 lines
No EOL
1.1 KiB
JavaScript
// Get Helcim payment plans
|
|
const HELCIM_API_BASE = 'https://api.helcim.com/v2'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
try {
|
|
await requireAdmin(event)
|
|
const config = useRuntimeConfig(event)
|
|
const helcimToken = config.public.helcimToken || process.env.NUXT_PUBLIC_HELCIM_TOKEN
|
|
|
|
const response = await fetch(`${HELCIM_API_BASE}/payment-plans`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'accept': 'application/json',
|
|
'api-token': helcimToken
|
|
}
|
|
})
|
|
|
|
if (!response.ok) {
|
|
console.error('Failed to fetch payment plans:', response.status, response.statusText)
|
|
throw createError({
|
|
statusCode: response.status,
|
|
statusMessage: 'Failed to fetch payment plans'
|
|
})
|
|
}
|
|
|
|
const plansData = await response.json()
|
|
|
|
return {
|
|
success: true,
|
|
plans: plansData
|
|
}
|
|
|
|
} catch (error) {
|
|
if (error.statusCode) throw error
|
|
console.error('Error fetching Helcim payment plans:', error)
|
|
throw createError({
|
|
statusCode: 500,
|
|
statusMessage: 'An unexpected error occurred'
|
|
})
|
|
}
|
|
}) |