PHPackages                             ahmedsaoud31/larapay - 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. ahmedsaoud31/larapay

ActiveLibrary[Payment Processing](/categories/payments)

ahmedsaoud31/larapay
====================

Larapay is a free Laravel Payment Gatway package.

02PHP

Since Jun 25Pushed 2w ago1 watchersCompare

[ Source](https://github.com/ahmedsaoud31/larapay)[ Packagist](https://packagist.org/packages/ahmedsaoud31/larapay)[ RSS](/packages/ahmedsaoud31-larapay/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Larapay
=======

[](#larapay)

[![Total Downloads](https://camo.githubusercontent.com/9f58d9781758b873302c2d57519a17cea61784e48cd46eaba5605e06814a2b4d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61686d656473616f756433312f6c617261706179)](https://packagist.org/packages/ahmedsaoud31/larapay)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](https://en.wikipedia.org/wiki/MIT_License)[![PHP](https://camo.githubusercontent.com/f575af1b648be492e22e809caebece8d6ae4d5319ad769664ee7a52e1c31c939/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e302d626c7565)](https://www.php.net)[![Laravel](https://camo.githubusercontent.com/3487b9ffaf82d30fbf9e40b3f1ed3b70ef7721c6c67b86ce8379b5ecc4603776/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d25334525334431302e302d726564)](https://laravel.com)

A Laravel payment gateway package that provides a unified, fluent API for multiple payment providers in the Middle East and globally.

---

Supported Gateways
------------------

[](#supported-gateways)

GatewayRegionMode[PayTabs](https://www.paytabs.com)MENAHosted form / Direct API[PayMob](https://paymob.com)Egypt / MENAHosted checkout (unified)[Kashier](https://kashier.io)EgyptHPP redirect / Session API[Payfort (Amazon Payment Services)](https://paymentservices.amazon.com)MENAHosted checkout[PayPal](https://paypal.com)Global*(stub — not yet implemented)*---

Requirements
------------

[](#requirements)

- PHP &gt;= 8.0
- Laravel &gt;= 10.0
- Guzzle &gt;= 7.9

---

Installation
------------

[](#installation)

```
composer require ahmedsaoud31/larapay
```

Publish the config file:

```
php artisan vendor:publish --tag=larapay-config
```

Run migrations (creates the `larapay_transactions` table):

```
php artisan migrate
```

---

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

[](#configuration)

All settings live in `config/larapay.php`. Set your active gateway and mode in `.env`:

```
LARAPAY_MODE=sandbox        # sandbox or live
LARAPAY_GATEWAY=paytabs     # default gateway
LARAPAY_CURRENCY=EGP        # default currency
```

---

Gateways
--------

[](#gateways)

### PayTabs

[](#paytabs)

```
PAYTABS_PROFILE_ID=
PAYTABS_SANDBOX_SERVER_KEY=
PAYTABS_SANDBOX_CLIENT_KEY=
PAYTABS_END_POINT=https://secure-egypt.paytabs.com/
```

**Usage:**

```
$pay = Larapay::init(gateway: 'paytabs')
    ->billing(
        name: 'Ahmed Ali',
        email: 'ahmed@example.com',
        phone: '01012345678',
        address: 'Cairo, Egypt',
        city: 'Cairo',
    )
    ->cart(id: $order->id, description: 'Order #'.$order->id, amount: 500.00)
    ->pay();

if (!$pay->hasError()) {
    $pay->register();
    return redirect($pay->getRedirect());
}
echo $pay->getError();
```

**Check transaction:**

```
$check = Larapay::init(gateway: 'paytabs')
    ->set(refrance: $transaction->refrance)
    ->check();

if ($check->paymentAccepted()) {
    // mark as paid
}
```

**Refund:**

```
Larapay::init(gateway: 'paytabs')
    ->set(refrance: $transaction->refrance)
    ->cart(id: $response->cart_id, description: $response->cart_description, amount: $response->cart_amount)
    ->refund(50.00);
```

---

### PayMob

[](#paymob)

```
PAYMOB_SANDBOX_API_KEY=
PAYMOB_SANDBOX_SECRET_KEY=
PAYMOB_SANDBOX_PUBLIC_KEY=
```

**Usage:**

```
$pay = Larapay::init(gateway: 'paymob')
    ->billing(
        first_name: 'Ahmed',
        last_name: 'Ali',
        email: 'ahmed@example.com',
        phone: '+201012345678',
    )
    ->set(amount: 300)
    ->checkout();

if (!$pay->hasError()) {
    $pay->register();
    return redirect($pay->getRedirect());
}
```

---

### Kashier

[](#kashier)

Kashier supports two integration flows:

**A) HPP Redirect** — build a signed URL and redirect the user.

```
KASHIER_MID=MID-xxxx-xxx
KASHIER_SANDBOX_API_KEY=
KASHIER_SANDBOX_SECRET_KEY=
```

```
$pay = Larapay::init(gateway: 'kashier')
    ->billing(name: 'Ahmed Ali', email: 'ahmed@example.com')
    ->cart(id: $order->id, description: 'Order #'.$order->id, amount: 150.00)
    ->pay();

if (!$pay->hasError()) {
    $pay->register();
    return redirect($pay->getRedirect());
}
```

**B) Session API** — create a session server-side then show an order-review page that links to Kashier's hosted session URL.

```
$gateway = Larapay::init(gateway: 'kashier')
    ->billing(email: 'ahmed@example.com')
    ->cart(id: $order->id, description: 'Order #'.$order->id, amount: 150.00)
    ->createSession();

if ($gateway->hasError()) {
    abort(500, $gateway->getError());
}

$gateway->register();
return $gateway->getPayForm(storeName: 'My Shop');
```

**Callback verification** (in `clientCallback`):

```
$check = Larapay::init(gateway: 'kashier')
    ->check(request()->query());

if ($check->paymentAccepted()) {
    $transaction->status = 'success';
}
```

**Optional:** Restrict payment methods:

```
Larapay::init(gateway: 'kashier')->enableCard()->enableWallet()-> ...
```

---

### Payfort (Amazon Payment Services)

[](#payfort-amazon-payment-services)

```
PAYFORT_SANDBOX_ACCESS_CODE=
PAYFORT_SANDBOX_MERCHANT_ID=
PAYFORT_SANDBOX_SHA_REQUEST_PHRASE=
PAYFORT_SANDBOX_SHA_RESPONSE_PHRASE=
PAYFORT_CURRENCY=AED          # must match your APS account currency
```

**Usage:**

```
$pay = Larapay::init(gateway: 'payfort')
    ->billing(
        email: 'ahmed@example.com',
        name:  'Ahmed Ali',
        ip:    request()->ip(),
    )
    ->cart(id: $order->id, description: 'Order #'.$order->id, amount: 250.00)
    ->pay();

if (!$pay->hasError()) {
    $pay->register();
    return $pay->getPayForm();   // renders auto-submitting redirect page
}
```

The `getPayForm()` view auto-submits a hidden form to the APS hosted checkout page. After payment, APS POSTs the result back to `larapay.client-callback`.

**Check status:**

```
$check = Larapay::init(gateway: 'payfort')
    ->set(refrance: $transaction->refrance)
    ->check();
```

**Refund:**

```
Larapay::init(gateway: 'payfort')
    ->set(refrance: $transaction->fort_id, currency: 'AED')
    ->refund(50.00);
```

**Signature algorithm:**Params sorted alphabetically → concatenated as `key=value` → wrapped with SHA phrase → SHA-256 hash. Fully implemented — no manual calculation needed.

---

Callbacks
---------

[](#callbacks)

All gateways share the same callback routes. They are automatically registered by the service provider:

```
GET|POST  /larapay/{gateway}/client-callback   → clientCallback($gateway)
GET|POST  /larapay/{gateway}/server-callback   → serverCallback($gateway)

```

The `clientCallback` controller method handles each gateway's specific return format and updates the `larapay_transactions` table automatically.

---

Transaction Model
-----------------

[](#transaction-model)

All payments are recorded in `larapay_transactions`:

ColumnDescription`uid`Your internal unique reference (matches what you sent to the gateway)`gateway`Gateway name e.g. `paytabs``refrance`Gateway's transaction ID / fort\_id / tran\_ref`amount`Decimal amount`currency`ISO currency code`status``pending` → `success` / `cancelled``response`Full JSON gateway response`parent_id`Points to original transaction for refunds**Attach to any model (polymorphic):**

```
$transaction->transactionable()->associate($order)->save();
```

---

Test Routes
-----------

[](#test-routes)

The package registers these routes for quick testing:

RouteDescription`GET /larapay/test`PayTabs hosted form test`GET /larapay/paymob`PayMob checkout test`GET /larapay/kashier`Kashier HPP redirect test`GET /larapay/kashier/form`Kashier Session API + order review page`GET /larapay/payfort`Payfort hosted checkout test---

Fluent API Reference
--------------------

[](#fluent-api-reference)

All gateway instances share these chainable methods:

```
->billing(...)          // set customer details
->cart(...)             // set order id, description, amount, currency
->set(...)              // set any property (uid, refrance, currency, etc.)
->pay()                 // initiate payment (builds redirect URL or form params)
->checkout()            // PayMob unified checkout
->createSession()       // Kashier: create a payment session via API
->getPayForm()          // return Blade view (hosted form or order review)
->check()               // verify transaction status / callback signature
->checkSession()        // Kashier: poll session status via API
->refund($amount)       // initiate refund
->verifyCallback()      // Payfort: verify APS callback signature
->register()            // save pending LarapayTransaction to DB
->registerRefund($tx)   // save refund LarapayTransaction to DB
->hasError()            // bool — check if last operation failed
->getError()            // string — last error message
->hasRedirect()         // bool — check if a redirect URL was set
->getRedirect()         // string — redirect URL
->paymentAccepted()     // bool — payment was successful
->paymentCancelled()    // bool — payment failed / cancelled
->json()                // object — raw gateway response
```

---

License
-------

[](#license)

MIT — [Ahmed Aboelsaoud](mailto:ahmedsaoud31@gmail.com)

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance63

Regular maintenance activity

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4484348?v=4)[أحمد أبوالسعود](/maintainers/ahmedsaoud31)[@ahmedsaoud31](https://github.com/ahmedsaoud31)

---

Top Contributors

[![ahmedsaoud31](https://avatars.githubusercontent.com/u/4484348?v=4)](https://github.com/ahmedsaoud31 "ahmedsaoud31 (12 commits)")

### Embed Badge

![Health badge](/badges/ahmedsaoud31-larapay/health.svg)

```
[![Health](https://phpackages.com/badges/ahmedsaoud31-larapay/health.svg)](https://phpackages.com/packages/ahmedsaoud31-larapay)
```

###  Alternatives

[msilabs/bkash

bKash Payment Gateway API for Laravel Framework.

181.2k](/packages/msilabs-bkash)[binkode/laravel-paystack

A description for laravel-paystack.

112.1k](/packages/binkode-laravel-paystack)

PHPackages © 2026

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