Skip to main content

Why Webhooks?

Get real-time notifications when payments complete, fail, or change status. Webhooks keep your system in sync without polling.

Instant Updates

Know immediately when payments complete or fail

Reliable Delivery

Automatic retries ensure you never miss events

Efficient

No need to constantly poll for status updates

Complete Information

Each webhook includes full payment details

Setup

1

Create an Endpoint

Create a route on your server to receive webhook POST requests.
2

Configure Your Webhook in Cheqpay Suite

Sign in to Cheqpay Suite, open Settings (bottom-left), then select Webhooks in the side menu. Click the cog icon to manage your webhook URL and secret. We recommend managing this yourself; alternatively, you can contact our support team if you prefer they configure it for you.
3

Verify Signatures

Always validate that webhooks come from Cheqpay (see security below).

Configure in Cheqpay Suite

Cheqpay Suite is the control platform we provide to our registered clients to manage and monitor their operations. Access is typically granted as part of the contract signing process. If you do not yet have Suite access, contact our support team at support@cheqpay.mx. They will confirm your account and guide you through the steps to get started. Once you have access:
  1. Sign in to your Cheqpay Suite session.
  2. Open Settings from the bottom-left of the sidebar.
  3. In the side menu, select Webhooks.
  4. Click the cog icon on the Webhook card to manage your webhook URL and secret.

Webhook settings in Cheqpay Suite

You can view, copy, and update your webhook URL and secret directly from Cheqpay Suite. Keep your webhook secret secure and never commit it to version control.

Webhook Events

Payment Events

Subscription Events

Webhook Format

Payment Events

Each webhook includes event details and payment information:
For SPEI payments, the paymentMethod field looks like this:
For PayCash payments, the paymentMethod field looks like this:
For CIE Cash Net payments, the paymentMethod field looks like this:
CIE references are 8 digits.

Common Fields

Handle Webhooks Properly

Requirements

Return 200 OK within 5 seconds. Process data asynchronously.
Always check authenticity before processing events.
Queue work for background processing. Don’t block the response.
Events may be sent multiple times. Make your handler idempotent.

Example Handler (Node.js)

Example Handler (Python)

Security

Verify every webhook to ensure it’s from Cheqpay.
New merchants use the enriched signature by default. Every newly created merchant has enriched webhook signatures enabled automatically. Existing merchants keep the legacy signature unless enriched signatures are enabled for their account.

How Signatures Work

Cheqpay signs webhooks using HMAC-SHA256 with specific payload fields joined by a pipe (|) delimiter, plus the full webhook JSON body as the final part. The signature is sent in the x-webhook-signature header. Including the full body ensures each delivery produces a unique signature (for example when the same amount and payment method appear on different orders), which improves reconciliation and tamper detection. For payment events, the signed fields are:
For subscription events, the signed fields are:
JSON.stringify(payload) must be the full webhook body you received (id, event, and data), stringified with standard JSON serialization.

Signature Verification (Node.js)

Signature Verification (Python)

When stringifying the payload for verification, preserve the exact JSON key order from the request body. In Node.js, JSON.stringify(req.body) after express.json() is typically enough. In Python, prefer json.dumps with compact separators so the string matches Cheqpay’s serialization as closely as possible.

Legacy Signatures

Legacy. The field-only signature below applies to existing merchants that do not have enriched webhook signatures enabled. New merchants do not use this scheme.

How Legacy Signatures Work

Cheqpay signs webhooks using HMAC-SHA256 with specific payload fields joined by a pipe (|) delimiter. The signature is sent in the x-webhook-signature header. The full webhook body is not included. For payment events, the signed fields are:
For subscription events, the signed fields are:

Legacy Signature Verification (Node.js)

Legacy Signature Verification (Python)

PAYCASH Order Status Change Example

When a PayCash deposit is reconciled, you’ll receive a status change event similar to this:

CIE Cash Net Order Status Change Example

When a CIE Cash Net deposit is reconciled, you’ll receive a status change event similar to this:
Your webhook secret is available in Cheqpay Suite under Settings → Webhooks. Keep it secure and never commit it to version control.

Handle Duplicate Events

Cheqpay uses payload hashing to prevent duplicate events, but your handler should still be idempotent:

Event-Specific Handling

Payment Captured

Payment Authorization Failed

Refund Processed

Subscription Plan Changed

Triggered when a customer changes their subscription plan. Includes complete proration details and whether the change was an upgrade or downgrade.

Payload Structure

Payload Fields

Subscription Signature Verification

Use the enriched scheme below (default for new merchants). For legacy merchants without enriched signatures, omit JSON.stringify(payload) from the signed string — see Legacy Signatures.

Example Handler

Proration can be null if the merchant used prorationBehavior: "none" when changing the plan. Always check if proration exists before accessing its properties.
Use the changeDirection field to simplify your logic. You don’t need to compare plan amounts manually.

Automatic Retries

If your endpoint is unavailable, Cheqpay retries automatically with up to 10 attempts.

Test Mode (Sandbox)

Retries every 60 minutes for up to 10 attempts.

Live Mode (Production)

1

Initial Attempt

Webhook is sent to your endpoint.
2

Retries 1-4

Every 5 minutes (at 5, 10, 15, and 20 minutes after initial attempt).
3

Retries 5-10

Every 60 minutes until max retries are exhausted.
4

Failed

After all retries are exhausted, the webhook is marked as failed.
Set up monitoring to alert you of webhook failures before all retries are exhausted.

Testing Locally

Use ngrok to test webhooks during development:
Register the ngrok URL with Cheqpay:
Now you can test webhooks with your local development server!
Remember to update to your production URL before going live.

Monitoring and Debugging

Log All Webhooks

Monitor Webhook Health

Track webhook delivery and processing:

Best Practices

Always use HTTPS endpoints for production. Cheqpay will not send webhooks to HTTP URLs in live mode.
Never skip signature verification. This protects against spoofed webhooks.
Respond within 5 seconds. Use background jobs for actual processing.
Use the webhook id to track processed events and avoid duplicate processing.
Set up alerts for webhook failures. Investigate and fix issues quickly.
Log all webhook events for debugging and audit trails.

Webhook Endpoint Requirements

HTTPS Required

Must use secure HTTPS connection in production

Public Access

Endpoint must be publicly accessible

Fast Response

Return 200 OK within 5 seconds

Signature Verification

Verify signatures on all requests

Next Steps

View Payment Orders

Learn about payment statuses

Handle Refunds

Process refund webhooks

Testing Guide

Test webhooks in sandbox

Error Handling

Handle webhook errors gracefully