/**
 * 获取可用支付方式 API
 * 基于 Universal_Payment_Module v4.0 设计
 * 
 * GET /api/payment/methods
 */

import { NextResponse } from "next/server"
import { PaymentFactory } from "@/lib/payment"

// 确保网关已注册
import "@/lib/payment/alipay"
import "@/lib/payment/wechat"

export async function GET() {
  try {
    const methods = PaymentFactory.getEnabledGateways()

    return NextResponse.json({
      code: 200,
      message: "success",
      data: {
        methods,
      },
    })
  } catch (error) {
    console.error("[Payment] Get methods error:", error)
    return NextResponse.json(
      {
        code: 500,
        message: error instanceof Error ? error.message : "服务器错误",
        data: null,
      },
      { status: 500 }
    )
  }
}
