This page contains the complete Node.js implementation for handling theDocumentation Index
Fetch the complete documentation index at: https://payglocal.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
merchantCallbackURL endpoint. For a conceptual explanation of the callback flow, see Payment Response Handling.
What This Endpoint Does
PayGlocal POSTs to this endpoint after every payment — success or failure. The endpoint:- Extracts the
x-gl-tokenfrom the request body - Decodes the JWT payload to read the payment data
- Checks the
statusfield - Updates your order and redirects the customer accordingly
Implementation
Step-by-Step Breakdown
| Step | What it does |
|---|---|
| 1 — Extract token | Reads x-gl-token from POST body. Returns 400 if missing. |
| 2 — Split by dot | Splits the JWT into 3 parts. Takes index 1 — the Payload. |
| 3 — Convert base64url | Swaps - → + and _ → / to get standard Base64. |
| 4 — Decode Base64 | Converts Base64 to a UTF-8 string (raw JSON). |
| 5 — Parse JSON | Parses the string into a usable JavaScript object. |
| 6 — Extract fields | Pulls status, merchantTxnId, amount, gid from the object. |
| 7 — Handle result | SENT_FOR_CAPTURE → success. Anything else → failure. |
Decoded Payload Structure
Key Notes
Replace
updateOrderStatus and sendConfirmationEmail with your own database and email logic. These are placeholders representing actions you implement.Replace
https://your-domain.com/payment/success and https://your-domain.com/payment/failure with your actual success and failure page URLs.
