PayPal Webhooks: Verify Signatures, Test Events, and Handle Retries

Published October 6, 2025Updated December 4, 20269 min read

PayPal webhooks are signed HTTPS POST requests sent when payments capture, subscriptions update, or disputes open. To accept one safely, verify the five paypal-* headers and raw request body either through POST /v1/notifications/verify-webhook-signature (accepting only SUCCESS) or locally via CRC32 and PayPal's X.509 certificate. Below are working Node.js implementations for both approaches, simulator caveats, and PayPal's 25-retry schedule, checked against PayPal's REST webhooks reference in December 2026.

Key takeaways

  • PayPal delivers webhooks only to HTTPS URLs on port 443 and retries up to 25 times over 3 days until your server returns a 2xx status.
  • Every delivery includes five verification headers: paypal-transmission-id, paypal-transmission-time, paypal-transmission-sig, paypal-cert-url, and paypal-auth-algo.
  • Postback verification sends those headers, your webhook_id, and the raw event JSON to /v1/notifications/verify-webhook-signature; accept only verification_status: "SUCCESS".
  • Offline verification hashes the raw body bytes as an unsigned decimal CRC32, joins transmissionId|timeStamp|webhookId|crc32, and checks paypal-transmission-sig against the certificate at paypal-cert-url.
  • Simulator mock events fail postback verification by design, so verify your signature code against real sandbox transactions.
  • Point a sandbox subscription at the Hooklistener PayPal webhook debugger to inspect every paypal-* header and raw body byte before wiring up your local server.

Register a PayPal webhook listener

Every webhook subscription lives under a REST app in the PayPal Developer Dashboard and returns a Webhook ID. Store that ID per environment because signature verification checks it on every incoming request.

  1. Open Developer Dashboard → Apps & Credentials and select your REST app (Sandbox or Live).
  2. Under Webhooks, add an HTTPS URL listening on port 443. PayPal does not deliver to plain HTTP or custom ports.
  3. Pick the exact events your integration handles, such as PAYMENT.CAPTURE.COMPLETED, CHECKOUT.ORDER.APPROVED, or BILLING.SUBSCRIPTION.CANCELLED.
  4. Copy the generated Webhook ID into your environment config.

You can also create subscriptions with the REST API:

bash
# 1. Fetch an OAuth 2.0 access token
curl -s -u "$PAYPAL_CLIENT_ID:$PAYPAL_CLIENT_SECRET" \
  -d grant_type=client_credentials \
  https://api-m.sandbox.paypal.com/v1/oauth2/token

# 2. Register the webhook subscription (response "id" is your Webhook ID)
curl -s -X POST https://api-m.sandbox.paypal.com/v1/notifications/webhooks \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/paypal/webhooks",
    "event_types": [{ "name": "PAYMENT.CAPTURE.COMPLETED" }]
  }'

Switch the host to api-m.paypal.com with live credentials for production. Sandbox and live subscriptions are separate and produce different Webhook IDs.

Send test events with the simulator vs. sandbox

PayPal offers two ways to generate test traffic: the Webhooks simulator (mock payloads) and real sandbox transactions. Use the simulator to check JSON parsing and route matching, then switch to real sandbox orders before testing signature verification, because simulated events fail verify-webhook-signature.

bash
curl -s -X POST https://api-m.sandbox.paypal.com/v1/notifications/simulate-event \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/paypal/webhooks",
    "event_type": "PAYMENT.CAPTURE.COMPLETED",
    "resource_version": "2.0"
  }'
# Pass "webhook_id" instead of "url" to target an existing subscription.

To verify signatures end to end, capture a sandbox order or trigger a sandbox subscription billing event. Pointing your sandbox subscription at a Hooklistener URL first lets you inspect the exact paypal-transmission-sig and paypal-cert-url headers PayPal sent before writing your handler.

Verify PayPal webhook signatures

Every PayPal webhook request carries five headers used for verification. If your framework parses the body as JSON before your route runs, mount a raw-body middleware (such as express.raw({ type: 'application/json' }) or await req.text() in Next.js Route Handlers) so you keep the exact bytes PayPal signed. For cross-provider raw-body rules, see our guide on webhook signing verification best practices.

HeaderPurpose
paypal-transmission-idUnique identifier for this delivery attempt
paypal-transmission-timeISO-8601 timestamp when PayPal transmitted the event
paypal-transmission-sigBase64-encoded RSA-SHA256 signature
paypal-cert-urlHTTPS URL of the X.509 certificate used to sign the payload
paypal-auth-algoSigning algorithm, expected to be SHA256withRSA

Option A: POST to verify-webhook-signature

Send the five header values, your Webhook ID, and the raw event JSON to /v1/notifications/verify-webhook-signature. PayPal returns verification_status as SUCCESS or FAILURE. Reject requests missing any header before making an API call, and splice rawBody directly rather than calling JSON.stringify(JSON.parse(rawBody)), which can alter whitespace or decimal formatting.

verify-paypal.ts
const PAYPAL_API = process.env.PAYPAL_API ?? "https://api-m.sandbox.paypal.com"; // live: https://api-m.paypal.com

function readHeader(
  headers: Record<string, string | string[] | undefined>,
  name: string,
): string {
  const value = headers[name.toLowerCase()];
  return Array.isArray(value) ? (value[0] ?? "") : (value ?? "");
}

export async function verifyWithPayPal(
  rawBody: string,
  headers: Record<string, string | string[] | undefined>,
  webhookId: string,
  accessToken: string, // from /v1/oauth2/token, cached until expiry
): Promise<boolean> {
  const authAlgo = readHeader(headers, "paypal-auth-algo");
  const certUrl = readHeader(headers, "paypal-cert-url");
  const transmissionId = readHeader(headers, "paypal-transmission-id");
  const transmissionSig = readHeader(headers, "paypal-transmission-sig");
  const transmissionTime = readHeader(headers, "paypal-transmission-time");

  if (!rawBody || !webhookId || !authAlgo || !certUrl || !transmissionId || !transmissionSig || !transmissionTime) {
    return false;
  }

  // Splice rawBody unchanged so JSON formatting matches what PayPal signed.
  const body =
    `{"auth_algo":${JSON.stringify(authAlgo)},"cert_url":${JSON.stringify(certUrl)},"transmission_id":${JSON.stringify(transmissionId)},"transmission_sig":${JSON.stringify(transmissionSig)},"transmission_time":${JSON.stringify(transmissionTime)},"webhook_id":${JSON.stringify(webhookId)},"webhook_event":${rawBody}}`;

  const res = await fetch(`${PAYPAL_API}/v1/notifications/verify-webhook-signature`, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      Authorization: `Bearer ${accessToken}`,
    },
    body,
  });
  if (!res.ok) return false;

  const data = (await res.json()) as { verification_status?: string };
  return data.verification_status === "SUCCESS";
}
  • Match the Webhook ID and API host to the event's environment (sandbox vs. live).
  • Cache the OAuth access token until expiry instead of requesting one on every webhook.
  • This approach adds one HTTP round trip to PayPal per event; high-volume endpoints usually verify offline instead.

Option B: Verify offline with CRC32 and the X.509 certificate

To verify without an API round trip per delivery, compute the unsigned CRC32 of the raw request bytes in base-10, build transmissionId|timeStamp|webhookId|crc32, and verify paypal-transmission-sig with SHA256withRSA against the certificate at paypal-cert-url. Always validate that paypal-cert-url is HTTPS on a .paypal.com subdomain so an attacker cannot supply their own certificate URL.

verify-paypal-offline.ts
import crypto from "node:crypto";
import crc32 from "buffer-crc32";

const certCache = new Map<string, string>();

function readHeader(
  headers: Record<string, string | string[] | undefined>,
  name: string,
): string {
  const value = headers[name.toLowerCase()];
  return Array.isArray(value) ? (value[0] ?? "") : (value ?? "");
}

async function getCertificate(certUrl: string): Promise<string | null> {
  let url: URL;
  try {
    url = new URL(certUrl);
  } catch {
    return null;
  }

  if (url.protocol !== "https:" || !url.hostname.endsWith(".paypal.com")) {
    return null;
  }

  if (!certCache.has(certUrl)) {
    const res = await fetch(certUrl);
    if (!res.ok) return null;
    certCache.set(certUrl, await res.text());
  }
  return certCache.get(certUrl) ?? null;
}

export async function verifyPayPalOffline(
  rawBody: Buffer, // exact bytes PayPal sent
  headers: Record<string, string | string[] | undefined>,
  webhookId: string,
): Promise<boolean> {
  const authAlgo = readHeader(headers, "paypal-auth-algo");
  const certUrl = readHeader(headers, "paypal-cert-url");
  const transmissionId = readHeader(headers, "paypal-transmission-id");
  const transmissionSig = readHeader(headers, "paypal-transmission-sig");
  const transmissionTime = readHeader(headers, "paypal-transmission-time");

  if (
    rawBody.length === 0 ||
    !webhookId ||
    authAlgo !== "SHA256withRSA" ||
    !certUrl ||
    !transmissionId ||
    !transmissionSig ||
    !transmissionTime
  ) {
    return false;
  }

  const certificate = await getCertificate(certUrl);
  if (!certificate) return false;

  const checksum = crc32.unsigned(rawBody).toString(10);
  const message = [transmissionId, transmissionTime, webhookId, checksum].join("|");

  try {
    return crypto.verify(
      "sha256",
      Buffer.from(message),
      certificate,
      Buffer.from(transmissionSig, "base64"),
    );
  } catch {
    return false;
  }
}
  • Compute crc32.unsigned(rawBody) directly from the raw request buffer; re-serialized JSON produces a different checksum.
  • Confirm paypal-auth-algo equals SHA256withRSA before running crypto.verify.
  • Cache certificates by URL, and evict or refetch if verification fails after PayPal rotates a certificate.

Process events idempotently and return 200 fast

Once the signature passes, persist the raw event or push it onto a background queue, return 200 OK, and run downstream fulfillment asynchronously. PayPal can deliver duplicate events and deliver them out of order, so guard fulfillment on event.id and re-query the Orders or Subscriptions REST API before releasing goods when current state matters.

  • Store event.id with a unique index so retries skip already-processed deliveries.
  • Return HTTP 200 as soon as the event is durably saved, rather than waiting on emails, PDFs, or third-party APIs.
  • Log verification failures with the five paypal-* headers and a SHA-256 digest of the raw body for debugging.

PayPal retry schedule and launch checks

When your listener returns a non-2xx status or times out, PayPal retries delivery up to 25 times over 3 days. In production, watch the Webhook Events log in the Developer Dashboard to track failed deliveries and resend events after deploying a fix.

Production checklist

  • Keep sandbox and live listeners, OAuth credentials, and Webhook IDs strictly separate.
  • Confirm WAF or bot-protection rules allow PayPal's incoming POST requests.
  • Alert on sustained 4xx or 5xx spikes on your webhook route before the 3-day retry window expires.

Common failure causes

  • FAILURE on real events: mismatched Webhook ID (sandbox vs. live) or body parsed before verification.
  • FAILURE on simulator events: expected behavior; test verification with a real sandbox payment.
  • No requests arriving: verify TLS on port 443 and make sure the endpoint URL does not HTTP-redirect.

Quick reference

StageActionKey constraint
RegisterAdd HTTPS URL via dashboard or /v1/notifications/webhooksPort 443 only; save Webhook ID per environment
SimulateDashboard simulator or /v1/notifications/simulate-eventMock payloads fail postback verification
Verifyverify-webhook-signature or offline CRC32 + certHash raw bytes, match Webhook ID, require SUCCESS
ProcessEnqueue payload and dedupe on event.idReturn 200 OK before running slow work
MonitorInspect Webhook Events status in dashboardUp to 25 retries over 3 days; manual resend available

Inspect and forward PayPal webhooks locally

Most signature mismatches happen because middleware altered the request body or because sandbox and live Webhook IDs were swapped. Hooklistener gives you a public HTTPS endpoint to inspect the exact headers and raw bytes PayPal sends, then forward traffic straight to localhost.

  1. Capture headers and raw bytes (Free): create an endpoint in the Hooklistener dashboard (the Free plan includes 1 endpoint, 50 stored requests, and MCP access with no credit card required), subscribe it in PayPal Sandbox, and complete a sandbox payment.
  2. Tunnel to localhost: install the Hooklistener CLI (npm i -g hooklistener), run hooklistener login, and run hooklistener tunnel --port 3000 to receive live sandbox deliveries on your local server.
  3. Replay captured events (Pro): on Pro ($12/mo, or $9/mo billed yearly, with 25K requests, 14-day history, and a static tunnel), resend captured PAYMENT.CAPTURE.COMPLETED deliveries after each edit without repeating sandbox checkout flows.
  4. Inspect from your coding agent: connect the Hooklistener MCP server so Claude Code or Codex can create endpoints, wait for PayPal deliveries, and inspect exact headers while debugging your verifier.

Frequently asked questions

How do I verify a PayPal webhook signature?

Either POST the five paypal-* headers, your webhook_id, and the unmodified event body to /v1/notifications/verify-webhook-signature and accept only verification_status SUCCESS, or verify locally: build transmissionId|timeStamp|webhookId|crc32(rawBody) and verify paypal-transmission-sig (base64, SHA256withRSA) against the X.509 certificate from paypal-cert-url.

What does verify-webhook-signature return?

A JSON object with verification_status set to "SUCCESS" or "FAILURE". It does not return VALID or INVALID. The request requires an OAuth access token and targets https://api-m.sandbox.paypal.com in sandbox or https://api-m.paypal.com in live.

Why does PayPal webhook verification fail for simulator events?

PayPal's postback verification endpoint does not validate mock events generated by the Webhooks simulator. Use simulator events to test payload parsing and routing, then test signature verification against real sandbox events created by an actual sandbox payment or subscription action.

How many times does PayPal retry a webhook?

PayPal retries failed deliveries up to 25 times over 3 days whenever your listener does not return a 2xx status or cannot be reached. Persist event.id to skip duplicates and return 200 OK as soon as the event is stored.

How do I inspect the raw PayPal webhook headers and body?

Subscribe a Hooklistener endpoint URL to your events in the PayPal Developer Dashboard, trigger a sandbox payment, and open the captured request. It records all five paypal-* headers and the exact raw body bytes your verification code receives.

Further reading