Setup and Handling Webhooks
Step 1: Configure Your Endpoint in Trust Swiftly
Step 2: Secure Your Endpoint with Signature Verification
// Pseudocode for verification
$secret = 'your_webhook_signing_secret';
$receivedSignature = $_SERVER['HTTP_SIGNATURE'];
$rawPayload = file_get_contents('php://input');
$computedSignature = hash_hmac('sha256', $rawPayload, $secret);
// Use a secure comparison function
if (!hash_equals($computedSignature, $receivedSignature)) {
// The request is invalid - reject it
http_response_code(403);
exit('Invalid signature.');
}
// The signature is valid - proceed to process the payloadStep 3: Understand the Webhook Payload
Key Identifiers
Event Types
Event Type
Description
Step 4: Best Practices for Reliable Handling
Acknowledge First, Process Later (Asynchronous Processing)
Handle Retries with Idempotency
Step 5: Development and Troubleshooting
Testing Locally
Troubleshooting Signature Mismatches
Manage and Test Your Webhooks

Last updated