Update: 2026-05-09 17:36:15
This commit is contained in:
@@ -102,7 +102,7 @@ class SubscriptionController extends GetxController {
|
||||
Future<bool> 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();
|
||||
|
||||
@@ -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'; }
|
||||
}));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user