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.
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>
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 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
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:
API RESPONSEAWAITING 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.