validate Stripe cancellation responses
This commit is contained in:
@@ -228,8 +228,11 @@ export async function cancelSubscription({ subId, neden, aciklama }) {
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) throw new Error(data?.error?.message || `Stripe hatası: HTTP ${res.status}`);
|
||||
if (typeof data.id !== 'string' || !data.id.trim() || typeof data.status !== 'string' || !data.status.trim())
|
||||
throw new Error('Stripe abonelik iptal yanıtı geçersiz.');
|
||||
return {
|
||||
id: data.id,
|
||||
status: data.status,
|
||||
donemSonunda: Boolean(data.cancel_at_period_end),
|
||||
bitis: data.cancel_at ? new Date(data.cancel_at * 1000).toISOString() : null,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user