PHPackages                             ayman-elmalah/laravel-myfatoorah - 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. ayman-elmalah/laravel-myfatoorah

ActiveLibrary[API Development](/categories/api)

ayman-elmalah/laravel-myfatoorah
================================

My fatoorah api wrapper

v1.0.7(3y ago)217.3k↓56.3%8[1 issues](https://github.com/ayman-elmalah/laravel-myfatoorah/issues)[1 PRs](https://github.com/ayman-elmalah/laravel-myfatoorah/pulls)MITPHPPHP ^7.4|^8.0

Since Mar 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ayman-elmalah/laravel-myfatoorah)[ Packagist](https://packagist.org/packages/ayman-elmalah/laravel-myfatoorah)[ RSS](/packages/ayman-elmalah-laravel-myfatoorah/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (3)Versions (8)Used By (0)

Laravel Myfatoorah
==================

[](#laravel-myfatoorah)

laravel myfatoorah is a php package written by [Ayman Elmalah](https://github.com/ayman-elmalah) with laravel to handle myfatoorah functionality by making it's api more easy .

Features
--------

[](#features)

- Creating invoices
- Returning payments
- Check that payment is success or not
- Change the token on the fly
- Refund invoice

Installation Guide
==================

[](#installation-guide)

Composer installation

```
composer require ayman-elmalah/laravel-myfatoorah

```

The package is compatible with laravel ^6.0|^7.0|^8.0|^9.0 so you don't need to set providers or aliases for the package, we're using laravel auto discovery

Configuration
-------------

[](#configuration)

To publish config run

```
php artisan vendor:publish --provider="AymanElmalah\MyFatoorah\MyFatoorahServiceProvider"

```

and modify the config file with your own information. File is located in `/config/myfatoorah.php`

Get Your Credentials From Myfatoorah
------------------------------------

[](#get-your-credentials-from-myfatoorah)

- Go to [My fatoorah](https://www.myfatoorah.com/)
- You will get access token
- Go to your .env file and paste your credentials to be like this
- MYFATOORAH\_MODE options \["test", "live", "live-sa"\]

```
MYFATOORAH_MODE=test
MYFATOORAH_TOKEN=token

```

or you can add it using `setAccessToken($token?)->setMode($mode?)`

You are now ready to use the package

### Test cards page

[](#test-cards-page)

You can get test cards from [DOCS](https://myfatoorah.readme.io/docs/test-cards)

### Usage examples

[](#usage-examples)

Create payment page

```
Route::get('payment', [\App\Http\Controllers\MyFatoorahController::class, 'index']);
Route::get('payment/callback', [\App\Http\Controllers\MyFatoorahController::class, 'callback']);
Route::get('payment/error', [\App\Http\Controllers\MyFatoorahController::class, 'error']);

```

At the controller, you can get the data from payment page at [DOCS](https://myfatoorah.readme.io/docs/send-payment)

```
use AymanElmalah\MyFatoorah\Facades\MyFatoorah;

public function index() {
     $data = [
       'CustomerName' => 'New user',
       'NotificationOption' => 'all',
       'MobileCountryCode' => '+966',
       'CustomerMobile' => '0000000000',
       'DisplayCurrencyIso' => 'SAR',
       'CustomerEmail' => 'test@test.test',
       'InvoiceValue' => '100',
       'Language' => 'en',
       'CallBackUrl' => 'https://yourdomain.test/callback',
       'ErrorUrl' => 'https://yourdomain.test/error',
   ];

// If you want to set the credentials and the mode manually.
//    $myfatoorah = MyFatoorah::setAccessToken($token)->setMode('test')->createInvoice($data);

// And this one if you need to access token from config
   $myfatoorah = MyFatoorah::createInvoice($data);

 // when you got a response from myFatoorah API, you can redirect the user to the myfatoorah portal
 return response()->json($myfatoorah);
}

```

Get callback to check if success payment
----------------------------------------

[](#get-callback-to-check-if-success-payment)

```
public function callback(Request $request) {
   $myfatoorah = MyFatoorah::payment($request->paymentId);

   // It will check that payment is success or not
   // return response()->json($myfatoorah->isSuccess());

   // It will return payment response with all data
   return response()->json($myfatoorah->get());
}

```

Error page
----------

[](#error-page)

```
public function error(Request $request) {
   // Show error actions
   return response()->json(['status' => 'fail']);
}

```

Refund payment

```
Route::get('reund', [\App\Http\Controllers\MyFatoorahController::class, 'refund']);

```

At the controller, you can get the data from payment page at [DOCS](https://myfatoorah.readme.io/docs/make-refund)

```
use AymanElmalah\MyFatoorah\Facades\MyFatoorah;

public function refund() {
     $data = [
       'KeyType' => 'invoiceid',     // can be invoiceId or PaymentId
       'Key' => '94272',             // key value like payment reference id, you can got it from the $request->paymentId in callback function
       'RefundChargeOnCustomer' => false,
       'ServiceChargeOnCustomer' => false,
       'Amount' => 210,
       'Comment' => 'Refund',
       'AmountDeductedFromSupplier' => 0
     ];

   // If you want to set the credentials and the mode manually.
   // $myfatoorah = MyFatoorah::setAccessToken($token)->setMode('test')->refundInvoice($data);

   // And this one if you need to access token from config
   $myfatoorah = MyFatoorah::refundInvoice($data);

   // You can check the output
   return response()->json($myfatoorah);
}

```

Authors
-------

[](#authors)

- **Ayman Elmalah** - *Initial work* - [ayman-elmalah](https://github.com/ayman-elmalah)

See also the list of [contributors](https://github.com/ayman-elmalah/laravel-myfatoorah/graphs/contributors) who participated in this project.

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

Acknowledgments
---------------

[](#acknowledgments)

- If yo have any questions, issues or PRs feel free to contact me.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~111 days

Recently: every ~165 days

Total

7

Last Release

1259d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22693197?v=4)[Ayman Elmalah](/maintainers/ayman-elmalah)[@ayman-elmalah](https://github.com/ayman-elmalah)

---

Top Contributors

[![ayman-elmalah](https://avatars.githubusercontent.com/u/22693197?v=4)](https://github.com/ayman-elmalah "ayman-elmalah (7 commits)")[![ousid](https://avatars.githubusercontent.com/u/21012933?v=4)](https://github.com/ousid "ousid (7 commits)")[![Saifallak](https://avatars.githubusercontent.com/u/6053156?v=4)](https://github.com/Saifallak "Saifallak (1 commits)")

### Embed Badge

![Health badge](/badges/ayman-elmalah-laravel-myfatoorah/health.svg)

```
[![Health](https://phpackages.com/badges/ayman-elmalah-laravel-myfatoorah/health.svg)](https://phpackages.com/packages/ayman-elmalah-laravel-myfatoorah)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.0k](/packages/simplestats-io-laravel-client)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.9k3](/packages/defstudio-telegraph)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1348.7k1](/packages/jasara-php-amzn-selling-partner-api)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)

PHPackages © 2026

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