fix subscription cancellation body parsing

This commit is contained in:
2026-09-06 17:45:38 +03:00
parent 5e2d255b29
commit fbe74b0919
+9 -1
View File
@@ -1276,7 +1276,15 @@ const server = http.createServer(async (req, res) => {
const kayit = store.getUser(user.email);
const subId = kayit?.stripe_sub_id;
if (!subId) return json(res, 400, { success: false, error: 'Aktif bir aboneliğiniz görünmüyor.' });
const body = await readJson(req);
let body;
try {
body = await readBody(req);
if (!body || typeof body !== 'object' || Array.isArray(body)) throw new Error('Geçersiz abonelik iptal gövdesi.');
if (body.neden != null && (typeof body.neden !== 'string' || body.neden.length > 100)) throw new Error('İptal nedeni geçersiz.');
if (body.aciklama != null && (typeof body.aciklama !== 'string' || body.aciklama.length > 500)) throw new Error('İptal açıklaması geçersiz.');
} catch (error) {
return json(res, 400, { success: false, error: error.message });
}
try {
const out = await cancelSubscription({ subId, neden: body.neden, aciklama: body.aciklama });
// Neden kaydı: ürün kararları için kendi tarafımızda da tutulur.