C
LitePay Docs
Merchant Login →

Integrate UPI Payments

Accept UPI payments on your website with just 3 lines of code. No Razorpay or Paytm needed.

How it works

🛒
1. Customer clicks Pay
Your website calls LitePay.open()
📱
2. QR Code appears
Customer scans with any UPI app
3. Auto-verified
SMS/Email confirms payment instantly
🔔
4. Webhook sent
Your server gets notified

EASIEST Method 1 — JavaScript Checkout (Client-Side)

Just add a script tag and a button. Works on any website — HTML, WordPress, Shopify, React, anything!

1

Add the LitePay script to your page

<!-- Add before </body> -->
<script src="https://litepay.in/checkout.js"></script>
2

Create a Pay button

<button onclick="payNow()">Pay ₹500</button>

<script>
function payNow() {
    LitePay.open({
        // Your Secret Key (from Dashboard → API Keys)
        key: "SEC_your_secret_key",

        // Payment Details
        amount: 500,
        customer_name: "Customer Name",
        customer_email: "customer@email.com",
        customer_phone: "9876543210",
        description: "Order #12345",

        // Where to redirect after payment
        callback_url: "https://yourwebsite.com/thank-you.php",

        // OR use JavaScript callbacks
        onSuccess: function(data) {
            alert("Payment Successful! Order: " + data.order_id);
        },
        onFailure: function(data) {
            alert("Payment Failed");
        }
    });
}
</script>

⚠️ Note: For production, create orders from your server (Method 2) and only pass the order_id to the frontend. Never expose the Secret Key in client-side code for high-security apps.


RECOMMENDED Method 2 — Server-Side API (PHP Example)

More secure. Create the order from your server, then pass the order_id to the frontend.

1

Create Order (Server-Side PHP)

// create-payment.php (on YOUR server)
<?php
$secret_key = "SEC_your_secret_key";

$data = [
    "amount"         => 500,
    "customer_name"  => "Rahul Kumar",
    "customer_email" => "rahul@gmail.com",
    "customer_phone" => "9876543210",
    "description"    => "Wallet Recharge"
];

$ch = curl_init("https://litepay.in/api/v1/create-order.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: application/json",
    "Authorization: Bearer " . $secret_key
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = json_decode(curl_exec($ch), true);

if ($response['success']) {
    // Redirect customer to payment page
    header("Location: " . $response['payment_url']);
}
?>
2

Receive Webhook (on YOUR server)

// webhook.php (on YOUR server) — Set this URL in LitePay Dashboard → API Keys
<?php
$payload  = file_get_contents('php://input');
$data     = json_decode($payload, true);

// Verify signature
$signature = $_SERVER['HTTP_X_GATEWAY_SIGNATURE'] ?? '';
$expected  = hash_hmac('sha256', $payload, "SEC_your_secret_key");

if ($signature === $expected) {
    // Payment confirmed!
    $order_id = $data['order_id'];
    $amount   = $data['amount'];
    $utr      = $data['utr'];

    // TODO: Update your database, approve wallet, send receipt, etc.
    
    http_response_code(200);
    echo "OK";
}
?>

API Reference

POST /api/v1/create-order.php

Creates a new payment order and returns a payment URL.

Headers

AuthorizationBearer SEC_your_secret_key
Content-Typeapplication/json

Body Parameters

amount *Payment amount in INR (e.g. 500)
customer_nameCustomer's name
customer_emailCustomer's email
customer_phoneCustomer's phone
descriptionPayment description

Response

{
    "success": true,
    "order_id": "ORD_6645A1B2C3abc1",
    "amount": 500,
    "payment_url": "https://litepay.in/pay/?order_id=ORD_6645A1B2C3abc1",
    "expires_at": "2025-05-15 08:30:00"
}
GET /api/v1/order-status.php?order_id=ORD_xxx

Check the current status of a payment order.

Response

{
    "success": true,
    "order_id": "ORD_6645A1B2C3abc1",
    "status": "success",  // pending | success | failed | expired
    "amount": 500,
    "utr": "412345678901",
    "payment_time": "2025-05-15 08:05:30"
}
WEBHOOK payment.success

Sent to your Webhook URL when a payment is successfully verified.

Payload

{
    "event": "payment.success",
    "order_id": "ORD_6645A1B2C3abc1",
    "amount": 500,
    "utr": "412345678901",
    "timestamp": 1747254900
}

Signature Verification

The header X-Gateway-Signature contains HMAC-SHA256 of the payload signed with your Secret Key. Always verify this before processing.

LitePay UPI Gateway — Powered by your own infrastructure