import { NextResponse } from "next/server";
import { getAuthFromRequest } from "@open-mercato/shared/lib/auth/server";
import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
import { paymentGatewaysTag } from "../../openapi.js";
const metadata = {
  path: "/payment_gateways/providers/[providerKey]",
  GET: { requireAuth: true, requireFeatures: ["payment_gateways.view"] }
};
async function GET(request, { params }) {
  const auth = await getAuthFromRequest(request);
  if (!auth?.tenantId || !auth.orgId) {
    return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
  }
  const resolvedParams = await params;
  const providerKey = resolvedParams?.providerKey?.trim();
  if (!providerKey) {
    return NextResponse.json({ error: "Provider key is required" }, { status: 400 });
  }
  const { resolve } = await createRequestContainer();
  const descriptorService = resolve("paymentGatewayDescriptorService");
  const descriptor = await descriptorService.getResolved(providerKey, {
    organizationId: auth.orgId,
    tenantId: auth.tenantId
  });
  if (!descriptor) {
    return NextResponse.json({ error: "Provider descriptor not found" }, { status: 404 });
  }
  return NextResponse.json(descriptor);
}
const openApi = {
  tags: [paymentGatewaysTag],
  summary: "Get payment gateway descriptor",
  methods: {
    GET: {
      summary: "Get payment gateway descriptor",
      tags: [paymentGatewaysTag],
      responses: [
        { status: 200, description: "Provider descriptor" },
        { status: 404, description: "Provider descriptor not found" }
      ]
    }
  }
};
var route_default = GET;
export {
  GET,
  route_default as default,
  metadata,
  openApi
};
//# sourceMappingURL=route.js.map
