PHPackages                             yogeshgupta/phonepe-laravel - 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. yogeshgupta/phonepe-laravel

ActiveLibrary[Payment Processing](/categories/payments)

yogeshgupta/phonepe-laravel
===========================

Complete PhonePe Payment Gateway v2 integration for Laravel with OAuth, Webhook, Auto-Logging, Events &amp; Facade

v1.0.3(1y ago)0834↓33.3%[1 issues](https://github.com/Yogesh0610/phonepe-laravel/issues)1MITPHPPHP ^8.1

Since Apr 22Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/Yogesh0610/phonepe-laravel)[ Packagist](https://packagist.org/packages/yogeshgupta/phonepe-laravel)[ RSS](/packages/yogeshgupta-phonepe-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (5)Used By (1)

PhonePe API v2 Laravel Integration
==================================

[](#phonepe-api-v2-laravel-integration)

A Laravel package for integrating the **PhonePe API v2** payment gateway, developed by Yogesh Gupta. This is a standalone implementation designed to simplify **PhonePe payment gateway** integration in Laravel applications, supporting the **PhonePe checkout v2** API for secure and efficient transactions.

Features
--------

[](#features)

- Initiate payments using the **PhonePe API v2**.
- Verify payment status with the **PhonePe checkout v2** endpoint.
- Support for UAT and production environments.
- Token caching for efficient **PhonePe API v2** calls.
- Laravel configuration and facade for easy **Laravel PhonePe integration**.

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

[](#requirements)

- PHP &gt;= 8.1
- Laravel 9.x, 10.x, 11.x, or 12.x

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

[](#installation)

1. Install the package via Composer:

```
composer require yogeshgupta/phonepe-laravel
```

2. Publish the configuration file:

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

This will create a `config/phonepe.php` file in your Laravel project.

3. Add your PhonePe credentials to your `.env` file:

```
PHONEPE_ENV=uat
PHONEPE_UAT_CLIENT_ID=SU2504041946024365502022
PHONEPE_UAT_CLIENT_VERSION=1
PHONEPE_UAT_CLIENT_SECRET=ae83cba2-07c0-43a9-b0c4-1d84c261fd12
PHONEPE_PROD_CLIENT_ID=your_prod_client_id
PHONEPE_PROD_CLIENT_VERSION=your_prod_client_version
PHONEPE_PROD_CLIENT_SECRET=your_prod_client_secret
PHONEPE_REDIRECT_URL=https://your-app.com/phonepe/process
```

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

[](#configuration)

The configuration file (`config/phonepe.php`) allows you to customize:

- Environment (`uat` or `prod`)
- Client ID, version, and secret for both environments
- Token cache path
- Redirect URL after **PhonePe API v2** payment

Example configuration:

```
return [
    'environment' => env('PHONEPE_ENV', 'uat'),
    'uat' => [
        'client_id' => env('PHONEPE_UAT_CLIENT_ID', 'SU2504041946024365502022'),
        'client_version' => env('PHONEPE_UAT_CLIENT_VERSION', 1),
        'client_secret' => env('PHONEPE_UAT_CLIENT_SECRET', 'ae83cba2-07c0-43a9-b0c4-1d84c261fd12'),
        'base_url' => 'https://api-preprod.phonepe.com/apis/pg-sandbox',
        'auth_url' => 'https://api-preprod.phonepe.com/apis/pg-sandbox',
        'token_cache_path' => storage_path('app/phonepe/phonepe_token_uat.json'),
    ],
    'prod' => [
        // ...
    ],
];
```

Usage
-----

[](#usage)

### Initiating a Payment

[](#initiating-a-payment)

```
use YogeshGupta\PhonePe\Facades\PhonePe;

$result = PhonePe::initiatePayment(10000, 'SUB123'); // Amount in paisa, subscription ID

if ($result['success']) {
    return redirect($result['redirectUrl']);
} else {
    \Log::error('Payment initiation failed: ' . $result['error']);
    return back()->withErrors(['error' => $result['error']]);
}
```

### Verifying Payment Status

[](#verifying-payment-status)

```
use YogeshGupta\PhonePe\Facades\PhonePe;

$result = PhonePe::verifyPhonePePayment('merchantOrderId123');

if ($result['success']) {
    \Log::info('Payment status: ' . json_encode($result['data']));
    return response()->json($result['data']);
} else {
    \Log::error('Payment verification failed: ' . $result['error']);
    return response()->json(['error' => $result['error']], 400);
}
```

### Example Controller

[](#example-controller)

```
namespace App\Http\Controllers;

use YogeshGupta\PhonePe\Facades\PhonePe;
use Illuminate\Http\Request;

class PaymentController extends Controller
{
    public function initiate(Request $request)
    {
        $amount = $request->input('amount'); // Amount in paisa
        $subscriptionId = $request->input('subscription_id');

        $result = PhonePe::initiatePayment($amount, $subscriptionId);

        if ($result['success']) {
            return redirect($result['redirectUrl']);
        }

        return back()->withErrors(['error' => $result['error']]);
    }

    public function verify(Request $request)
    {
        $merchantOrderId = $request->input('merchantOrderId');
        $result = PhonePe::verifyPhonePePayment($merchantOrderId);

        if ($result['success']) {
            \Log::info('Payment status: ' . json_encode($result['data']));
            return response()->json($result['data']);
        }

        \Log::error('Verification failed: ' . $result['error']);
        return response()->json(['error' => $result['error']], 400);
    }
}
```

Testing
-------

[](#testing)

To run tests (if included):

```
vendor/bin/phpunit vendor/yogeshgupta/phonepe-laravel/tests
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please follow these steps:

1. Fork the repository.
2. Create a feature branch (`git checkout -b feature/your-feature`).
3. Commit your changes (`git commit -m 'Add your feature'`).
4. Push to the branch (`git push origin feature/your-feature`).
5. Open a pull request.

Issues
------

[](#issues)

Report bugs or suggest features by opening an issue on the GitHub repository.

License
-------

[](#license)

This **Laravel PhonePe integration** package is licensed under the MIT License.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance61

Regular maintenance activity

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

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

4

Last Release

386d ago

PHP version history (2 changes)v1.0.0PHP ^8.0

v1.0.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/55f7cb204eb19067038de7e9e1bcbfebba1f63a46ee2eccdb4191545a8fa7877?d=identicon)[Yogesh0610](/maintainers/Yogesh0610)

---

Top Contributors

[![Yogesh0610](https://avatars.githubusercontent.com/u/86668869?v=4)](https://github.com/Yogesh0610 "Yogesh0610 (13 commits)")

### Embed Badge

![Health badge](/badges/yogeshgupta-phonepe-laravel/health.svg)

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

###  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)[karson/mpesa-php-sdk

172.2k](/packages/karson-mpesa-php-sdk)

PHPackages © 2026

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