PhonePey by Lushai Dev
Official PhonePey Gateway Documentation & API Specs

Developer API & Integration Guide

Accept fast, zero-fee UPI payments directly into your bank. Our engine verifies payments in real time. We provide ready code for PHP, Node.js, Python, and JavaScript.

1. Overview & Authentication

PhonePey provides a clean REST API. You can create orders and verify payments in real time. Authentication is fast. Pass your user_token with each request.

Base Endpoint URL
https://www.phonepey.lushai.dev/api
Authentication Methods
Pass user_token in JSON body or Bearer Token header

2. Create Order API

POST /api/create-order

Create a dynamic UPI checkout session. Buyers can scan a QR code or tap a 1-click intent button for PhonePe, Google Pay, or Paytm.

Two Checkout Options: Razorpay-Style Popup vs Hosted Redirect
1. Popup Modal (Razorpay Style - Recommended): Keep buyers on your website without leaving your page. Pass the returned token to new PhonePey({ token }).open() (see Chapter 5).
2. Hosted Redirect Page: Send buyers to the hosted PhonePey page by redirecting them to result.payment_url.

Request Parameters:

Parameter Type Requirement Description
user_token string Required Your unique merchant integration token obtained from Developer Settings.
amount string / float Required Transaction amount (e.g. "149" or 149.00). Min ₹1.00.
order_id string Required Your custom unique order identifier (e.g. "ORD_174000123").
customer_mobile string Required Customer's active 10-digit mobile number.
redirect_url string Required Destination URL where customer is redirected upon successful payment.
remark1 string Optional Internal customer name, product title, or correlation note.
remark2 string Optional Additional server-side tracking reference.
curl -X POST https://www.phonepey.lushai.dev/api/create-order \ -H "Content-Type: application/json" \ -d '{ "user_token": "YOUR_USER_TOKEN", "amount": "149.00", "order_id": "ORD_174000123", "customer_mobile": "9876543210", "redirect_url": "https://yourwebsite.com/payment-success", "remark1": "Pro Plan Subscription" }'

JSON Response (200 OK):

{ "status": true, "message": "Order created successfully", "result": { "order_id": "ORD_174000123", "payment_url": "https://www.phonepey.lushai.dev/pay?token=8c4e51...", "amount": "149.00", "token": "8c4e5192c73bb...", "upi_intent": "upi://pay?pa=store@ybl&pn=Store&am=149.00&cu=INR&tn=ORD_174000123", "qr_data": "upi://pay?pa=store@ybl&pn=Store&am=149.00&cu=INR&tn=ORD_174000123", "created_at": "2026-08-22 17:20:00" } }

3. Check Order Status API

POST /api/check-status

Check the real-time status of an order using your order_id. When paid, the engine returns the verified 12-digit UTR number.

Request Parameters:

Parameter Type Requirement Description
user_token string Required Your merchant integration token.
order_id string Required The specific unique order ID string to verify status for.
curl -X POST https://www.phonepey.lushai.dev/api/check-status \ -H "Content-Type: application/json" \ -d '{ "user_token": "YOUR_USER_TOKEN", "order_id": "ORD_174000123" }'

Verified JSON Response:

{ "status": true, "message": "Order status retrieved", "result": { "order_id": "ORD_174000123", "status": "SUCCESS", "amount": "149.00", "utr": "412398765432", "verified": true, "transaction_date": "2026-08-22 17:21:00", "remark1": "Pro Plan Subscription" } }

4. Webhooks & Instant Payment Notifications

When a customer payment succeeds, PhonePey sends an instant HTTP POST event to your Webhook URL. You can set your Webhook URL in Developer Settings:

WEBHOOK PAYLOAD (POST)
{ "event": "order.paid", "timestamp": "2026-08-22T17:21:00+05:30", "order_id": "ORD_174000123", "amount": "149.00", "utr": "412398765432", "status": "SUCCESS", "remark1": "Pro Plan Subscription" }
PHP WEBHOOK LISTENER EXAMPLE
<?php $payload = file_get_contents('php://input'); $event = json_decode($payload, true); if ($event && ($event['status'] ?? '') === 'SUCCESS') { $orderId = $event['order_id']; $utr = $event['utr']; $amount = $event['amount']; // Update your database order as PAID // fulfill_order($orderId, $utr); http_response_code(200); echo json_encode(['status' => 'acknowledged']); } else { http_response_code(400); } ?>

5. JavaScript Embed SDK (Razorpay-Style Popup Modal)

Recommended for All Websites

Integrate a seamless, in-context popup checkout modal just like Razorpay or Cashfree. Your customers complete payment directly on your page without being redirected away to an external site.

Approach 1: Direct 1-Click Drop-in (Low Code)

HTML / JAVASCRIPT (DROP-IN POPUP)
<!-- 1. Include PhonePey Drop-in SDK --> <script src="https://www.phonepey.lushai.dev/checkout.js"></script> <!-- 2. Trigger Payment Button --> <button id="pay-btn" class="btn btn-primary">Pay ₹149 with UPI</button> <script> document.getElementById('pay-btn').addEventListener('click', function () { var options = { key: "YOUR_API_TOKEN", // From PhonePey Dashboard > API Integration amount: 149.00, order_id: "ORD_" + Date.now(), name: "My Online Store", prefill: { name: "Lalmuana", contact: "9876543210", email: "customer@example.com" }, handler: function (response) { // Instant verification callback upon customer payment alert("Payment Verified! UTR: " + response.utr); window.location.href = "/payment-success?order_id=" + response.order_id + "&utr=" + response.utr; }, modal: { ondismiss: function () { console.log("Customer closed the checkout modal."); } } }; var rzp = new PhonePey(options); rzp.open(); }); </script>

Approach 2: Server-Side Order + Client-Side Popup Modal (Standard Razorpay Architecture)

Create the order securely on your server using POST /api/create-order, return the generated token to your frontend, and open the popup modal:

FRONTEND JAVASCRIPT WITH BACKEND TOKEN
<!-- 1. Include PhonePey SDK --> <script src="https://www.phonepey.lushai.dev/checkout.js"></script> <script> async function startCheckout() { // Step 1: Request token from your backend server const res = await fetch('/my-backend/create-order.php', { method: 'POST' }); const data = await res.json(); // returns { token: "8c4e51...", order_id: "ORD_..." } // Step 2: Launch in-context Razorpay-style popup modal! var rzp = new PhonePey({ token: data.token, // Token returned from PhonePey /api/create-order handler: function (response) { // Step 3: Verified UTR callback! window.location.href = "/order-confirmed?order_id=" + response.order_id + "&utr=" + response.utr; }, modal: { ondismiss: function () { console.log("Customer closed checkout popup."); } } }); rzp.open(); } </script>
Official Plugin • Razorpay-Style Popup Enabled • WooCommerce 4.0 - 9.2+

6. Official WooCommerce UPI Gateway Plugin

Connect your WooCommerce e-commerce store with PhonePey. Accept 0% fee UPI payments straight into your bank account. Features **In-Context Popup Modal (Razorpay Style)** by default, so customers never leave your website!

Download Plugin (.ZIP)
STEP 1
Instant Installation

Download the ZIP file. In your WordPress Admin, go to Plugins → Add New → Upload Plugin, choose phonepey-woocommerce.zip, click Install Now and Activate.

STEP 2
One-Key Configuration

Navigate to WooCommerce → Settings → Payments → PhonePey UPI. Enable the gateway and paste your API Key (user_token) from your PhonePey Dashboard.

STEP 3
Automated Instant Fulfillment

Copy your Webhook endpoint: https://yourdomain.com/?wc-api=phonepey_webhook and paste it into your PhonePey API Integration settings. All paid orders automatically update to Processing with UTR reference recorded!

7. Auto Payment Capture & Merchant Setup Guides

PhonePey delivers instant 0% commission direct settlement. To enable automated real-time transaction verification, complete these 2 quick setup steps:

STEP 1
Add Email in PhonePe Business App
Link your notification Gmail address inside your PhonePe Business profile
Generate Google App Password
Create a 16-character secure App Password for IMAP auto-capture

9. Interactive Live API Tester & Demo

Open Full Checkout Demo

Execute live test requests to /api/create-order directly in your browser, or visit our dedicated Live Checkout Simulator to test real-time 10–40s auto-capture:

Compatible Apps: UPI PhonePe Google Pay Paytm BharatPe
API RESPONSE AWAITING REQUEST
Click "Execute Create Order Request" above to test live endpoint...

10. HTTP Status Codes & Error Handling

PhonePey returns standard HTTP response codes alongside JSON error objects:

Code Meaning Typical Cause
200 OK Success Order created or status retrieved successfully.
401 Unauthorized Invalid Token Missing, invalid, or expired user_token.
422 Unprocessable Validation Error Missing order_id, invalid customer_mobile, or amount < ₹1.
404 Not Found Not Found Order identifier does not exist in your account.