Integrating PhonePe with your PHP-based website allows you to offer a seamless payment experience. This guide walks you through creating a payment order, redirecting the user to PhonePe, and handling the callback to confirm the transaction.
🔄 How to Integrate PhonePe Payment Gateway in PHP
Integrating PhonePe with your PHP-based website allows you to offer a seamless payment experience. This guide walks you through creating a payment order, redirecting the user to PhonePe, and handling the callback to confirm the transaction.
🛒 Step 1: Capture the Order and Redirect to Confirmation
After the customer places an order, show a confirmation page summarizing their order. Include a Submit & Pay button that, when clicked, redirects the user to checksum.php.
🧾 Step 2: Construct the Payment Payload in checksum.php
Fetch the order details and generate a unique transaction ID. Then, create the payload:
🔐 Step 3: Generate X-VERIFY Header
📡 Step 4: Send the Payment Request to PhonePe API
💳 Step 5: Redirect to PhonePe Checkout
Embed the checkout script and initiate the transaction:
🔔 Step 6: Handle the Payment Callback
After payment completion, PhonePe will send a POST request to your callback.php with transaction details.
1️⃣ Receive the Callback Data
2️⃣ Construct the X-VERIFY Header for Payment Status Check
3️⃣ Call the PhonePe Status API
4️⃣ Process the Payment Status
Store the callback and status response for logging or debugging:
Then, check the payment status:


