1. Go to this page and download the library: Download algmaal/laravel-fawaterak library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
algmaal / laravel-fawaterak example snippets
use Algmaal\LaravelFawaterak\Facades\Fawaterak;
// الحصول على طرق الدفع
$paymentMethods = app(\Algmaal\LaravelFawaterak\Contracts\FawaterakServiceInterface::class)
->getPaymentMethods();
foreach ($paymentMethods['data'] as $method) {
echo $method['name_ar'] . ' - ' . $method['name_en'];
}
use Algmaal\LaravelFawaterak\Facades\Fawaterak;
$invoiceKey = 'hyU2vcy3USvT5Tg';
// التحقق من نجاح الدفعة
if (Fawaterak::isPaymentSuccessful($invoiceKey)) {
echo 'تم الدفع بنجاح!';
} else {
echo 'الدفعة لم تكتمل بعد';
}
// الحصول على حالة الدفعة
$status = Fawaterak::getPaymentStatus($invoiceKey);
echo "حالة الدفعة: {$status}";
// الحصول على تفاصيل الدفعة كاملة
$paymentDetails = Fawaterak::getPayment($invoiceKey);
// في EventServiceProvider
use Illuminate\Support\Facades\Event;
Event::listen('fawaterak.webhook.received', function ($data) {
// معالجة عامة لجميع الـ webhooks
Log::info('Webhook received', $data);
});
Event::listen('fawaterak.payment.paid', function ($data) {
// معالجة الدفعات المكتملة
$invoiceKey = $data['invoice_key'];
// تحديث قاعدة البيانات، إرسال إيميل، إلخ
});
Event::listen('fawaterak.payment.failed', function ($data) {
// معالجة الدفعات الفاشلة
});
Event::listen('fawaterak.payment.pending', function ($data) {
// معالجة الدفعات المعلقة
});