PHPackages                             raftarpay/raftarpay - 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. raftarpay/raftarpay

ActiveLibrary[Payment Processing](/categories/payments)

raftarpay/raftarpay
===================

A clean, Laravel-native unified API for Pakistani payment gateways — JazzCash &amp; EasyPaisa (more coming soon).

v1.0.2(1mo ago)04MITPHPPHP ^8.1

Since Jul 15Pushed 1mo agoCompare

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

READMEChangelogDependencies (6)Versions (4)Used By (0)

RaftarPay 🇵🇰⚡
=============

[](#raftarpay-)

**A clean, Laravel-native unified API for Pakistani payment gateways.**

Integrating payments in Pakistan usually means learning a different SDK, hashing scheme and callback format for every provider. RaftarPay gives you **one consistent API** for **JazzCash** and **EasyPaisa** — with the banks' official security (HMAC-SHA256 / AES-128 request signing and signature-verified callbacks) baked in.

```
use RaftarPay\Facades\Payment;

return Payment::gateway('jazzcash')->charge([
    'amount'      => 1500,              // PKR
    'reference'   => 'ORDER-1001',
    'description' => 'Premium plan',
    'return_url'  => route('checkout.callback'),
])->send();                            // redirects the customer to the bank
```

---

✨ Features
----------

[](#-features)

- ✅ **Unified API** across gateways — swap `jazzcash` ↔ `easypaisa` with one string
- ✅ **JazzCash** support (official `pp_SecureHash` HMAC-SHA256 page-redirect flow)
- ✅ **EasyPaisa** support (Easypay `merchantHashedReq` AES-128 hosted checkout)
- ✅ **Signature-verified callbacks** — tampered payloads are rejected automatically
- ✅ **Automatic transaction logging** (`raftarpay_transactions` table)
- ✅ **Events** — `PaymentCompleted` / `PaymentFailed`
- ✅ **Sandbox &amp; production** environments via one config flag
- ✅ **Extensible** — register your own gateway driver with `Payment::extend()`
- ✅ **Fully tested** (PHPUnit + Orchestra Testbench)

---

📦 Installation
--------------

[](#-installation)

```
composer require raftarpay/raftarpay
php artisan raftarpay:install
```

`raftarpay:install` publishes the config (`config/raftarpay.php`), publishes and runs the migration.

### Installing straight from GitHub (before Packagist)

[](#installing-straight-from-github-before-packagist)

Until the package is on Packagist, add the repo to your app's `composer.json`:

```
"repositories": [
    { "type": "vcs", "url": "https://github.com/alibuildz/raftarpay" }
],
```

then:

```
composer require raftarpay/raftarpay:dev-main
php artisan raftarpay:install
```

Then add your merchant credentials to `.env`:

```
RAFTARPAY_GATEWAY=jazzcash
RAFTARPAY_ENV=sandbox

# JazzCash (JazzCash Business account)
JAZZCASH_MERCHANT_ID=MC00000
JAZZCASH_PASSWORD=xxxxxxxx
JAZZCASH_INTEGRITY_SALT=xxxxxxxx

# EasyPaisa (Telenor Microfinance Bank merchant)
EASYPAISA_STORE_ID=00000
EASYPAISA_HASH_KEY=xxxxxxxxxxxxxxxx
```

> You need your **own merchant account** with each provider to accept real money. JazzCash &amp; EasyPaisa both offer **public sandboxes**, so you can test RaftarPay end-to-end before going live.

---

🚀 Usage
-------

[](#-usage)

### 1. Start a payment

[](#1-start-a-payment)

```
use RaftarPay\Facades\Payment;

$response = Payment::charge([
    'amount'         => 2500,
    'reference'      => 'ORDER-'.$order->id,
    'description'    => 'Order #'.$order->id,
    'customer_email' => $order->email,
    'customer_phone' => $order->phone,
    'return_url'     => route('payments.callback'),
], 'jazzcash');

return $response->send();   // redirect / auto-submit form to the gateway
```

### 2. Handle the callback

[](#2-handle-the-callback)

RaftarPay auto-registers callback routes at:

```
POST /raftarpay/{gateway}/callback

```

It verifies the signature, updates the transaction, and fires an event. Listen for it:

```
use RaftarPay\Events\PaymentCompleted;

Event::listen(function (PaymentCompleted $e) {
    $order = Order::where('reference', $e->response->reference)->first();
    $order?->markPaid();
});
```

Prefer to handle it yourself? Verify any request manually:

```
$result = Payment::handleCallback($request, 'jazzcash');

if ($result->isPaid()) {
    // ✅ signature valid + bank approved
}
```

### 3. `mode` — 2D vs 3D

[](#3-mode--2d-vs-3d)

Set `mode` per gateway in the config:

- `3d` *(default, recommended)* — 3D-Secure / OTP verification by the customer's bank.
- `2d` — direct charge without OTP (only if your merchant profile is approved for it).

---

🧩 Adding your own gateway
-------------------------

[](#-adding-your-own-gateway)

```
Payment::extend('mygateway', \App\Payments\MyGateway::class);
```

Any class implementing `RaftarPay\Contracts\Gateway` works.

---

🔒 Security
----------

[](#-security)

- JazzCash requests/responses are signed and verified with **HMAC-SHA256** over the integrity salt + sorted fields.
- EasyPaisa requests are **AES-128-ECB** encrypted with your Hash Key.
- Callback signatures are compared in **constant time** (`hash_equals`).
- Never commit your merchant credentials — keep them in `.env`.

---

🧪 Testing
---------

[](#-testing)

```
composer install
vendor/bin/phpunit
```

---

🤝 Contributing
--------------

[](#-contributing)

RaftarPay is open source and community-driven. Issues, new gateway drivers, docs and fixes are all welcome — open a PR.

---

💼 Built by Ali — need a Laravel dev?
------------------------------------

[](#-built-by-ali--need-a-laravel-dev)

I'm **Muhammad Ali**, a full-stack developer building web apps, payment integrations, AI tools &amp; automations for businesses worldwide.

If RaftarPay saved you time and you need custom development — payment gateways, SaaS platforms, bots, or anything Laravel — let's talk 👇

- 🔗 **LinkedIn:**
- 💚 **Hire me on Upwork:** [https://www.upwork.com/freelancers/~01a2c3edded808759c?mp\_source=share](https://www.upwork.com/freelancers/~01a2c3edded808759c?mp_source=share)

⭐ And if this package helped you, a star on the repo means a lot!

📄 License
---------

[](#-license)

MIT © Muhammad Ali ([@alibuildz](https://github.com/alibuildz) · [LinkedIn](https://www.linkedin.com/in/alibuilds/))

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance90

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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

Total

3

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4ac145cd206fd2aede314ba2bca3d766aec3902b6d6ce5ec8b91c538900d6192?d=identicon)[alibuildz](/maintainers/alibuildz)

---

Top Contributors

[![devin-ai-integration[bot]](https://avatars.githubusercontent.com/in/811515?v=4)](https://github.com/devin-ai-integration[bot] "devin-ai-integration[bot] (5 commits)")

---

Tags

laravelpaymentpayment gatewaypakistanjazzcasheasypaisa

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3365.5M359](/packages/psalm-plugin-laravel)[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k118.2M1.0k](/packages/laravel-socialite)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1346.4k29](/packages/fleetbase-core-api)[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.

5226.7k](/packages/simplestats-io-laravel-client)[spatie/laravel-health

Monitor the health of a Laravel application

89313.5M195](/packages/spatie-laravel-health)[api-platform/laravel

API Platform support for Laravel

58190.1k22](/packages/api-platform-laravel)

PHPackages © 2026

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