PHPackages                             yosefib/sadad-pgw - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. yosefib/sadad-pgw

ActiveLibrary[Payment Processing](/categories/payments)

yosefib/sadad-pgw
=================

Laravel package for SADAD payment gateway integration

v1.0.0(1y ago)31PHPPHP ^8.0

Since Apr 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/yosefibrahemali/sadad-pgw)[ Packagist](https://packagist.org/packages/yosefib/sadad-pgw)[ RSS](/packages/yosefib-sadad-pgw/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

yosefIb/sadad-pgw
=================

[](#yosefibsadad-pgw)

**Laravel package for integrating with SADAD PGW (Payment Gateway)**
This package simplifies the process of validating users, creating invoices, handling OTPs, and confirming payments using SADAD.

---

🚀 Features
----------

[](#-features)

- ✅ Validate customer identity and create invoice
- 🔐 Confirm payment using OTP
- 🔁 Resend OTP
- 📊 Check transaction status
- 🎯 Unified and formatted API responses

---

📦 Installation (Local Usage in Laravel)
---------------------------------------

[](#-installation-local-usage-in-laravel)

1. Install the package in your Laravel project:

```
composer require yosefib/sadad-pgw

```

2. Edit your Laravel project’s `composer.json` and add:

```
"repositories": [
  {
    "type": "path",
    "url": "packages/yosefib/sadad-pgw"
  }
],
"require": {
  "yosefib/sadad-pgw": "*"
}
```

3. Run:

```
composer update
```

4. Add environment variables in your `.env`:

```
SADAD_TOKEN=your_token
SADAD_BASE_URL=https://pgw-test.almadar.ly

```

5. Add this config file in `config/sadad.php`:

```
return [
    'base_url' => env('SADAD_BASE_URL'),
    'token' => env('SADAD_TOKEN'),
];
```

---

🧪 Usage Example
---------------

[](#-usage-example)

```
use YosefIb\SadadPGW\Sadad;

public function initiate(Sadad $sadad)
{
    $response = $sadad->validateCustomer(
        '0921234567',  // Customer phone number
        '1990',        // Birth year as string
        'INV-1001',    // Invoice number
        75.00,         // Amount
        7              // Service category (example: Food & Beverages)
    );

    return response()->json($response);
}
```

---

✅ Response Format
-----------------

[](#-response-format)

### Success

[](#success)

```
{
  "success": true,
  "message": "تم التحقق من هوية العميل",
  "status_code": 200,
  "data": {
    "transactionId": "TX123456",
    "merchantNo": "M-001"
  }
}
```

### Failure

[](#failure)

```
{
  "success": false,
  "message": "العميل غير مسجل في خدمة سداد",
  "status_code": 400,
  "data": {
    "statusCode": 1,
    "message": "Invalid OTP"
  }
}
```

---

🏦 Complete Payment Flow (Full Transaction Steps)
------------------------------------------------

[](#-complete-payment-flow-full-transaction-steps)

To complete a transaction using SADAD PGW:

1. **Validate the Customer and Create Invoice**
    - Call the `validateCustomer` method.
    - This sends an OTP to the customer's phone.
    - Also creates a pending transaction in SADAD.

```
$response = $sadad->validateCustomer(
    '0921234567', // Customer phone number
    1990,         // Birth year
    'INV-1001',   // Invoice number
    75.00,        // Amount
    7             // Service category (example: Food & Beverages)
);
```

2. **Pay the Invoice with OTP**
    - After the customer receives the OTP via SMS, use it to confirm payment.
    - You need the `transactionId` returned from `validateCustomer`.

```
$response = $sadad->payInvoice(
    'TransactionId_From_ValidateCustomer',
    'OTP_Code_From_SMS'
);
```

3. **Resend OTP (if needed)**
    - If the customer did not receive the OTP, you can request to resend it.

```
$response = $sadad->resendOtp(
    'TransactionId_From_ValidateCustomer'
);
```

4. **Check Transaction Status (Optional)**
    - To check if the transaction was successfully paid:

```
$response = $sadad->transactionStatus(
    'INV-1001' // Invoice number
);
```

---

### 📋 Example Flow

[](#-example-flow)

- Step 1: `validateCustomer` ➔ OTP sent to user.
- Step 2: User receives OTP ➔ enters it.
- Step 3: `payInvoice` using OTP ➔ transaction completed.

✅ Done!

---

📄 License
---------

[](#-license)

MIT © 2025 Yosef Ibrahem Ali
----------------------------

[](#mit--2025-yosef-ibrahem-ali)

🧾 Response Example for Completed Payment
----------------------------------------

[](#-response-example-for-completed-payment)

After calling `payInvoice`, a successful response may look like:

```
{
  "success": true,
  "message": "تم الدفع بنجاح",
  "status_code": 200,
  "data": {
    "result": "SD-20240430123456",
    "transactionId": "TX987654321",
    "merchantNo": "M-123456",
    "commission": 1.25,
    "total": 76.25
  }
}
```

On failure (e.g. invalid OTP):

```
{
  "success": false,
  "message": "OTP غير صحيح",
  "status_code": 400,
  "data": {
    "statusCode": 2,
    "message": "OTP غير صحيح أو منتهي"
  }
}
```

---

🗂️ Service Categories
---------------------

[](#️-service-categories)

When creating an invoice via `validateCustomer`, you must pass a category ID.
Use one of the following:

Category Name (Arabic)IDبدون تصنيف0مواد صحية5صيدليات6مواد غذائية7مقاهي ومطاعم8ملابس وأحذية9قرطاسية10إلكترونيات11صيانة وقطع غيار12خدمات سياحية13مواد بناء14خدمات تعليمية15خدمات دعائية16مواد منزلية17أثاث ومفروشات18إطارات وونشات19البيع الإلكتروني20العطور ومواد منزلية21المخابز والحلويات22البصريات والعدسات23ساعات ومجوهرات وإكسسوارات24مستلزمات الأم والطفل25ورش صيانة26مواد تنظيف27الألعاب28لحوم ودواجن29عيادات ومصحات30معامل تحاليل32الملابس التقليدية36Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance49

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

376d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/171520facf7ed5800c66c5d795ac66ce0c7ba231d88c426da92a0fd0192dc1b5?d=identicon)[yosefibrahemali](/maintainers/yosefibrahemali)

---

Top Contributors

[![yosefibrahemali](https://avatars.githubusercontent.com/u/147654832?v=4)](https://github.com/yosefibrahemali "yosefibrahemali (8 commits)")

### Embed Badge

![Health badge](/badges/yosefib-sadad-pgw/health.svg)

```
[![Health](https://phpackages.com/badges/yosefib-sadad-pgw/health.svg)](https://phpackages.com/packages/yosefib-sadad-pgw)
```

###  Alternatives

[laraveldaily/laravel-invoices

Missing invoices for Laravel

1.5k1.3M4](/packages/laraveldaily-laravel-invoices)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)[karson/mpesa-php-sdk

172.2k](/packages/karson-mpesa-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
