PHP code example of fayyaztech / phonepe-gateway-pg-v2
1. Go to this page and download the library: Download fayyaztech/phonepe-gateway-pg-v2 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fayyaztech / phonepe-gateway-pg-v2 example snippets
use fayyaztech\PhonePeGatewayPGV2\PhonePe;
// Initialize with environment (UAT/PROD)
$phonepe = new PhonePe(
client_id: 'YOUR_CLIENT_ID',
client_secret: 'YOUR_CLIENT_SECRET',
mode: PhonePe::MODE_UAT, // Use MODE_PROD for production
debug: true
);
// Initiate Payment
$response = $phonepe->initiatePayment(
merchantOrderId: 'ORDER' . time(),
amount: 100 * 100, // Amount in paise
redirectUrl: 'https://your-domain.com/redirect'
);
// Get payment URL
if (isset($response['orderId'])) {
$paymentUrl = $response['redirectUrl'];
// Redirect user to $paymentUrl
}