Skip to content
Developers · Checkout security

Checkout security

Checkout monitoring for your cashier page. It flags chargeback and fraud risk early, and shows where customers drop off and which device, browser and UPI app converts.

Setup
One block on your server, one line in your cashier page
API key
The one your server already has. No new keys
Payments
Untouched. The script only observes the page

Using our hosted payment page? Nothing to do. Monitoring is already on.

One step

Pick your language, paste one block

Choose the language your cashier page is built in. Each block holds the whole setup: a helper for your server and the one line that prints it in your cashier page.

Paste the helper into your Express app, pass its result to your cashier view, and print it once.

Node.js · Express · EJS
// Payee Global checkout security for Express (Node 18+). Paste into your app.
// It uses the API key your server already has (PG_API_KEY) and returns "" on any problem.
async function pgCheckoutTag(origin, orderId, txnId) {
  const key = process.env.PG_API_KEY;
  if (!key) return '';
  try {
    const r = await fetch('https://api.payeeglobal.com/v2/analytics/checkout-session', {
      method: 'POST',
      headers: { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json' },
      body: JSON.stringify({ origin }),
      signal: AbortSignal.timeout(1500),
    });
    if (r.status !== 201) return '';
    const s = await r.json();
    if (!s.client_token || !s.attempt_id) return '';
    const esc = (v) => String(v).replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
    const attrs = { token: s.client_token, attempt: s.attempt_id, order: orderId, txn: txnId };
    let tag = '<script async src="https://api.payeeglobal.com/v2/analytics/sdk.js"';
    for (const [k, v] of Object.entries(attrs)) if (v != null && v !== '') tag += ` data-pg-${k}="${esc(v)}"`;
    return tag + '></script>';
  } catch {
    return '';
  }
}

// In your cashier route (https://pay.example.com = your cashier's origin):
//   res.render('cashier', { ...data, pgTag: await pgCheckoutTag('https://pay.example.com', order.id) });
// In views/cashier.ejs, once:
//   <%- pgTag %>

Paste the function into a PHP file your cashier page includes, and print it once in the page.

PHP · plain
// Payee Global checkout security for PHP 7.4+ (curl). Paste into a PHP file your cashier page includes.
// It uses the API key your server already has (PG_API_KEY) and returns '' on any problem.
function pg_checkout_tag(string $origin, $orderId = null, $txnId = null): string
{
    $key = getenv('PG_API_KEY');
    if (!$key || !function_exists('curl_init')) return '';
    try {
        $ch = curl_init('https://api.payeeglobal.com/v2/analytics/checkout-session');
        curl_setopt_array($ch, [
            CURLOPT_POST => true,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT_MS => 1500,
            CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $key, 'Content-Type: application/json'],
            CURLOPT_POSTFIELDS => json_encode(['origin' => $origin]),
        ]);
        $body = curl_exec($ch);
        if (curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 201 || !is_string($body)) return '';
        $s = json_decode($body, true);
        if (empty($s['client_token']) || empty($s['attempt_id'])) return '';
        $attrs = ['token' => $s['client_token'], 'attempt' => $s['attempt_id'], 'order' => $orderId, 'txn' => $txnId];
        $tag = '<script async src="https://api.payeeglobal.com/v2/analytics/sdk.js"';
        foreach ($attrs as $k => $v) {
            if ($v !== null && $v !== '') $tag .= ' data-pg-' . $k . '="' . htmlspecialchars((string) $v, ENT_QUOTES, 'UTF-8') . '"';
        }
        return $tag . '></script>';
    } catch (\Throwable $e) {
        return '';
    }
}

/* In your cashier page, once (https://pay.example.com = your cashier's origin):
   <?= pg_checkout_tag('https://pay.example.com', $orderId) ?>
*/

Save the class as app/Support/PgCheckout.php and print it once in your cashier Blade view.

Laravel · app/Support/PgCheckout.php · Blade
<?php
// Payee Global checkout security for Laravel. Save as app/Support/PgCheckout.php
// It uses the API key your server already has (PG_API_KEY) and returns '' on any problem.
namespace App\Support;

use Illuminate\Support\Facades\Http;

class PgCheckout
{
    public static function tag(string $origin, $orderId = null, $txnId = null): string
    {
        $key = config('services.payeeglobal.key') ?: env('PG_API_KEY'); // config: if you run config:cache
        if (!$key) return '';
        try {
            $r = Http::withToken($key)->withOptions(['timeout' => 1.5])
                ->post('https://api.payeeglobal.com/v2/analytics/checkout-session', ['origin' => $origin]);
            $s = $r->status() === 201 ? $r->json() : null;
            if (empty($s['client_token']) || empty($s['attempt_id'])) return '';
            $attrs = ['token' => $s['client_token'], 'attempt' => $s['attempt_id'], 'order' => $orderId, 'txn' => $txnId];
            $tag = '<script async src="https://api.payeeglobal.com/v2/analytics/sdk.js"';
            foreach ($attrs as $k => $v) {
                if ($v !== null && $v !== '') $tag .= ' data-pg-' . $k . '="' . e((string) $v) . '"';
            }
            return $tag . '></script>';
        } catch (\Throwable $e) {
            return '';
        }
    }
}

// In your cashier Blade view, once (https://pay.example.com = your cashier's origin):
//   {!! \App\Support\PgCheckout::tag('https://pay.example.com', $order->id) !!}

Paste the function into views.py, add its result to your cashier view's context, and print it once.

Python · Django
# Payee Global checkout security for Django. Paste into your views.py.
# It uses the API key your server already has (PG_API_KEY) and returns "" on any problem.
import json, os, urllib.request
from django.utils.html import escape
from django.utils.safestring import mark_safe

def pg_checkout_tag(origin, order_id=None, txn_id=None):
    key = os.environ.get("PG_API_KEY")
    if not key:
        return ""
    try:
        req = urllib.request.Request(
            "https://api.payeeglobal.com/v2/analytics/checkout-session", method="POST",
            data=json.dumps({"origin": origin}).encode(),
            headers={"Authorization": f"Bearer {key}", "Content-Type": "application/json"})
        with urllib.request.urlopen(req, timeout=1.5) as r:
            s = json.load(r) if r.status == 201 else {}
        if not s.get("client_token") or not s.get("attempt_id"):
            return ""
        attrs = {"token": s["client_token"], "attempt": s["attempt_id"], "order": order_id, "txn": txn_id}
        tag = '<script async src="https://api.payeeglobal.com/v2/analytics/sdk.js"'
        tag += "".join(f' data-pg-{k}="{escape(v)}"' for k, v in attrs.items() if v not in (None, ""))
        return mark_safe(tag + "></script>")
    except Exception:
        return ""

# In your cashier view (https://pay.example.com = your cashier's origin):
#   context["pg_tag"] = pg_checkout_tag("https://pay.example.com", order.id)
# In cashier.html, once:
#   {{ pg_tag }}

Paste the function into your app, register it with Jinja once, and call it once in your cashier template.

Python · Flask or FastAPI · Jinja2
# Payee Global checkout security for Flask or FastAPI (Jinja2). Paste into your app module.
# It uses the API key your server already has (PG_API_KEY) and returns "" on any problem.
import json, os, urllib.request
from markupsafe import Markup, escape

def pg_checkout_tag(origin, order_id=None, txn_id=None):
    key = os.environ.get("PG_API_KEY")
    if not key:
        return ""
    try:
        req = urllib.request.Request(
            "https://api.payeeglobal.com/v2/analytics/checkout-session", method="POST",
            data=json.dumps({"origin": origin}).encode(),
            headers={"Authorization": f"Bearer {key}", "Content-Type": "application/json"})
        with urllib.request.urlopen(req, timeout=1.5) as r:
            s = json.load(r) if r.status == 201 else {}
        if not s.get("client_token") or not s.get("attempt_id"):
            return ""
        attrs = {"token": s["client_token"], "attempt": s["attempt_id"], "order": order_id, "txn": txn_id}
        tag = '<script async src="https://api.payeeglobal.com/v2/analytics/sdk.js"'
        tag += "".join(f' data-pg-{k}="{escape(v)}"' for k, v in attrs.items() if v not in (None, ""))
        return Markup(tag + "></script>")
    except Exception:
        return ""

# Flask:    app.jinja_env.globals["pg_checkout_tag"] = pg_checkout_tag
# FastAPI:  templates.env.globals["pg_checkout_tag"] = pg_checkout_tag   (render from a plain def route)
# In cashier.html, once (https://pay.example.com = your cashier's origin):
#   {{ pg_checkout_tag("https://pay.example.com", order.id) }}

Save the class beside your controller, add its result to the model, and print it once with Thymeleaf.

Java · Spring Boot · Thymeleaf
// Payee Global checkout security for Spring Boot (Java 11+, Jackson). Save as PgCheckout.java beside your controller.
// It uses the API key your server already has (PG_API_KEY) and returns "" on any problem.
package com.example.shop; // your package

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.LinkedHashMap;
import java.util.Map;

public final class PgCheckout {
    private static final HttpClient HTTP = HttpClient.newBuilder().connectTimeout(Duration.ofMillis(1500)).build();
    private static final ObjectMapper JSON = new ObjectMapper();

    public static String tag(String origin, Object orderId, Object txnId) {
        String key = System.getenv("PG_API_KEY");
        if (key == null || key.isEmpty()) return "";
        try {
            HttpRequest req = HttpRequest.newBuilder(URI.create("https://api.payeeglobal.com/v2/analytics/checkout-session"))
                .timeout(Duration.ofMillis(1500))
                .header("Authorization", "Bearer " + key)
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(JSON.writeValueAsString(Map.of("origin", origin))))
                .build();
            HttpResponse<String> res = HTTP.send(req, HttpResponse.BodyHandlers.ofString());
            JsonNode s = res.statusCode() == 201 ? JSON.readTree(res.body()) : JSON.createObjectNode();
            String token = s.path("client_token").asText(""), attempt = s.path("attempt_id").asText("");
            if (token.isEmpty() || attempt.isEmpty()) return "";
            Map<String, Object> attrs = new LinkedHashMap<>();
            attrs.put("token", token); attrs.put("attempt", attempt); attrs.put("order", orderId); attrs.put("txn", txnId);
            StringBuilder tag = new StringBuilder("<script async src=\"https://api.payeeglobal.com/v2/analytics/sdk.js\"");
            attrs.forEach((k, v) -> {
                if (v != null && !v.toString().isEmpty()) tag.append(" data-pg-").append(k).append("=\"").append(esc(v.toString())).append('"');
            });
            return tag.append("></script>").toString();
        } catch (Exception e) {
            return "";
        }
    }

    private static String esc(String v) {
        return v.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;").replace("\"", "&quot;").replace("'", "&#39;");
    }
}

// In your cashier controller (https://pay.example.com = your cashier's origin):
//   model.addAttribute("pgTag", PgCheckout.tag("https://pay.example.com", order.getId(), null));
// In cashier.html (Thymeleaf), once:
//   <th:block th:utext="${pgTag}"></th:block>

Save the class in your web project and print it once in your cashier Razor view.

C# · ASP.NET Core · Razor
// Payee Global checkout security for ASP.NET Core (.NET 6+). Save as PgCheckout.cs in your web project.
// It uses the API key your server already has (PG_API_KEY) and returns "" on any problem.
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

public static class PgCheckout
{
    private static readonly HttpClient Http = new HttpClient { Timeout = TimeSpan.FromMilliseconds(1500) };

    public static async Task<string> TagAsync(string origin, object? orderId = null, object? txnId = null)
    {
        var key = Environment.GetEnvironmentVariable("PG_API_KEY");
        if (string.IsNullOrEmpty(key)) return "";
        try
        {
            using var req = new HttpRequestMessage(HttpMethod.Post, "https://api.payeeglobal.com/v2/analytics/checkout-session")
            {
                Content = JsonContent.Create(new { origin })
            };
            req.Headers.Authorization = new AuthenticationHeaderValue("Bearer", key);
            using var res = await Http.SendAsync(req);
            if (res.StatusCode != HttpStatusCode.Created) return "";
            using var doc = JsonDocument.Parse(await res.Content.ReadAsStringAsync());
            var token = doc.RootElement.GetProperty("client_token").GetString();
            var attempt = doc.RootElement.GetProperty("attempt_id").GetString();
            if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(attempt)) return "";
            var tag = new StringBuilder("<script async src=\"https://api.payeeglobal.com/v2/analytics/sdk.js\"");
            foreach (var (k, v) in new[] { ("token", token), ("attempt", attempt), ("order", Convert.ToString(orderId)), ("txn", Convert.ToString(txnId)) })
                if (!string.IsNullOrEmpty(v)) tag.Append($" data-pg-{k}=\"{WebUtility.HtmlEncode(v)}\"");
            return tag.Append("></script>").ToString();
        }
        catch
        {
            return "";
        }
    }
}

// In your cashier Razor view, once (https://pay.example.com = your cashier's origin):
//   @Html.Raw(await PgCheckout.TagAsync("https://pay.example.com", Model.OrderId))

Save the file in your server package, pass its result to your cashier template, and print it once.

Go · net/http · html/template
// Payee Global checkout security for Go (net/http, html/template). Save as pgcheckout.go in your server package.
// It uses the API key your server already has (PG_API_KEY) and returns "" on any problem.
package main

import (
	"bytes"
	"encoding/json"
	"html"
	"html/template"
	"net/http"
	"os"
	"time"
)

var pgHTTP = &http.Client{Timeout: 1500 * time.Millisecond}

func pgCheckoutTag(origin, orderID, txnID string) template.HTML {
	key := os.Getenv("PG_API_KEY")
	if key == "" {
		return ""
	}
	body, _ := json.Marshal(map[string]string{"origin": origin})
	req, err := http.NewRequest("POST", "https://api.payeeglobal.com/v2/analytics/checkout-session", bytes.NewReader(body))
	if err != nil {
		return ""
	}
	req.Header.Set("Authorization", "Bearer "+key)
	req.Header.Set("Content-Type", "application/json")
	res, err := pgHTTP.Do(req)
	if err != nil {
		return ""
	}
	defer res.Body.Close()
	var s struct {
		ClientToken string `json:"client_token"`
		AttemptID   string `json:"attempt_id"`
	}
	if res.StatusCode != 201 || json.NewDecoder(res.Body).Decode(&s) != nil || s.ClientToken == "" || s.AttemptID == "" {
		return ""
	}
	tag := `<script async src="https://api.payeeglobal.com/v2/analytics/sdk.js"`
	for _, a := range [][2]string{{"token", s.ClientToken}, {"attempt", s.AttemptID}, {"order", orderID}, {"txn", txnID}} {
		if a[1] != "" {
			tag += ` data-pg-` + a[0] + `="` + html.EscapeString(a[1]) + `"`
		}
	}
	return template.HTML(tag + `></script>`)
}

// In your cashier handler (https://pay.example.com = your cashier's origin):
//   data["PgTag"] = pgCheckoutTag("https://pay.example.com", orderID, "")
// In cashier.html, once:
//   {{.PgTag}}

Paste the method inside ApplicationHelper and print it once in your cashier view.

Ruby · Rails · ERB
# Payee Global checkout security for Rails. Paste inside module ApplicationHelper (app/helpers/application_helper.rb).
# It uses the API key your server already has (PG_API_KEY) and returns "" on any problem.
require "net/http"
require "json"

def pg_checkout_tag(origin, order_id = nil, txn_id = nil)
  key = ENV["PG_API_KEY"].to_s
  return "" if key.empty?
  res = Timeout.timeout(1.5) do
    Net::HTTP.post(URI("https://api.payeeglobal.com/v2/analytics/checkout-session"), { origin: origin }.to_json,
                   "Authorization" => "Bearer #{key}", "Content-Type" => "application/json")
  end
  s = res.code == "201" ? JSON.parse(res.body) : {}
  return "" if s["client_token"].to_s.empty? || s["attempt_id"].to_s.empty?
  attrs = { token: s["client_token"], attempt: s["attempt_id"], order: order_id, txn: txn_id }
  out = +'<script async src="https://api.payeeglobal.com/v2/analytics/sdk.js"'
  attrs.each { |k, v| out << %( data-pg-#{k}="#{ERB::Util.html_escape(v.to_s)}") unless v.to_s.empty? }
  (out << "></script>").html_safe
rescue StandardError
  ""
end

# In your cashier view, once (https://pay.example.com = your cashier's origin):
#   <%= pg_checkout_tag("https://pay.example.com", @order.id) %>

Any backend: call the session endpoint for each checkout and print the tag with the two values it returns.

Any language · cURL and the tag
# 1. On your server, for every checkout (https://pay.example.com = your cashier's origin):
curl -sS -X POST https://api.payeeglobal.com/v2/analytics/checkout-session \
  -H "Authorization: Bearer $PG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"origin":"https://pay.example.com"}'
# Answer, HTTP 201: {"client_token":"...","attempt_id":"...","expires_at":"...","events_url":"...","sdk_url":"..."}

# 2. Print this tag once on the cashier page, with client_token and attempt_id from that answer
#    (HTML-escape each value; leave out data-pg-order or data-pg-txn when you do not have it):
# <script async src="https://api.payeeglobal.com/v2/analytics/sdk.js" data-pg-token="CLIENT_TOKEN" data-pg-attempt="ATTEMPT_ID" data-pg-order="YOUR_ORDER_ID"></script>

No developer to hand? Send us your cashier URL in your Telegram group and we will set it up with you.

  • Origin. Replace https://pay.example.com with your cashier page's origin: https, host and port, no path.
  • Order ID. Pass the same merchant_order_id you send in your pay-in request: Analytics matches each checkout to its payment by it. If the pay-in already exists when the page opens, pass its Payee Global transaction_id as the third argument.
  • Key. The helper reads your existing Payee Global API key from PG_API_KEY. If your server keeps it under another name, read it from there. The key never reaches the browser: the page gets a short-lived, write-only token.
  • If anything fails (no key, no answer within 1.5 seconds, an error answer), the helper returns an empty string and your cashier page renders exactly as before.
Then

Check it

  1. Open one checkout on your cashier page.
  2. Tap a UPI app button. The payment does not need to complete.
  3. Send us the Payee Global transaction ID of that checkout in your Telegram group. Analytics shows that checkout, and we confirm it with you.

Not showing? Open your cashier page's source: it should contain one <script async src="https://api.payeeglobal.com/v2/analytics/sdk.js" data-pg-token=…> tag. If the tag is missing, the helper returned an empty string: check that PG_API_KEY is set where your web server runs, and that the origin is exactly your cashier's.

Optional

Only if you need it

The pay-in is created after the page opens

Add one line to the callback that receives your Payee Global pay-in, so Analytics can match the checkout to it.

Cashier page · your success callback
// In your existing success callback, once the Payee Global pay-in exists:
window.PGAnalytics && PGAnalytics.setPayment({ transactionId: pgTransactionId, merchantOrderId: orderId });
Report extra checkout steps

The script records the checkout on its own. These five calls add steps only your page knows about. Any other name is ignored.

Cashier page · optional steps
// Optional: report extra steps from your cashier page (only these five names are accepted).
window.PGAnalytics && PGAnalytics.event('payment_request_started'); // before your pay-in API call
window.PGAnalytics && PGAnalytics.event('payment_options_failed');  // your pay-in request failed
window.PGAnalytics && PGAnalytics.event('qr_downloaded');           // the customer saved the QR
window.PGAnalytics && PGAnalytics.event('checkout_expired');        // your cashier timer ran out
window.PGAnalytics && PGAnalytics.event('status_poll_error');       // your status polling failed
Your page has a Content-Security-Policy

Add https://api.payeeglobal.com to your existing script-src and connect-src. The tag carries no inline script, so it needs no nonce or hash.

Content-Security-Policy · add to your existing lists
script-src  'self' https://api.payeeglobal.com;
connect-src 'self' https://api.payeeglobal.com;
App taps or the QR are not detected

The script counts a tap on any link or button whose address starts with upi:, tez:, gpay:, phonepe:, paytmmp: or paytm:, and it finds the first image, canvas or SVG whose id, class or alt text contains qr. It never reads or sends the payment link itself. If your markup differs, mark it:

Cashier page · only if taps or the QR are not detected
<!-- App buttons that are not upi:, tez:, gpay:, phonepe:, paytmmp: or paytm: links: name the app -->
<button type="button" data-pg-app="phonepe">PhonePe</button>
<!-- A QR whose id, class and alt text do not contain "qr": mark it -->
<img src="/payment-code.png" alt="Scan to pay" data-pg-qr>

data-pg-app takes gpay, phonepe, paytm or other. You can also add data-pg-qr="<CSS selector>" to the script tag itself.

Start the script yourself, with selectors

For teams that prefer to name their elements. Create the session on your server as in the Other tab, pass client_token and attempt_id to the page, and call start(). It runs once per page; button keys are gpay, phonepe, paytm and other.

Cashier page · start() with your own selectors
<!-- Load the script WITHOUT the data-pg- attributes, then start it yourself (once per page). -->
<script src="https://api.payeeglobal.com/v2/analytics/sdk.js"></script>
<script>
  window.PGAnalytics && PGAnalytics.start({
    clientToken: 'CLIENT_TOKEN',         // client_token from checkout-session, new for every checkout
    attemptId: 'ATTEMPT_ID',             // attempt_id from the same answer
    merchantOrderId: 'YOUR_ORDER_ID',
    transactionId: 'PG_TRANSACTION_ID',  // leave out until the pay-in exists
    qrSelector: '#qr',
    buttons: { gpay: '#pay-gpay', phonepe: '#pay-phonepe', paytm: '#pay-paytm', other: '#pay-other' }
  });
</script>

With a Content-Security-Policy, give this inline script your usual nonce or hash.

Send checkout events from your server instead

For teams that already record checkout events on their own backend. One event per request, with the API key your server already has; no script on the page. Not needed when you use the tag. The fields are under Reference.

Your server · checkout-events
curl -sS -X POST https://api.payeeglobal.com/v2/analytics/checkout-events \
  -H "Authorization: Bearer $PG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"event_id":"evt_7Hq2mX9pLr4K","attempt_id":"att_5Nw8cJ3vTb6Q","event_type":"app_selected","occurred_at":"2026-10-27T10:15:02Z","sequence":2,"merchant_order_id":"ORDER-1042","context":{"device":"mobile","os":"Android","os_version":"14","browser":"Chrome","browser_version":"129","app":"phonepe","method":"intent"}}'
# Answer, HTTP 202: {"accepted":true,"event_id":"evt_7Hq2mX9pLr4K","duplicate":false}
Reference

Endpoints, data and limits

All three are on https://api.payeeglobal.com. Bodies are plain JSON, not the encrypted body the payment calls use.

POST /v2/analytics/checkout-session

Creates the short-lived session for one checkout attempt. Server to server only: a request that carries a browser Origin header is refused. Call it for every checkout and every reload of the cashier page.

AuthorizationBearer <your existing API key>
Content-Typeapplication/json
originRequired. The exact https origin of your cashier page, for example https://pay.example.com: no path, query, fragment or credentials.
attempt_idOptional. 12 to 80 characters of A-Z a-z 0-9 _ -. Generated for you when left out.

The answer, HTTP 201:

HTTP 201
{
  "client_token": "<write-only token>",
  "attempt_id": "<attempt id>",
  "expires_at": "2026-10-27T12:15:00.000Z",
  "events_url": "https://api.payeeglobal.com/v2/analytics/browser-events",
  "sdk_url": "https://api.payeeglobal.com/v2/analytics/sdk.js"
}

client_token is write-only: it is bound to your merchant account, this attempt and this origin, it cannot read reports or touch payments, and it expires after 2 hours.

HTTPerror
400invalid_https_origin, invalid_attempt
401authentication_required, invalid_credentials
403server_to_server_only: the request carried a browser Origin header
429rate_limited
503telemetry_unavailable

GET /v2/analytics/sdk.js

The public script. With the attributes below it starts itself; it sets no cookies and stores nothing on the device.

data-pg-tokenRequired. client_token from the session.
data-pg-attemptRequired. attempt_id from the session.
data-pg-orderOptional. Your merchant_order_id, as sent in your pay-in request.
data-pg-txnOptional. The Payee Global transaction_id, when the pay-in exists already.
data-pg-qrOptional. A CSS selector for your QR, when it is not found on its own.

In the page: PGAnalytics.start({clientToken, attemptId, transactionId, merchantOrderId, qrSelector, buttons}), PGAnalytics.setPayment({transactionId, merchantOrderId}) and PGAnalytics.event(name). start() runs once per page: use the attributes or start(), not both.

What it sends on its own: checkout_opened; payment_options_ready once a transaction ID is known; qr_displayed when at least a quarter of the QR is visible (not proof of a scan); app_selected and intent_attempted on an app tap (not proof the app opened); page_hidden and page_returned (not proof of abandonment); page_active once a minute while visible, at most 20 times; checkout_error on a script error on the page, with no message text.

POST /v2/analytics/checkout-events

Optional, server only, with your existing API key. One event per request, at most 8 KB. The answer is HTTP 202 {"accepted": true, "event_id": "…", "duplicate": false}; an event_id sent twice is stored once.

event_idRequired. 12 to 80 characters of A-Z a-z 0-9 _ -, unique per event.
attempt_idRequired. Same format: one per checkout attempt.
event_typeRequired. checkout_opened, payment_request_started, payment_options_ready, payment_options_failed, qr_displayed, qr_downloaded, app_selected, intent_attempted, page_hidden, page_returned, page_active, checkout_error, status_poll_error or checkout_expired.
occurred_atRequired. ISO time with a zone, within the last 24 hours.
sequenceOptional. Whole number, 0 to 100000.
transaction_idOptional. The Payee Global transaction ID; one that is not yours is refused with 404 transaction_not_found.
merchant_order_idOptional. Your order ID, as sent in your pay-in request.
contextOptional. os (Android, iOS, Windows, macOS, Linux, Unknown), os_version, browser (Chrome, Safari, Edge, Firefox, Opera, Other, Unknown), browser_version, device (mobile, tablet, desktop, unknown), webview (true or false), app (gpay, phonepe, paytm, other, unknown), method (qr, intent, redirect, unknown), error_code (script, render, network, timeout, request_rejected, status_poll, other), visible_ms, http_status, cashier_version.

Errors: 400 (invalid_payload, invalid_event, invalid_time, invalid_transaction, invalid_order, invalid_sequence, invalid_context), 401, 403 server_to_server_only, 404 transaction_not_found, 429 rate_limited, 503 telemetry_unavailable.

What is kept, and for how long

Kept: the event type and time, its sequence, your order ID and the Payee Global transaction ID, the operating system and browser with their major versions, the device type, whether the page ran inside another app's browser, the UPI app and method (QR or app), an error category, and how long the page was visible.

Never kept: the full user-agent, IP addresses, page URLs, UPI payment links, bank details, PINs, names, phone numbers, emails, free text and API keys. The script sets no cookies and stores nothing on the device.

Retention: raw events are deleted 90 days after they arrive. Payment outcomes (paid, pending, failed) always come from Payee Global's payment records, never from the browser. Events with neither an order ID nor a transaction ID are not shown in Analytics.

Limits

WhatLimit
Sessions300 a minute per merchant account
Events from your server1,200 a minute per API key
Events from the page60 a minute per checkout attempt; the script queues 30, sends at most 100 per page, tries each up to 3 times with a 4-second timeout

On 429 or 503, try later with backoff; on 400, fix the event; on 401, use a new token or the correct key; on 403, check the origin. Monitoring is best effort: blockers, offline pages and abrupt closes can lose events, and none of this ever blocks, delays or retries a payment.

Questions

Ask in your Telegram group, or write to support@payeeglobal.com. The rest of the API is documented under Developers.