LearningQue Pay · Docs
Merchant login
Log in to see these examples pre-filled with your own API keys.

How it works

Your customer clicks Pay on your site → a secure LearningQue window (pay.learningque.in) shows a short loading sign and opens the payment page (UPI / cards / netbanking / wallets) → on success 95% is credited to your LearningQue wallet and 5% is kept as the gateway fee (your rate can differ; see your Wallet page). Every payment carries the note LearningQue Wallet.

Two ways to integrate: (A) Browser SDK with your public key (fastest), or (B) Server API with your secret key (recommended: amount can't be tampered with). Always confirm payment on your server using the webhook or the order status API before delivering anything.


A. Browser SDK (iframe checkout)

<script src="https://pay.learningque.in/public/sdk.js?v=1.2.0"></script>
<button id="payBtn">Pay ₹499</button>

<script>
document.getElementById("payBtn").onclick = function () {
  LearningQuePay.checkout({
    key: "lq_pk_YOUR_PUBLIC_KEY",
    amount: 499,
    orderId: "INV-" + Date.now(),          // your own reference (optional but recommended)
    customer: { name: "Rahul", email: "rahul@example.com", phone: "9876543210" },
    returnUrl: "https://yoursite.com/thanks.php",   // optional, used in redirect/popup fallbacks
    mode: "iframe",                        // "iframe" (default) | "popup" | "redirect"
    onSuccess: function (r) { console.log("paid", r.order_id); /* then confirm on your server */ },
    onFailure: function (r) { console.log("failed", r); },
    onClose:   function ()  { console.log("closed"); },
    onError:   function (e) { alert(e.message); }
  });
};
</script>

No-JS style: <button data-lq-pay data-key="lq_pk_YOUR_PUBLIC_KEY" data-amount="499" data-order-id="INV-1" data-success-url="/thanks.php">Pay</button>

Set Allowed domains for your key in the panel so only your websites can use it. Some banks refuse to load inside an iframe; use mode: "popup" or "redirect" if your customers report that.


B. PHP SDK (server side)

Download LearningQue.php

<?php
require "LearningQue.php";
$lq = new LearningQue("lq_sk_YOUR_SECRET_KEY", "https://pay.learningque.in/public");

// 1) create an order on your server, then send the customer to checkout_url (or hand it to the JS SDK)
$order = $lq->createOrder([
    "amount"         => 499,
    "order_id"       => "INV-1001",
    "customer_name"  => "Rahul",
    "customer_email" => "rahul@example.com",
    "customer_phone" => "9876543210",
    "return_url"     => "https://yoursite.com/thanks.php",
    "meta"           => ["user_id" => 42],
]);
header("Location: " . $order["checkout_url"]);

// JS SDK with a server-created order (secret key never reaches the browser):
//   LearningQuePay.checkout({ checkoutUrl: "<?= $order['checkout_url'] ?>", onSuccess: fn })
Return page (customer lands here; the query string is signed):
<?php
require "LearningQue.php";
$lq = new LearningQue("lq_sk_YOUR_SECRET_KEY", "https://pay.learningque.in/public");
if (!$lq->verifyRedirect($_GET)) die("Invalid signature");
$o = $lq->getOrder($_GET["lq_order_id"]);          // always confirm with the API
if ($o["status"] === "PAID") { /* deliver the product / credit the user */ }
Webhook receiver (set the URL in Panel → API & SDK):
<?php
require "LearningQue.php";
$lq  = new LearningQue("lq_sk_YOUR_SECRET_KEY");
$raw  = file_get_contents("php://input");
if (!$lq->verifyWebhook($raw, $_SERVER["HTTP_X_LEARNINGQUE_SIGNATURE"] ?? "")) { http_response_code(401); exit; }
$evt = json_decode($raw, true);                       // {"event":"payment.success","data":{...order...}}
if ($evt["event"] === "payment.success") {
    $order = $evt["data"];                            // order_id, merchant_order_id, amount, net_amount, ...
    // mark $order["merchant_order_id"] as paid (make it idempotent!)
}
http_response_code(200); echo "OK";                   // any 2xx = delivered, otherwise we retry

C. Wallet API / SDK

Your wallet holds the 95% share of every paid order. Read it, list the ledger and request withdrawals from your own code:

<?php
$w = $lq->wallet();                                  // ["balance"=>1234.5,"total_earned"=>..,"pending_withdrawals"=>..,"commission_percent"=>5]
$t = $lq->walletTransactions(["type" => "credit", "page" => 1, "limit" => 20]);

// withdraw to bank
$lq->withdraw(["method" => "bank", "amount" => 500, "account_name" => "Rahul Sharma", "account_number" => "123456789012", "ifsc" => "HDFC0001234"]);
// or to UPI
$lq->withdraw(["method" => "upi", "amount" => 500, "upi_id" => "rahul@okhdfcbank"]);
$list = $lq->withdrawals();

D. REST API reference

Base URL: https://pay.learningque.in/public/api/v1 · Auth header: Authorization: Bearer lq_sk_YOUR_SECRET_KEY · JSON in/out · Responses look like {"success":true,"data":{...}} or {"success":false,"error":"..."}

MethodEndpointDescription
POST/ordersamount*, order_id, customer_name, customer_email, customer_phone, return_url, meta → returns order + checkout_url
GET/orders/{id}Order by LearningQue id (LQ…) or your own order_id. Unpaid orders are re-verified live.
GET/orders?status=PAID&page=1&limit=20List orders
GET/walletBalance, total earned, pending withdrawals, your commission %
GET/wallet/transactions?type=creditWallet ledger
POST/withdrawalsRequest payout (debits wallet immediately, refunded if rejected)
GET/withdrawalsWithdrawal requests + status + UTR
POST/public/ordersUsed by the browser SDK with X-Public-Key header

curl -X POST https://pay.learningque.in/public/api/v1/orders \
  -H "Authorization: Bearer lq_sk_YOUR_SECRET_KEY" -H "Content-Type: application/json" \
  -d '{"amount": 499, "order_id": "INV-1001", "customer_phone": "9876543210"}'

curl https://pay.learningque.in/public/api/v1/wallet -H "Authorization: Bearer lq_sk_YOUR_SECRET_KEY"

Order status: CREATED (waiting) · PAID · FAILED (customer can retry) · EXPIRED (link valid for 60 minutes).
Webhook signature: X-LearningQue-Signature = HMAC_SHA256(raw_body, secret_key) (hex). Redirect signature: HMAC_SHA256(lq_order_id|status|amount, secret_key).
HTTP codes: 200/201 ok · 401 bad key · 403 not allowed · 404 not found · 409 order_id already paid · 422 validation.