diff --git a/app/api/merchants/register/route.ts b/app/api/merchants/register/route.ts
new file mode 100644
index 0000000..a00d528
--- /dev/null
+++ b/app/api/merchants/register/route.ts
@@ -0,0 +1,37 @@
+import { NextRequest, NextResponse } from 'next/server';
+import { db } from '@/lib/db';
+import crypto from 'crypto';
+
+export async function POST(req: NextRequest) {
+ try {
+ const { name } = await req.json();
+
+ if (!name || name.length < 3) {
+ return NextResponse.json({ error: 'Firma adı en az 3 karakter olmalıdır.' }, { status: 400 });
+ }
+
+ // Generate a 10-char ID
+ const short_id = crypto.randomBytes(5).toString('hex');
+ const api_key = crypto.randomBytes(24).toString('hex'); // Secure API Key
+
+ // Insert into database
+ const result = await db.query(
+ `INSERT INTO merchants (name, short_id, api_key)
+ VALUES ($1, $2, $3)
+ RETURNING *`,
+ [name, short_id, api_key]
+ );
+
+ const merchant = result.rows[0];
+
+ return NextResponse.json({
+ success: true,
+ merchantId: merchant.id,
+ shortId: merchant.short_id,
+ apiKey: merchant.api_key
+ });
+ } catch (err: any) {
+ console.error('[Registration Error]:', err.message);
+ return NextResponse.json({ error: 'Sunucu hatası: ' + err.message }, { status: 500 });
+ }
+}
diff --git a/app/merchant/[id]/login/page.tsx b/app/merchant/[id]/login/page.tsx
index a08b55e..6884327 100644
--- a/app/merchant/[id]/login/page.tsx
+++ b/app/merchant/[id]/login/page.tsx
@@ -84,7 +84,13 @@ export default function MerchantLoginPage() {
-
+
+