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

ActiveLibrary[Payment Processing](/categories/payments)

zarenta/phonepe
===============

Laravel PhonePay payment gateway

v1.0.10(1y ago)029MITPHP

Since Oct 18Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (12)Used By (0)

PhonePe Payment Gateway for Laravel
===================================

[](#phonepe-payment-gateway-for-laravel)

This package provides an easy way to integrate the PhonePe payment gateway into your Laravel application.

Features
--------

[](#features)

- Initiate payments via PhonePe.
- Check transaction statuses.
- Secure callback handling for payment notifications.

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

[](#installation)

To get your api key go to [PhonePe Official Website](https://business.phonepe.com/register?referral-code=RF2410031828387153842834)

### Step 1: Install the Package

[](#step-1-install-the-package)

Run the following command to install the package via Composer:

```
composer require zarenta/phonepe
```

### Step 2: Publish Configuration

[](#step-2-publish-configuration)

Add Service provider to `bootstrap/provider.php` file

```
PhonePe\LaravelPhonePeServiceProvider::class,
```

Publish the configuration file using the artisan command:

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

This will publish a `config/phonepe.php` file where you can set your PhonePe credentials.

### Step 3: Add CSRF Exception for Callback URL

[](#step-3-add-csrf-exception-for-callback-url)

Update `bootstrap/app.php` to exclude the callback URL from CSRF verification. Add the following middleware configuration:

```
->withMiddleware(function (Middleware $middleware) {

    $middleware->web(append: [

        \App\Http\Middleware\HandleInertiaRequests::class,

        \Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class,

    ]);

    $middleware->validateCsrfTokens(except: [

        'phonepe/callback',  // Exclude PhonePe callback route from CSRF

    ]);

})
```

### Step 4: Set Up Environment Variables

[](#step-4-set-up-environment-variables)

In your `.env` file, add the following variables with your PhonePe account details:

```
PHONEPE_MERCHANT_ID=your_merchant_id

PHONEPE_MERCHANT_USER_ID=your_merchant_user_id

PHONEPE_SALT_KEY=your_salt_key

PHONEPE_SALT_INDEX=your_salt_index

PHONEPE_CALLBACK_URL=https://yourdomain.com/phonepe/callback

PHONEPE_ENV=production # or sandbox for testing
```

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

[](#configuration)

The published configuration file `config/phonepe.php` will have the following structure:

```
return [

    'merchantId' => env('PHONEPE_MERCHANT_ID'),

    'merchantUserId' => env('PHONEPE_MERCHANT_USER_ID'),

    'saltKey' => env('PHONEPE_SALT_KEY'),

    'saltIndex' => env('PHONEPE_SALT_INDEX'),

    'callBackUrl' => env('PHONEPE_CALLBACK_URL'),

    'env' => env('PHONEPE_ENV', 'sandbox'),

];
```

Usage
-----

[](#usage)

### Initiating Payment

[](#initiating-payment)

Here's an example of how to initiate a payment using the `PhonePeGateway`:

```
use PhonePe\PhonePeGateway;

public function initiatePayment(Request $request)

{

    $phonePe = new PhonePeGateway();

    try {

        $paymentUrl = $phonePe->makePayment(

            $amount = 1000, // Amount in rupees

            $redirectUrl = 'https://yourdomain.com/payment/success',

            $merchantTransactionId = 'your_unique_transaction_id',

            $phone = '9999999999',

            $email = 'user@example.com',

            $shortName = 'Your Company',

            $message = 'Payment for Order #1234'

        );

        return redirect($paymentUrl);

    } catch (PhonePe\Exception\PhonePeException $e) {

        return response()->json(['error' => $e->getMessage()], 400);

    }

}
```

### Checking Transaction Status

[](#checking-transaction-status)

To check the transaction status, use the `getTransactionStatus` method:

```
use PhonePe\PhonePeGateway;

public function checkTransactionStatus($transactionId)

{

    $phonePe = new PhonePeGateway();

    $status = $phonePe->getTransactionStatus(\request()->all());

    if ($status) {

        return response()->json(['status' => 'Transaction successful']);

    } else {

        return response()->json(['status' => 'Transaction failed or pending']);

    }

}
```

### Handling PhonePe Callback

[](#handling-phonepe-callback)

Create a route to handle the PhonePe callback in your `routes/web.php`:

```
Route::post('/phonepe/callback', [YourPaymentController::class, 'handlePhonePeCallback']);
```

In your controller, you can write logic to handle the callback and update the transaction status accordingly.

License
-------

[](#license)

This package is open-source and licensed under the [MIT License](LICENSE).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

11

Last Release

577d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed4b143bdfc51bfe0252ef5c07575b0d620834bcf27f91853db263174e8b532e?d=identicon)[narendraraghuwanshi](/maintainers/narendraraghuwanshi)

---

Top Contributors

[![narendraraghuwanshi](https://avatars.githubusercontent.com/u/26792935?v=4)](https://github.com/narendraraghuwanshi "narendraraghuwanshi (15 commits)")

### Embed Badge

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

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

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

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