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() { -
+
+ +
+
+ +
+
+

Kritik Güvenlik Anahtarı

+

+ Bu anahtarı güvenli bir yere kaydedin. Sisteme giriş yapmak için tek yönteminiz budur. Bir daha görüntülenemez! +

+
+
+ {success.apiKey} + +
+
+ + + + + + + ); + } + + return ( +
+
+
+
+ +
+

Firma Kaydı

+

P2CGateway Merchant Network'e Katılın

+
+ +
+
+

Firma adınızı belirleyin

+

+ Müşterileriniz ödeme sayfasında bu ismi görecektir. +

+
+ +
+
+ setName(e.target.value)} + placeholder="Örn: Ayris Teknoloji" + className="w-full px-6 py-4 bg-gray-50 border-2 border-transparent focus:border-blue-500 focus:bg-white rounded-[24px] outline-none transition-all font-bold text-gray-900 placeholder:text-gray-300" + /> + {error &&

{error}

} +
+ +
+

+ * Kayıt olduktan sonra size özel bir yönetim paneli ve API anahtarı tahsis edilecektir. +

+
+ + +
+
+ +
+ +
+
+ +
+ + End-to-End Secure Merchant Onboarding +
+
+ ); +}