Webhook events
| Event | Receive when |
|---|---|
| Verify | When you save the webhook URL on the "External Connection" page. |
| Reservation | When the customer confirms the reservation. |
Verify Event
Webhook event object which contains a verification code.
Payload
| Name | Type | Description |
|---|---|---|
| type | String | Always "verify" |
| verify_code | String | Verification code for verifying your webhook. |
json
{
"type": "verify",
"verify_code": "9rw86YWHM5QePyV"
}Instructions for encrypting the verify_code to send back for verification.
js
import crypto from 'crypto'
router.post('/webhook', (req, res) => {
const clientSecret = configs.client_secret
const type = req.body.type
const data = req.body.data
if (type === 'verify') {
const verifyCode = data.verify_code
const signature = crypto.createHmac('SHA256', clientSecret)
.update(verifyCode)
.digest('hex')
return res.json({
verify_code: signature
})
}
// This depends on your system and should not return a status code of 200.
return res.status(400).json({
message: 'Invalid Type'
})
})Reservation Event
Webhook event object which contains a reservation information.
Payload
json
{
"type": "reservation",
"data": {
"seq_booking_no": 1,
"first_name": "John",
"last_name": "Doe",
"telephone_no": "+66123456789",
"email": "john_doe@example.com",
"note": "Lorem Ipsum",
"reserve_details": [
{
"key": "Hello",
"value": "World"
},
{
"key": "Social",
"value": [
"Instagram",
"Facebook"
]
}
],
"payment_status": "PENDING",
"user_ref": "9dd54aa9-5e9c-451f-8040-b32afecd0fc4",
"customer_lang": "th",
"details": [
{
"quantity": 1,
"start_at": "2024-10-29T04:00:00.000Z",
"end_at": "2024-10-29T05:00:00.000Z",
"booking_status": "PENDING",
"reserve_details": [
{
"key": "Hello",
"value": "World"
}
],
"shop_service_main_setting": {
"id": "d419f6cf-8486-4ab6-95d9-699e314714fa",
"name": {
"th": "Backend Development Course",
"en": "Backend Development Course"
},
"description": {
"th": "Lorem Ipsum",
"en": "Lorem Ipsum"
},
"note": {
"th": "Lorem Ipsum",
"en": "Lorem Ipsum"
}
},
"shop_service_sub_setting": {
"id": "cf06793a-d1d9-4651-a402-dec2ce516a08",
"name": {
"th": "NodeJS Zero to Hero",
"en": "NodeJS Zero to Hero"
},
"is_display_start_time": true,
"is_display_end_time": true,
"service_details": {
"th": "Lorem Ipsum",
"en": "Lorem Ipsum"
},
"reservation_notes": {
"th": "Lorem Ipsum",
"en": "Lorem Ipsum"
}
}
}
]
}
}