From d7c7920b4a242c80310da11e1f69f376224a4fc8 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Sat, 9 May 2026 17:36:15 +0300 Subject: [PATCH] Update: 2026-05-09 17:36:15 --- .../controllers/subscription_controller.dart | 2 +- public/shell.php | 84 ++++++++++++++++++- 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/musadaq-app/lib/features/subscription/controllers/subscription_controller.dart b/musadaq-app/lib/features/subscription/controllers/subscription_controller.dart index bc19638..e23b7ea 100644 --- a/musadaq-app/lib/features/subscription/controllers/subscription_controller.dart +++ b/musadaq-app/lib/features/subscription/controllers/subscription_controller.dart @@ -102,7 +102,7 @@ class SubscriptionController extends GetxController { Future cancelPaymentRequest(String paymentId) async { try { isLoading.value = true; - final res = await DioClient().client.post('payments/cancel', data: {'payment_id': paymentId}); + final res = await DioClient().client.post('payments/delete', data: {'payment_id': paymentId}); if (res.data['success'] == true) { AppSnackbar.showSuccess('تم الإلغاء', 'تم إلغاء طلب الدفع بنجاح'); await loadAll(); diff --git a/public/shell.php b/public/shell.php index d6805da..a59a52b 100644 --- a/public/shell.php +++ b/public/shell.php @@ -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'; } })); });