Esenda
Hosted Checkout

Webhooks

Receive payment event notifications for hosted checkout

If a notification_url is provided in the payment request payload, Esenda will trigger a webhook:

  1. Whenever a transaction is updated (processing, accepted)
  2. When a transaction reaches a terminal state (success, failed, cancelled)

Updates for refunds and partial refunds are not sent via webhook for the Hosted Checkout. Contact your Esenda account manager or support@esenda.com if you need refund webhook support.

Esenda expects a 200 OK response. If not received, the webhook is retried up to 4 more times (5 attempts total).

Webhook Payload

{
  "created_at": "2024-01-23 14:42:19.999462",
  "data": {
    "payment_id": "2d6586da-b5ad-4417-901a-c499dbdac774",
    "payment_method": "card",
    "status": "success",
    "payment_reference": "reference",
    "request_id": "6c6b77ba-fc4a-4a18-a1d9-5b2cdc2f8cdf"
  },
  "event_type": "payment.updated",
  "id": "36bd6eea-9bad-4101-b3de-35389d348f9f",
  "shortcode": "test-school"
}

Payload Fields

FieldDescriptionExample
created_atCreated at timestamp2024-01-23 14:42:19.999462
dataObject containing the payment ID and statusSee below
data.payment_idUUID payment identifierUUID
data.payment_methodPayment method usedcard, open_banking
data.statusPayment statussuccess, failed
data.payment_referencePayment referencereference
data.request_idThe request_id from your payment requestUUID
event_typeWebhook event typepayment.updated
idUnique webhook identifier (UUID)UUID
shortcodeOrganisation shortcodetest-school

HMAC Signature Verification

All webhooks include an X-Hmac-Signature header. Use the webhook HMAC shared secret provided by Esenda with SHA-512 to verify authenticity.

Webhook Headers

Content-Type:      application/json
X-Hmac-Signature:  <hmac_signature>

Validation Example (Python)

import hashlib
import hmac
import json

secret_key = SECRET_KEY_PROVIDED_BY_ESENDA

# Serialize the webhook body to a canonical JSON string
data_json = json.dumps(webhook_message, sort_keys=True, separators=(",", ":"))

# Calculate the HMAC-SHA-512 signature
expected_signature = hmac.new(
    secret_key.encode("utf-8"), data_json.encode("utf-8"), hashlib.sha512
).hexdigest()

# Compare signatures securely
signatures_match = hmac.compare_digest(expected_signature, received_signature)

On this page