Back to Docs
Core Concept
Webhooks
Get notified when payments are received and verified.
Webhook Events
payment.receivedSent when a payment is verified and the request is forwarded.
payment.failedSent when payment verification fails.
endpoint.createdSent when a new metered endpoint is created.
Webhook Payload
webhook-payload.json
json
{
"event": "payment.received",
"timestamp": "2024-01-15T10:30:00Z",
"data": {
"endpointId": "ep_abc123",
"amount": "1.00",
"currency": "USDC",
"txHash": "0x...",
"chain": "base",
"facilitator": "cdp",
"payer": "0x..."
}
}Verifying Webhooks
Verify the webhook signature to ensure it came from EasePay:
verify-webhook.ts
typescript
import crypto from 'crypto'
function verifyWebhook(payload: string, signature: string, secret: string) {
const expected = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex')
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
)
}