PHPackages                             elfarmawy/laravel-fawaterk - 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. [API Development](/categories/api)
4. /
5. elfarmawy/laravel-fawaterk

ActiveLibrary[API Development](/categories/api)

elfarmawy/laravel-fawaterk
==========================

Production-ready Laravel SDK for the Fawaterak payment gateway

v1.1.0(1w ago)52↓100%1[1 PRs](https://github.com/TarekHesham/laravel-fawaterk/pulls)MITPHPPHP ^8.2CI passing

Since May 21Pushed 1w ago1 watchersCompare

[ Source](https://github.com/TarekHesham/laravel-fawaterk)[ Packagist](https://packagist.org/packages/elfarmawy/laravel-fawaterk)[ Docs](https://github.com/elfarmawy/laravel-fawaterk)[ RSS](/packages/elfarmawy-laravel-fawaterk/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (7)Versions (3)Used By (0)

Laravel Fawaterk
================

[](#laravel-fawaterk)

 [![Laravel Fawaterk](https://camo.githubusercontent.com/6c8f9e60b3033366ca9a03952eac0ed47bf19fd78a8bec3fa29fcd2ad8d85a28/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c253230466177617465726b2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d656c6661726d6177792532466c61726176656c2d666177617465726b267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d4d6f6465726e2b4c61726176656c2b53444b2b666f722b7468652b466177617465726b2b7061796d656e742b67617465776179266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d3930707826696d616765733d6372656469742d63617264)](https://camo.githubusercontent.com/6c8f9e60b3033366ca9a03952eac0ed47bf19fd78a8bec3fa29fcd2ad8d85a28/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c253230466177617465726b2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d656c6661726d6177792532466c61726176656c2d666177617465726b267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d4d6f6465726e2b4c61726176656c2b53444b2b666f722b7468652b466177617465726b2b7061796d656e742b67617465776179266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d3930707826696d616765733d6372656469742d63617264)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b599d1f129bf5e78641ecbe5c794c0153ce5b4631fb9f59d53d838e9bcc05732/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c6661726d6177792f6c61726176656c2d666177617465726b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elfarmawy/laravel-fawaterk)[![Total Downloads](https://camo.githubusercontent.com/8f94703ca9d3a48af75648f2fc067a684aefcc40591cfb4c56824ce61dbe7cfb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656c6661726d6177792f6c61726176656c2d666177617465726b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elfarmawy/laravel-fawaterk)[![Tests](https://camo.githubusercontent.com/2d82a60178c2fa5c261f6c5671fa649e17ad076087e04505b1483710e6855910/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f546172656b48657368616d2f6c61726176656c2d666177617465726b2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265)](https://github.com/TarekHesham/laravel-fawaterk/actions)[![PHP Version](https://camo.githubusercontent.com/5799106723e51f34fb92f8c42def80e58ed84ae2904f094ca2d145a6b5004143/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f656c6661726d6177792f6c61726176656c2d666177617465726b3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elfarmawy/laravel-fawaterk)[![Software License](https://camo.githubusercontent.com/fce25225184c8cc4ba12c068934e0a30b28b628b982391dad53697d7f9c26307/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f656c6661726d6177792f6c61726176656c2d666177617465726b3f7374796c653d666c61742d737175617265)](LICENSE.md)

 **A modern, strongly-typed Laravel SDK for the Fawaterk payment gateway.**

Built with DTOs, Enums, Fluent Builders, Tokenization Support, Secure Webhooks, and a developer-first architecture.

---

Introduction
============

[](#introduction)

Laravel Fawaterk is a modern Laravel SDK designed to simplify integration with the Fawaterk payment gateway while maintaining a clean and strongly-typed developer experience.

Unlike traditional payment wrappers that rely heavily on arrays and undocumented payloads, this package provides:

- Strongly-typed DTOs
- Immutable request &amp; response objects
- Enum-driven APIs
- Fluent builders
- IDE-friendly autocompletion
- Secure webhook verification
- Laravel-native architecture
- SOLID &amp; DDD-inspired design

The package is intentionally designed to feel natural inside Laravel applications while remaining framework-friendly and easy to extend.

---

Features
========

[](#features)

- Invoice creation and payment verification
- Seamless integration for Cards, Installments, Mobile Wallets, Meeza, Fawry, Aman, and Basata.
- Payment methods retrieval
- Card tokenization support
- Typed DTO request &amp; response objects
- Fluent request builders
- Secure HMAC webhook verification
- Immutable readonly objects
- Clean architecture
- Laravel Facade support
- PHPStan-friendly
- Pest testing support
- Laravel 10, 11, 12, and 13 support

---

Table of Contents
=================

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Quick Start](#quick-start)
- [Invoices](#invoices)

    - [Create Invoice](#create-invoice)
    - [Get Invoice Data](#get-invoice-data)
    - [Verify Paid Invoice](#verify-paid-invoice)
- [Gateway Operations](#gateway-operations)

    - [Get Payment Methods](#get-payment-methods)
    - [Initialize Payment](#initialize-payment)
- [Tokenization](#tokenization)

    - [Create Token Screen](#create-token-screen)
    - [Pay With Token](#pay-with-token)
    - [Delete Token](#delete-token)
- [Webhooks](#webhooks)
- [Error Handling](#error-handling)
- [Testing](#testing)
- [Architecture](#architecture)
- [Security](#security)
- [Contributing](#contributing)
- [Changelog](#changelog)
- [License](#license)

---

Requirements
============

[](#requirements)

DependencyVersionPHP8.2+Laravel10.x, 11.x, 12.x, 13.x---

Installation
============

[](#installation)

You can install the package via Composer:

```
composer require elfarmawy/laravel-fawaterk
```

Laravel will automatically register the service provider and facade.

---

Configuration
=============

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag="fawaterk-config"
```

Add your credentials to the `.env` file:

```
FAWATERK_API_KEY=your_api_key_here

FAWATERK_MODE=staging
```

Available modes:

- `staging`
- `production`

---

Quick Start
===========

[](#quick-start)

Create an invoice in seconds using the fluent builder API.

```
use ElFarmawy\Fawaterk\Facades\Fawaterk;
use ElFarmawy\Fawaterk\Enums\Currency;
use ElFarmawy\Fawaterk\Data\Invoices\Requests\CreateInvoiceRequest;

$response = Fawaterk::invoices()->create(
    CreateInvoiceRequest::builder()
        ->cartTotal(150)
        ->currency(Currency::EGP)
        ->customer($customer)
        ->cartItems($items)
        ->build()
);

return redirect($response->data->invoiceUrl);
```

---

Invoices
========

[](#invoices)

Create Invoice
--------------

[](#create-invoice)

```
use ElFarmawy\Fawaterk\Facades\Fawaterk;
use ElFarmawy\Fawaterk\Data\Invoices\Requests\CreateInvoiceRequest;
use ElFarmawy\Fawaterk\Data\Invoices\Shared\CustomerData;
use ElFarmawy\Fawaterk\Data\Invoices\Shared\CartItemData;
use ElFarmawy\Fawaterk\Enums\Currency;

$request = CreateInvoiceRequest::builder()
    ->cartTotal(150.50)
    ->currency(Currency::EGP)
    ->customer(
        new CustomerData(
            firstName: 'John',
            lastName: 'Doe',
            email: 'john@example.com',
            phone: '01000000000',
            address: '123 Main St'
        )
    )
    ->cartItems([
        new CartItemData(
            name: 'Product 1',
            price: 100,
            quantity: 1
        ),

        new CartItemData(
            name: 'Product 2',
            price: 50.5,
            quantity: 1
        ),
    ])
    ->build();

$response = Fawaterk::invoices()
    ->create($request);

$invoiceId = $response->data->invoiceId;

$paymentLink = $response->data->invoiceUrl;
```

---

Get Invoice Data
----------------

[](#get-invoice-data)

```
$response = Fawaterk::invoices()
    ->find($invoiceId);
```

---

Verify Paid Invoice
-------------------

[](#verify-paid-invoice)

```
$verifiedInvoice = Fawaterk::invoices()
    ->verifyPaid($invoiceId);
```

This method throws a `RequestException` if the invoice is not paid or does not exist.

---

Gateway Operations
==================

[](#gateway-operations)

Get Payment Methods
-------------------

[](#get-payment-methods)

```
$methods = Fawaterk::gateway()
    ->paymentMethods();

foreach ($methods as $method) {
    echo $method->name_en;
}
```

---

Initialize Payment
------------------

[](#initialize-payment)

```
use ElFarmawy\Fawaterk\Facades\Fawaterk;
use ElFarmawy\Fawaterk\Data\Gateway\Requests\InitPayRequest;
use ElFarmawy\Fawaterk\Enums\Currency;

$request = new InitPayRequest(
    payment_method_id: 2,
    cartTotal: 100,
    currency: Currency::EGP,
    invoice_number: 'INV-' . time(),
    customer: $customerData,
    cartItems: $cartItems,
    redirectionUrls: $redirectionUrlsData
);

$response = Fawaterk::gateway()
    ->initPay($request);
```

Depending on the selected payment method, the response will automatically resolve into one of the following DTOs:

- `InitPayRedirectResponse`
- `InitPayFawryResponse`
- `InitPayMeezaResponse`
- `InitPayBastaResponse`
- `InitPayAmanResponse`

---

Tokenization
============

[](#tokenization)

Create Token Screen
-------------------

[](#create-token-screen)

Generate a secure hosted screen for saving customer cards.

```
use ElFarmawy\Fawaterk\Data\Tokenization\Requests\CreateTokenScreenRequest;
use ElFarmawy\Fawaterk\Data\Invoices\Shared\RedirectionUrlsData;

$request = new CreateTokenScreenRequest(
    customer: $customerData,

    redirectionUrls: new RedirectionUrlsData(
        successUrl: 'https://example.com/success',
        failUrl: 'https://example.com/fail',
        pendingUrl: 'https://example.com/pending'
    )
);

$response = Fawaterk::gateway()
    ->createCardTokenScreen($request);

$url = $response->url;
```

---

Pay With Token
--------------

[](#pay-with-token)

```
use ElFarmawy\Fawaterk\Data\Tokenization\Requests\PayWithTokenRequest;

$request = new PayWithTokenRequest(
    token: 'customer_saved_token',
    cartTotal: 200,
    currency: Currency::EGP,
    customer: $customerData,
    cartItems: $cartItems
);

$response = Fawaterk::gateway()
    ->payWithToken($request);
```

---

Delete Token
------------

[](#delete-token)

```
$response = Fawaterk::gateway()
    ->deleteToken($token);
```

---

Webhooks
========

[](#webhooks)

Laravel Fawaterk provides secure webhook verification and automatic payload parsing into typed DTOs.

Supported webhook events:

- `paid`
- `failed`
- `canceled`
- `refund`

---

Example Controller
------------------

[](#example-controller)

```
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use ElFarmawy\Fawaterk\Services\FawaterkWebhookService;
use ElFarmawy\Fawaterk\Data\Webhooks\PaidWebhookData;
use ElFarmawy\Fawaterk\Enums\WebhookType;
use ElFarmawy\Fawaterk\Exceptions\WebhookSignatureVerificationException;

class FawaterkWebhookController extends Controller
{
    public function __invoke(
        Request $request,
        FawaterkWebhookService $webhookService
    ) {
        $payload = $request->all();
        $webhookType = $request->query('type') ?? $request->input('type', 'paid');

        try {

            $webhook = $webhookService->verifyAndParse(
                payload: $payload,
                webhookType: WebhookType::from($webhookType)
            );

            if ($webhook instanceof PaidWebhookData) {

                // Handle successful payment

            }

            return response()->json([
                'status' => 'success',
            ]);

        } catch (WebhookSignatureVerificationException $exception) {

            abort(403, 'Invalid webhook signature.');

        }
    }
}
```

---

Verify Signature Only
---------------------

[](#verify-signature-only)

```
$isValid = $webhookService->verifySignature(
    payload: $payload,
    signature: $signature
);
```

---

Error Handling
==============

[](#error-handling)

Laravel Fawaterk maps API responses into typed exceptions.

```
use ElFarmawy\Fawaterk\Exceptions\ApiException;
use ElFarmawy\Fawaterk\Exceptions\RequestException;
use ElFarmawy\Fawaterk\Exceptions\ValidationException;
use ElFarmawy\Fawaterk\Exceptions\AuthenticationException;

try {

    $response = Fawaterk::invoices()
        ->create($request);

} catch (ValidationException $exception) {

    $errors = $exception->errors;

} catch (AuthenticationException $exception) {

    // Invalid API credentials

} catch (RequestException $exception) {

    // Request processing error

} catch (ApiException $exception) {

    // Generic API exception

}
```

---

Testing
=======

[](#testing)

Run the test suite:

```
composer test
```

or

```
vendor/bin/pest
```

---

Architecture
============

[](#architecture)

Laravel Fawaterk follows a layered architecture focused on maintainability, testability, and developer experience.

```
Application
    ↓
Fawaterk Facade
    ↓
Services
    ↓
DTOs / Builders
    ↓
HTTP Client
    ↓
Fawaterk API

```

---

Core Principles
---------------

[](#core-principles)

### DTO-first Design

[](#dto-first-design)

Every request and response is represented using strongly-typed DTOs instead of arrays.

### Immutable Objects

[](#immutable-objects)

All DTOs are immutable and readonly where possible.

### Enum-driven APIs

[](#enum-driven-apis)

Enums are used extensively to prevent invalid payload values.

### Thin Service Layer

[](#thin-service-layer)

The package avoids unnecessary business logic and acts as a predictable SDK around the official Fawaterk API.

### Laravel-native Experience

[](#laravel-native-experience)

The SDK integrates naturally with Laravel conventions, facades, dependency injection, and the HTTP client.

---

Security
========

[](#security)

If you discover any security vulnerabilities, please report them responsibly instead of opening a public issue.

---

Contributing
============

[](#contributing)

Contributions are welcome and greatly appreciated.

Please submit a pull request or open an issue for discussion before large changes.

---

Changelog
=========

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for more information about recent changes.

---

License
=======

[](#license)

The MIT License (MIT).

Please see [LICENSE.md](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance98

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

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

Every ~8 days

Total

2

Last Release

11d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e49323ad5b272abd72b7b0b6d21a5bb68f2260c8281aa3280c10014bdea485a6?d=identicon)[Tarek Hesham](/maintainers/Tarek%20Hesham)

---

Top Contributors

[![TarekHesham](https://avatars.githubusercontent.com/u/37149220?v=4)](https://github.com/TarekHesham "TarekHesham (36 commits)")

---

Tags

apifawaterklaravellaravel-frameworkpayment-gatewaylaravelsdkpaymentApi Wrapperpayment gatewayfawaterakelfarmawy

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/elfarmawy-laravel-fawaterk/health.svg)

```
[![Health](https://phpackages.com/badges/elfarmawy-laravel-fawaterk/health.svg)](https://phpackages.com/packages/elfarmawy-laravel-fawaterk)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)[resend/resend-laravel

Resend for Laravel

1212.2M8](/packages/resend-resend-laravel)[essa/api-tool-kit

set of tools to build an api with laravel

53286.5k](/packages/essa-api-tool-kit)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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