<?php
// Altyapıdan dönüş. iyzico ve Shopier sonucu tarayıcıyla POST eder: doğrulanır, sonra
// imzalı GET adresine yönlendirilir (çerezler çapraz POST'ta gelmediği için).
$provider = get('saglayici', '');
if (is_post() && in_array($provider, ['iyzico', 'shopier'], true)) {
$payment = ('gateway_' . $provider . '_callback')();
$order = $payment ? db_find('orders', $payment['order_id']) : null;
if (!$order) {
not_found();
}
header('Location: ' . payment_result_url($order), true, 303);
exit;
}
$order = order_by_key(get('no', ''), get('k', ''));
if (!$order) {
not_found();
}
$payment = order_payments($order['id'])[0] ?? null;
$paid = $order['payment_status'] === 'paid';
$failed = !$paid && ($order['payment_status'] === 'failed' || get('durum') === 'hata');
$waiting = !$paid && !$failed;
if ($paid) {
sess_set('last_order', $order['id']);
}
view_header($paid ? 'Ödeme başarılı' : 'Ödeme sonucu', ['noindex' => true]);
?>
<?php if ($waiting): ?>
<meta http-equiv="refresh" content="3">
<?php endif ?>
<section class="container-x pt-12">
<div class="mx-auto max-w-xl text-center">
<?php if ($paid): ?>
<span class="mx-auto flex size-16 items-center justify-center rounded-full bg-emerald-50 text-emerald-600 ring-8 ring-emerald-50/50"><?= icon('check', 'size-8', '2') ?></span>
<h1 class="heading mt-8 text-4xl <?= heading_weight_class() ?>">Ödemeniz alındı!</h1>
<p class="mt-4 text-zinc-600">#<?= e($order['order_no']) ?> numaralı siparişiniz onaylandı. Siparişinizin detaylarını <?= e($order['email']) ?> adresine gönderdik.</p>
<div class="mt-8 flex flex-wrap justify-center gap-3">
<a href="<?= url('siparis-tamam') ?>" class="btn-primary">Sipariş özetini gör</a>
<a href="<?= url('urunler') ?>" class="btn-light">Alışverişe devam et</a>
</div>
<?php elseif ($failed): ?>
<span class="mx-auto flex size-16 items-center justify-center rounded-full bg-rose-50 text-rose-600 ring-8 ring-rose-50/50"><?= icon('x', 'size-8', '2') ?></span>
<h1 class="heading mt-8 text-4xl <?= heading_weight_class() ?>">Ödeme tamamlanamadı</h1>
<p class="mt-4 text-zinc-600"><?= e($payment['error'] ?? 'Kartınızdan çekim yapılamadı.') ?></p>
<?php if ($order['status'] === 'odeme_bekleniyor'): ?>
<p class="mt-2 text-sm text-zinc-500">Siparişiniz <?= payment_timeout() ?> dakika boyunca sizin için ayrılmış durumda.</p>
<div class="mt-8 flex flex-wrap justify-center gap-3">
<a href="<?= e(payment_url($order)) ?>" class="btn-primary">Tekrar dene</a>
<a href="<?= url('iletisim') ?>" class="btn-light">Yardım al</a>
</div>
<?php else: ?>
<a href="<?= url('sepet') ?>" class="btn-primary mt-8">Sepete dön</a>
<?php endif ?>
<?php else: ?>
<svg class="mx-auto size-14 animate-spin text-ink" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="2.5" opacity=".15"/><path d="M21 12a9 9 0 0 0-9-9" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>
<h1 class="heading mt-8 text-3xl <?= heading_weight_class() ?>">Ödemeniz doğrulanıyor…</h1>
<p class="mt-4 text-zinc-600">Bankanızdan onay bekleniyor, bu sayfa birkaç saniyede bir kendini yeniler. Lütfen kapatmayın.</p>
<?php endif ?>
</div>
</section>
<?php view_footer() ?>
Lisans bilgisi projenin LICENSE dosyasında.