How Webhooks works
Webhooks allow you to receive events within the PassSlot system. In combination with our REST API they allow to perform perform automation task that are not covered by our system. Examples include:
- Build custom reports
- Log customer activity
- Automate customer journeys (e.g. update fields after pass was created)
For more information about how webhook work visit:
Sample Webhook
You can use our PassSlot PHP SDK to setup a simple webhook receiver. The SDK will read the body and handle the webhook verification logic for you.
<?php
require_once('src/PassSlot.php');
$appKey ='<YOUR APP KEY>';
try {
$event = PassSlotWebhookReceiver::read();
if ($event->type == "pass.created") {
try {
$pass = $event->data; // data of pass.created event is compatible with $pass (has serialNumber & passTypeIdentifier)
$engine = PassSlot::start($appKey);
$passValues = $engine->getPassValues($pass);
echo "Serial Number: " . $data->serialNumber;
echo "Template ID: " . $data->templateId;
echo "Pass Type ID: " . $data->passTypeIdentifier;
echo "Values:";
var_dump($passValues);
header('X-PHP-Response-Code: 200', true, 200);
} catch (Exception $e) {
var_dump($e);
header('X-PHP-Response-Code: 500', true, 500);
}
}
die();
} catch (Exception $e) {
header('X-PHP-Response-Code: 500', true, 500);
echo $e;
die();
}