Laravel PhonePe

Laravel PhonePe

Latest Stable Version Total Downloads License
View Package

Laravel Phonepe

Overview: Laravel PhonePe Integration streamlines the process of integrating PhonePe payment gateway into Laravel applications. With straightforward setup steps and flexible usage options, developers can facilitate seamless payments for their users.

Installation: Install the package via Composer:

composer require dipesh79/laravel-phonepe

Add the required variables in the .env file:

PHONEPE_MERCHANT_ID="PGTESTPAYUAT"
PHONEPE_MERCHANT_USER_ID="MUID123"
PHONEPE_ENV="staging" //staging or production
PHONEPE_SALT_KEY="099eb0cd-02cf-4e2a-8aca-3e6c6aff0399"
PHONEPE_SALT_INDEX="1"
PHONEPE_CALLBACK_URL="http://localhost:8000"

Publish the vendor file for configuration:

php artisan vendor:publish --provider="Dipesh79\LaravelPhonePe\LaravelPhonePeServiceProvider"

Usage: Redirect the user to the payment page from your controller:

<?php

use Dipesh79\LaravelPhonePe\LaravelPhonePe;

// Your Controller Method
public function phonePePayment()
{
    $phonepe = new LaravelPhonePe();
    // amount, phone number, callback URL, unique merchant transaction id
    $url = $phonepe->makePayment(1000, '9999999999', 'http://localhost:8000/redirct-url', '1');
    return redirect()->away($url);
}

Check Payment Status: After Successful Payment, PhonePe will redirect to your callback URL with the transaction ID and status. You can check the payment status using the transaction ID.

<?php

use Dipesh79\LaravelPhonePe\LaravelPhonePe;
use Illuminate\Http\Request;

public function callBackAction(Request $request)
{
    $phonepe = new LaravelPhonePe();
    $response = $phonepe->getTransactionStatus($request->all());
    if($response == true){
        // Payment Success
    }
    else
    {
        // Payment Failed           
    }
}

License: MIT

Author: @Dipesh79

Support: For support, email dipeshkhanal79[at]gmail[dot]com.

This post is licensed under CC BY 4.0 by the author.