PHPackages                             codersandip/laravel-multi-payment-gateway - 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. codersandip/laravel-multi-payment-gateway

ActiveLibrary[Payment Processing](/categories/payments)

codersandip/laravel-multi-payment-gateway
=========================================

A unified payment gateway wrapper for Indian-focused gateways (Razorpay, PayU, Stripe, Cashfree).

v1.0.0(2mo ago)00MITPHPPHP ^8.1

Since Feb 26Pushed 2mo agoCompare

[ Source](https://github.com/codersandip/laravel-multi-payment-gateway)[ Packagist](https://packagist.org/packages/codersandip/laravel-multi-payment-gateway)[ RSS](/packages/codersandip-laravel-multi-payment-gateway/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Multi-Payment Gateway Wrapper
=====================================

[](#laravel-multi-payment-gateway-wrapper)

A unified, production-ready payment gateway package for Indian-focused gateways (Razorpay, PayU, Stripe, Cashfree). Built specifically for Laravel 10+, implementing clean architecture, SOLID principles, and an automatic driver failover mechanism.

Features
--------

[](#features)

- **Driver-based Architecture:** Clean abstractions over multiple gateways.
- **Database Tracking:** Eloquent models log all transactions, allowing instant audit trails.
- **Failover &amp; Retries:** Automatic retries for failed requests, and fallback to secondary gateways.
- **Robust Event System:** Automatically dispatches `PaymentSuccess` and `PaymentFailed` events.
- **Async Queue Jobs:** Run payment actions in the background.
- **Auto-Reconciliation Artisan Command:** Scheduled DB cleanup for pending webhooks.
- **Extensible:** Easily register custom drivers.
- **Centralized Logging:** Dedicated channel logging for all gateway interactions.
- **Unified Standard Response:** Predictable array returns `[success, gateway, transaction_id, status, message, raw]`.
- **No Third-Party SDKs:** Powered completely by Laravel's built-in HTTP client (`Illuminate\Support\Facades\Http`).

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

[](#installation)

You can install the package via Composer:

```
composer require codersandip/laravel-multi-payment-gateway
```

Publish the configuration file and migrate the database:

```
php artisan vendor:publish --provider="Codersandip\MultiPayment\MultiPaymentServiceProvider" --tag="config"
php artisan migrate
```

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

[](#configuration)

In `config/multi-payment.php`, you can set the default driver, failover drivers, error logging channel, and the allowed retries before moving to a fallback.

```
'default' => 'razorpay',
'failovers' => ['stripe', 'cashfree'],
'retries' => [
    'attempts' => 2,
    'sleep' => 1000, // milliseconds
],
```

Usage
-----

[](#usage)

### 1. Basic Charge

[](#1-basic-charge)

```
use Codersandip\MultiPayment\Facades\MultiPayment;

$response = MultiPayment::charge([
    'amount' => 500,
    'currency' => 'INR',
    'email' => 'customer@test.com',
    'phone' => '9999999999',
]);
```

### 2. Async Background Process

[](#2-async-background-process)

If you wish to handle the request later in the background through the Laravel Queue, simply use:

```
MultiPayment::chargeAsync([
    'amount' => 500,
    'currency' => 'INR',
]);
```

### 3. Failover Execution

[](#3-failover-execution)

The manager automatically attempts the charge via the default gateway using Laravel's native `retry()` mechanism. If all retries exhaust, the manager catches the Exception and automatically shifts to the failover stack (e.g. from Razorpay directly to Stripe).

### 4. Events System

[](#4-events-system)

The package fires standard events whenever a gateway successfully completes an API execution or exhausts all retries resulting in an error.

To listen to these events, register listeners in `EventServiceProvider`:

```
use Codersandip\MultiPayment\Events\PaymentSuccess;
use Codersandip\MultiPayment\Events\PaymentFailed;

protected $listen = [
    PaymentSuccess::class => [
        SendPaymentReceipt::class,
    ],
    PaymentFailed::class => [
        AlertSupportTeam::class,
    ],
];
```

### 5. Custom Driver Extensibility

[](#5-custom-driver-extensibility)

Thanks to Laravel's Manager pattern, extending this package with any custom gateway is trivial. Inside your `AppServiceProvider` boot method:

```
use Codersandip\MultiPayment\Facades\MultiPayment;
use App\Payment\CustomGatewayDriver;

MultiPayment::extend('custom_gateway', function ($app) {
    return new CustomGatewayDriver(config('services.custom'));
});
```

Then use it instantly: `MultiPayment::driver('custom_gateway')->charge(...)`

Webhooks
--------

[](#webhooks)

We provide a built-in macro to handle webhooks asynchronously across any enabled gateway. Register this in your `routes/api.php`:

```
Route::paymentWebhooks('webhooks/payments');
```

This automatically handles verified posts to `/api/webhooks/payments/razorpay`, `.../stripe`, etc.

Database &amp; Auto Reconciliation
----------------------------------

[](#database--auto-reconciliation)

Every `charge` request securely logs an `pending` Eloquent `PaymentTransaction` before communicating with the Gateway. Once a gateway returns successfully (or fails across all failovers), the DB is synced seamlessly.

If a Sandbox Sandbox or webhooks drop instantly, you can run and schedule our artisan command to manually query the Gateways and fix all drifted `pending` payments:

```
php artisan payment:reconcile-pending --days=3
```

You can cleanly schedule this in Laravel's `Console/Kernel.php`:

```
$schedule->command('payment:reconcile-pending')->hourly();
```

Frontend / Blade Components
---------------------------

[](#frontend--blade-components)

The package natively ships with beautiful, pre-configured Blade Components targeting the official JavaScript SDK/Widgets of every supported gateway!

You can easily publish these views to customize them locally:

```
php artisan vendor:publish --tag="multi-payment-views"
```

Once a `charge` executes, pass the payload `$response` to any component in your blade file. They automatically mount the UI and redirect to your specified `$verifyUrl` upon success!

```
{{-- Stripe Elements --}}
@include('multi-payment::components.stripe', [
    'response' => $chargeResponse,
    'verifyUrl' => route('payment.verify')
])

{{-- Razorpay Checkout js Modal --}}
@include('multi-payment::components.razorpay', [
    'response' => $chargeResponse,
    'verifyUrl' => route('payment.verify'),
    'themeColor' => '#ff0000', // Optional
])

{{-- Cashfree SDK Modal --}}
@include('multi-payment::components.cashfree', [
    'response' => $chargeResponse
])

{{-- PayU Auto-Submit Form --}}
@include('multi-payment::components.payu', [
    'response' => $chargeResponse,
    'autoOpen' => true
])
```

Testing
-------

[](#testing)

The package relies on `orchestra/testbench` for Laravel container bindings. Run tests natively via PHPUnit:

```
composer require --dev orchestra/testbench phpunit/phpunit
vendor/bin/phpunit
```

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance86

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

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

76d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/156ff476b46c2fdcf56b1ea2dd94a891f78c538b1e8243774219ff08a81aa236?d=identicon)[codersandip](/maintainers/codersandip)

---

Top Contributors

[![tushar-sandip](https://avatars.githubusercontent.com/u/99278791?v=4)](https://github.com/tushar-sandip "tushar-sandip (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codersandip-laravel-multi-payment-gateway/health.svg)

```
[![Health](https://phpackages.com/badges/codersandip-laravel-multi-payment-gateway/health.svg)](https://phpackages.com/packages/codersandip-laravel-multi-payment-gateway)
```

###  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)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[asciisd/knet

Knet package is provides an expressive, fluent interface to KNet's payment services.

141.1k](/packages/asciisd-knet)

PHPackages © 2026

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