Skip to main content
This page contains the complete Node.js implementation for handling the 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:
  1. Extracts the x-gl-token from the request body
  2. Decodes the JWT payload to read the payment data
  3. Checks the status field
  4. Updates your order and redirects the customer accordingly

Implementation


Step-by-Step Breakdown


Decoded Payload Structure


Key Notes

Replace updateOrderStatus and sendConfirmationEmail with your own database and email logic. These are placeholders representing actions you implement.
SENT_FOR_CAPTURE is the only success status. Every other status — ISSUER_DECLINE, CUSTOMER_CANCELLED, ABANDONED, GENERAL_DECLINE — must be treated as a failure and redirect to your failure page.
Replace https://your-domain.com/payment/success and https://your-domain.com/payment/failure with your actual success and failure page URLs.