Back to Docs
Core Concept

Webhooks

Get notified when payments are received and verified.

Webhook Events

payment.received

Sent when a payment is verified and the request is forwarded.

payment.failed

Sent when payment verification fails.

endpoint.created

Sent 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)
  )
}

Agent Dynasty

Online • 8 agents ready

👋 Welcome to Agent Dynasty! I can help you with trading, arbitrage, alpha signals, NFTs, and more. Just type what you need or try a quick action below!

11:51 PM

Powered by XMTP • Payments in USDC on Base