DEV Community

Indian Modassir
Indian Modassir

Posted on

PGI - Payment Getaway Integration

PGI is a PHP library that provides ready-to-use integrations for multiple payment gateways.

Composer Installation

Installation is super-easy via Composer

composer require lazervel/pgi
Enter fullscreen mode Exit fullscreen mode

OR:

Click to Browse package

Payment Integrations

Razorpay Integration

Start accepting domestic and international payments from customers on your website using the Razorpay Payment Gateway. Razorpay has developed the Standard Checkout method and manages it. You can configure payment methods, orders, company logo and also select custom colour based on your convenience. Razorpay supports these payment methods and international currencies.

Configuration

use Lazervel\PGI\Razorpay;

require 'vendor/autoload.php';
$rzp = new Razorpay;
Enter fullscreen mode Exit fullscreen mode

Create an Order in Server

In the sample app, the index.php file contains the code for order creation using Orders API.

$rzp->order([
  'amount' => 50, // In Rupees        [required]
  'currency',     // default INR      [optional]
  'notes'         // default empty [] [optional]
]);

// Error Handling
$rzp->then(function($response) {
  print_r($response);
})->catch(function($err) {
  die($err);
});
Enter fullscreen mode Exit fullscreen mode

Verify Payment Signature

This is a mandatory step that allows you to confirm the authenticity of the details returned to the checkout for successful payments.


$orderId   = $_SESSION['razorpay_order_id'];   // Where you stored
$paymentId = $_SESSION['razorpay_payment_id']; // Where you stored
$signature = $_SESSION['razorpay_signature'];  // Where you stored

// All parameter is required
$rzp->verifySignature($orderId, $paymentId, $signature);

// Error Handling
$rzp->then(function($payment) {
  // Success payment
  print_r($payment);
})->catch(function($err) {
  // Failed payment
  die($err);
});
Enter fullscreen mode Exit fullscreen mode

License

Licensed Under MIT

Copyright (c) 2025 Indian Modassir

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

Resources

Report issue and send Pull Request in the main Lazervel repository

Top comments (0)