import { jsonError, jsonOk, readJsonBody } from "@/lib/server/api"; import { requireSuperAdminUser } from "@/lib/server/auth/current-user"; import { getBillingAccountConfig } from "@/lib/server/billing-service"; import { saveApiSettings } from "@/lib/server/app-settings"; export const runtime = "nodejs"; export async function PATCH(request: Request) { try { await requireSuperAdminUser(); const body = await readJsonBody>(request); const values = { ZHINIAN_BILLING_ACCOUNT_NAME: normalize(body.accountName), ZHINIAN_BILLING_ACCOUNT_BANK: normalize(body.bankName), ZHINIAN_BILLING_ACCOUNT_NUMBER: normalize(body.accountNumber), ZHINIAN_BILLING_CONTACT: normalize(body.contact) }; await saveApiSettings(values); return jsonOk({ billingAccount: getBillingAccountConfig() }); } catch (error) { return jsonError(error, 500, { request, source: "api.admin.billing.account" }); } } function normalize(value: unknown): string { return typeof value === "string" ? value.trim() : ""; }