39496-vm/admin_thawani.php
2026-04-06 05:37:02 +00:00

65 lines
3.1 KiB
PHP

<?php
// admin_thawani.php
if (!isset($pdo)) {
$pdo = db();
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'save_thawani') {
$secret = $_POST['thawani_secret_key'] ?? '';
$publishable = $_POST['thawani_publishable_key'] ?? '';
$mode = $_POST['thawani_mode'] ?? 'test';
$stmt = $pdo->prepare("UPDATE platform_profile SET thawani_secret_key = :secret, thawani_publishable_key = :publishable, thawani_mode = :mode WHERE id = 1");
$stmt->execute([
'secret' => $secret,
'publishable' => $publishable,
'mode' => $mode
]);
header('Location: ' . app_url('admin.php', ['page' => 'thawani', 'saved' => 1]));
exit;
}
$stmt = $pdo->query("SELECT thawani_secret_key, thawani_publishable_key, thawani_mode FROM platform_profile WHERE id = 1");
$prof = $stmt->fetch(PDO::FETCH_ASSOC) ?: [];
$mode = $prof['thawani_mode'] ?? 'test';
?>
<div class="section-header mb-4">
<div>
<span class="eyebrow"><?= h(t('Integrations', 'التكاملات')) ?></span>
<h1 class="section-title mb-2"><?= h(t('Thawani Gateway', 'بوابة Thawani')) ?></h1>
<p class="text-secondary mb-0"><?= h(t('Configure your Thawani payment gateway settings.', 'قم بتكوين إعدادات بوابة الدفع Thawani.')) ?></p>
</div>
</div>
<?php if (!empty($_GET['saved'])): ?>
<div class="alert alert-success"><?= h(t('Thawani settings updated successfully.', 'تم تحديث إعدادات Thawani بنجاح.')) ?></div>
<?php endif; ?>
<div class="panel-card" style="max-width: 600px;">
<form method="post">
<input type="hidden" name="action" value="save_thawani">
<div class="mb-3">
<label class="form-label fw-medium"><?= h(t('Secret Key', 'المفتاح السري')) ?></label>
<input type="password" name="thawani_secret_key" class="form-control" value="<?= h($prof['thawani_secret_key'] ?? '') ?>" placeholder="sk_...">
</div>
<div class="mb-3">
<label class="form-label fw-medium"><?= h(t('Publishable Key', 'المفتاح القابل للنشر')) ?></label>
<input type="text" name="thawani_publishable_key" class="form-control" value="<?= h($prof['thawani_publishable_key'] ?? '') ?>" placeholder="pk_...">
</div>
<div class="mb-4">
<label class="form-label fw-medium"><?= h(t('Mode', 'الوضع')) ?></label>
<select name="thawani_mode" class="form-select">
<option value="test" <?= $mode === 'test' ? 'selected' : '' ?>><?= h(t('Test Mode', 'وضع الاختبار')) ?></option>
<option value="live" <?= $mode === 'live' ? 'selected' : '' ?>><?= h(t('Live Mode', 'الوضع الحي')) ?></option>
</select>
</div>
<div class="d-flex justify-content-end">
<button type="submit" class="btn btn-primary px-4" style="background-color: var(--accent); border-color: var(--accent);">
<?= h(t('Save Settings', 'حفظ الإعدادات')) ?>
</button>
</div>
</form>
</div>