Download the PHP package mahmoud-hamed/laravel-nafith without Composer
On this page you can find all versions of the php package mahmoud-hamed/laravel-nafith. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mahmoud-hamed/laravel-nafith
More information about mahmoud-hamed/laravel-nafith
Files in mahmoud-hamed/laravel-nafith
Package laravel-nafith
Short Description Laravel package for Nafith API integration, sanad creation, webhook verification, and status sync
License MIT
Homepage https://github.com/mahmoud-hamed/laravel-nafith
Informations about the package laravel-nafith
Laravel Nafith
Laravel Nafith is a Laravel package for integrating with the Nafith Electronic Promissory Note (Sanad) platform.
This Nafith Laravel package handles OAuth2 authentication, sanad creation, sanad closing, status sync, and HMAC-SHA256 webhook verification. It also provides a database-backed tracking model that works with any Eloquent model, including models that use string or UUID primary keys.
Features
- Laravel package for Nafith API integration
- Nafith sanad creation and closing workflows
- Signed webhook verification for Nafith callbacks
- Status sync command for pending and approved sanads
- Database tracking with polymorphic Eloquent relations
- Encrypted storage for sensitive debtor and payload data
Why This Package
- Speeds up Nafith integration in Laravel 11 and Laravel 12 apps
- Keeps webhook handling and signature verification in one place
- Gives you a reusable Nafith service layer instead of one-off API code
- Works well for Saudi fintech and promissory note workflows
Requirements
- PHP 8.2+
- Laravel 11.x | 12.x
- A Nafith merchant account (sandbox or production)
Installation
1. Require the package
Laravel's auto-discovery registers the service provider automatically.
2. Publish config and migration
This creates:
config/nafith.php-- all API credentials and settingsdatabase/migrations/xxxx_create_nafith_sanads_table.php-- the tracking table
3. Run the migration
4. Add environment variables
Add these to your .env:
5. Add log channels (recommended)
Add these to your config/logging.php under the 'channels' array:
Sensitive payload data is redacted from logs by default. Only enable NAFITH_LOG_SENSITIVE_DATA=true for short-lived local debugging.
Quick Start
Creating a Sanad
Closing a Sanad
Syncing Status from Nafith API
Running the Artisan Command
Scheduling the Sync Command
Add to routes/console.php:
Webhook Setup
The package automatically registers a webhook endpoint at:
Configure the URI and middleware in config/nafith.php:
Webhook Flow
- Nafith sends a POST to your webhook URL
- The package verifies the HMAC-SHA256 signature
- Parses the payload and normalizes the status
- Dispatches
NafithWebhookReceivedevent - The default listener updates the
NafithSanadrecord in the database
Listening for Webhooks
The default listener handles database updates automatically. To add custom behavior (e.g., send notifications), listen to the event:
Using the NafithSanad Model
The NafithSanad model uses a polymorphic nafithable relation, so it works with any Eloquent model.
Sensitive debtor fields and stored payload snapshots are encrypted at rest and hidden from JSON serialization by default.
Adding the Relationship to Your Model
Querying Sanads
Getting the Parent Model
Using the Low-Level API Client
If you need direct API access without the service layer:
NafithStatus Enum
Architecture
License
MIT
All versions of laravel-nafith with dependencies
php Version ^8.2
illuminate/cache Version ^11.0|^12.0
illuminate/http Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0
illuminate/database Version ^11.0|^12.0
illuminate/config Version ^11.0|^12.0
illuminate/log Version ^11.0|^12.0
illuminate/contracts Version ^11.0|^12.0
illuminate/events Version ^11.0|^12.0
illuminate/routing Version ^11.0|^12.0