Update: 2026-05-09 17:36:15

This commit is contained in:
Hamza-Ayed
2026-05-09 17:36:15 +03:00
parent b9ba9c5030
commit d7c7920b4a
2 changed files with 84 additions and 2 deletions

View File

@@ -775,7 +775,7 @@
}
.form-input.mono {
font-family: 'IBM Plex Mono', monospace;
font-family: 'Outfit', sans-serif;
}
.form-section-title {
@@ -2753,6 +2753,88 @@
}
},
async upgradePlan(plan) {
if (this.isBusy) return;
this.isBusy = true;
try {
const res = await fetch('/index.php?route=v1/payments/create', {
method: 'POST',
headers: { 'Authorization': 'Bearer ' + this.token(), 'Content-Type': 'application/json' },
body: JSON.stringify({ plan_id: plan.id })
});
const json = await res.json();
this.isBusy = false;
if (json.success) {
this.paymentData = {
cliq_alias: json.data.cliq_alias,
amount: json.data.amount_jod,
plan_name: json.data.plan_name,
reference: json.data.reference_number,
payment_id: json.data.payment_id
};
this.showPaymentModal = true;
} else {
this.showError(json.message);
}
} catch (e) {
this.isBusy = false;
this.showError('فشل في إنشاء طلب الدفع. يرجى المحاولة لاحقاً.');
}
},
async uploadReceipt() {
if (!this.selectedFile || this.isBusy) return alert('الرجاء اختيار صورة الوصل');
this.isBusy = true;
const formData = new FormData();
formData.append('payment_id', this.paymentData.payment_id);
formData.append('receipt', this.selectedFile);
try {
const res = await fetch('/index.php?route=v1/payments/upload-receipt', {
method: 'POST',
headers: { 'Authorization': 'Bearer ' + this.token() },
body: formData
});
const json = await res.json();
this.isBusy = false;
if (json.success) {
alert(json.message);
this.showPaymentModal = false;
this.selectedFile = null;
await this.loadAll();
} else {
this.showError(json.message);
}
} catch (e) {
this.isBusy = false;
this.showError('حدث خطأ أثناء رفع الوصل.');
}
},
async cancelPayment(paymentId) {
if (!confirm('هل أنت متأكد من إلغاء طلب الترقية؟')) return;
this.isBusy = true;
try {
const res = await fetch('/index.php?route=v1/payments/delete', {
method: 'POST',
headers: { 'Authorization': 'Bearer ' + this.token(), 'Content-Type': 'application/json' },
body: JSON.stringify({ payment_id: paymentId })
});
const json = await res.json();
this.isBusy = false;
if (json.success) {
await this.loadAll();
} else {
this.showError(json.message);
}
} catch (e) {
this.isBusy = false;
this.showError('فشل إلغاء الطلب.');
}
},
logout() { localStorage.clear(); window.location.href = '/login.php'; }
}));
});