Examples#

Complete integration examples for the PayWatcher API. Each section shows the same operation in multiple languages — pick your tab and all examples on this page switch together.

Replace YOUR_API_KEY with your actual API key from the Dashboard under Settings → API Keys.

Create Payment Intent#

Create a payment intent to start accepting a USDC payment. The API returns a unique depositAddress and exactAmount for the payer.

curl -X POST https://api.masem.at/v1/payments \
-H "x-api-key: mms_paywatcher_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "amount": "49.00",
  "currency": "USDC",
  "chain": "base",
  "metadata": {
    "order_id": "ORD-123",
    "customer": "john@example.com"
  },
  "expires_in": 3600
}'

Response:

json
{
  "data": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "amount": "49.00",
    "exactAmount": "49.000042",
    "status": "pending",
    "depositAddress": "0x1a2b3c4d5e6f7890abcdef1234567890abcdef12",
    "confirmations": 0,
    "confirmationsRequired": 6,
    "txHash": null,
    "currency": "USDC",
    "chain": "base",
    "metadata": {
      "order_id": "ORD-123",
      "customer": "john@example.com"
    },
    "expiresAt": "2026-02-20T11:00:00Z",
    "createdAt": "2026-02-20T10:00:00Z",
    "updatedAt": "2026-02-20T10:00:00Z"
  }
}

Check Payment Status#

Poll the payment status or use it to verify a webhook event. The response uses camelCase field names.

curl https://api.masem.at/v1/payments/a1b2c3d4-e5f6-7890-abcd-ef1234567890 \
-H "x-api-key: mms_paywatcher_YOUR_API_KEY"

Receive & Verify Webhook#

Handle incoming webhook events and verify the HMAC-SHA256 signature. Webhook payloads use snake_case field names (e.g. exact_amount, tx_hash).

Always verify the x-paywatcher-signature header before processing events. See the Webhook Signature Verification docs for details.

# Simulate a webhook delivery for local testing
curl -X POST http://localhost:3000/webhooks/paywatcher \
-H "Content-Type: application/json" \
-H "x-paywatcher-signature: YOUR_COMPUTED_HMAC_HEX" \
-d '{
  "event": "payment.confirmed",
  "payment_id": "pay_7f2a3b4c-5d6e-7f8g-9h0i-1j2k3l4m5n6o",
  "timestamp": "2026-02-20T10:00:00Z",
  "data": {
    "amount": "49.00",
    "exact_amount": "49.000042",
    "currency": "USDC",
    "chain": "base",
    "tx_hash": "0x7a3f8b2c1d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f",
    "confirmations": 6
  }
}'

Your webhook handler should return 200 as quickly as possible. Process the event asynchronously (e.g. via a background job) to avoid timeouts and unnecessary retries.