Receive notifications at your webhook endpoint
Receive notifications at an HTTPS webhook endpoint in your own application. After you register a webhook endpoint, the Citizen Ticket platform can push real-time data to your application when customers complete payments.
Get started
First you must prepare your own web application:
- Create a webhook endpoint handler that is able to receive JSON payloads via POST requests,
- Ensure your endpoint can be accessed via a publically accessible URL. Your server must support HTTPS and have a valid certificate,
Set up your webhook
- Sign in to your organiser account
- Go to Organiser Profile
- Select “Webhooks”
- Click “+ Add Webhook”
- Enter the Fully Qualified URL for your application’s webhook endpoint
- Click “Save”
- A unique “Signing Secret” will be generated. Keep this secret and secure. You can use the buttons to reveal it and/or copy it directly to your clipboard. Your application should use this to verify webhook notifications (see “Secure your endpoint” below)
Test your webhook
- Sign in to your organiser account
- Go to Organiser Profile
- Select “Webhooks”
- Next to a webhook, press the “Test” button to issue an immediate test event. A popup notification displays whether it is successful,
- The status of the request can also be viewed by pressing “History”. This screen shows a list of historic notifications along with delivery statuses.
Secure your endpoint
Your endpoint handler should:
- Return a 2XX HTTP status code to indicate success. Any other response code is considered a failure and will be retried,
- Return quickly - If it takes longer than a couple of seconds, it is considered a failure and will be retried. If you need longer than this, queue the notification and process it asynchronously.
- Store the shared Signing Secret securely - Do not commit it into version control. Restrict read access to it.
- Verify the cryptographic signature:
- Calculate your own signature from the body of the request given to you plus your secret knowledge of the Signing Secret as follows: Signature=base64(HMAC-SHA256(body, SigningSecret))
- Verify it matches the value passed to you in the X-Signature header
- If it does not match, discard the message. This implies the message body has been altered en-route by a third party. This may be an indication of a man-in-the-middle attack.
- Verify the timestamp given in the JSON body. We recommend you discard messages older than 5 minutes.
- Verify the id given in the JSON body. We recommend you keep track of recent UUIDs and discard duplicates to guard against replay attacks.
Replay webhook notifications
- Sign in to your organiser account
- Go to Organiser Profile
- Select “Webhooks”
- Next to a webhook, press the “History” button to open the history screen,
- Next to a historic notification, press the “Replay” button to repeat it.
Supported notifications
These are the webhook event types currently supported by the platform:
event_type | Trigger | Payload |
test | Triggers when an organiser presses “Test” in the admin UI. | A hard-coded message. |
payment.complete | Triggers when a customer completes a payment. For customers on a payment plan, this event triggers both for initial payment as well as each later installment. | Fields identifying the customer and the ticket(s) being purchased. |