Webhook flow
Create a webhook endpoint
Use
POST /v1/aggregators/{{aggregator_id}}/webhooks with the event types you want.Receive the event
Safepay sends events with identifying headers, the event timestamp, and a signed payload.
Headers
Safepay includes headers for event ID, event type, aggregator ID, signature, and timestamp. Always read:X-SFPY-SIGNATUREX-SFPY-TIMESTAMP
Signature verification
Safepay signs the rawpayload body with HMAC SHA-256 using timestamp + '.' + payload. Use the webhook secret you receive when creating the webhook.
Use the webhook
payload object as the body argument when computing the signature.headerFormat represents the signature format Safepay uses when building the X-SFPY-SIGNATURE header. Keep it consistent with the value you receive.Retry behavior
Safepay retries failed deliveries up to 5 attempts using exponential backoff:- Attempt 1: 1 second
- Attempt 2: 2 seconds
- Attempt 3: 4 seconds
- Attempt 4: 8 seconds
- Attempt 5: 16 seconds
Event catalog
| Event | Category | Description |
|---|---|---|
payment.created | Payments | A new payment request was created (initiated by customer). |
payment.pending_authorization | Payments | Payment is awaiting authorization (for example, Pay Later checks). |
payment.authorized | Payments | Payment has been authorized and funds are on hold. |
payment.completed | Payments | Payment has been captured or charged successfully. |
payment.settled | Payments | Payment funds have been settled to the merchant. |
payment.refunded | Payments | Payment was fully refunded. |
payment.refund_partial | Payments | Payment was partially refunded. |
payment.rejected | Payments | Payment was rejected before authorization. |
payment.failed | Payments | Payment processing failed. |
payment.reversed | Payments | Payment was reversed after completion. |
payment.voided | Payments | Payment authorization was voided. |
settlement.created | Settlements | Settlement request was created. |
settlement.processing | Settlements | Settlement is currently processing. |
settlement.completed | Settlements | Settlement completed successfully. |
settlement.failed | Settlements | Settlement failed during processing. |
settlement.on_hold | Settlements | Settlement temporarily placed on hold. |
settlement.reversed | Settlements | Settlement was reversed. |
refund.created | Refunds | Refund request was created. |
refund.completed | Refunds | Refund was successfully completed. |
refund.failed | Refunds | Refund failed during processing. |
refund.canceled | Refunds | Refund request was canceled. |
Key endpoints
| Endpoint | Purpose |
|---|---|
POST /v1/aggregators/{{aggregator_id}}/webhooks | Create a webhook. |
GET /v1/aggregators/{{aggregator_id}}/webhooks | List webhook endpoints. |
GET /v1/aggregators/{{aggregator_id}}/webhooks/{{webhook_id}} | Read a webhook endpoint. |
PUT /v1/aggregators/{{aggregator_id}}/webhooks/{{webhook_id}} | Update a webhook endpoint. |
DELETE /v1/aggregators/{{aggregator_id}}/webhooks/{{webhook_id}} | Delete a webhook endpoint. |
PUT /v1/aggregators/{{aggregator_id}}/webhooks/{{webhook_id}}/rotate | Rotate the webhook secret. |
GET /v1/aggregators/{{aggregator_id}}/webhooks/{{endpoint}}/deliveries | List webhook deliveries. |
GET /v1/aggregators/{{aggregator_id}}/webhooks/{{endpoint}}/deliveries/{{delivery}} | Read a webhook delivery. |