Use webhooks for anything built on PayPal's REST APIs: Orders v2 and the JavaScript SDK, Subscriptions, Disputes. Keep IPN only where it already runs on a legacy integration, such as Payments Standard buttons or NVP/SOAP, until you migrate that integration. PayPal's IPN docs say "NVP/SOAP is a legacy integration method": still accepted and supported, but "there are newer solutions" (PayPal, last updated 17 August 2026). PayPal hasn't published a shutdown date that we could find.
IPN vs webhooks
From PayPal's docs, checked 14 November 2026 (IPN, webhooks, integration guide, API):
| IPN | Webhooks | |
|---|---|---|
| Status | Legacy, still supported | Current |
| Belongs to | NVP/SOAP and Payments Standard | REST APIs (Orders, Subscriptions, Disputes) |
| Payload | Name-value variables (txn_type, payment_status, txn_id) | JSON event (id, event_type, resource) |
| How you verify | Post the message back unaltered, prefixed with cmd=_notify-validate; PayPal answers VERIFIED or INVALID | Check an RSA signature yourself, or call verify-webhook-signature and get SUCCESS or FAILURE |
| Retries | Up to 4 days, at most 15 retries | Up to 25 times over 3 days, then marked Failed |
| Manual resend | Not covered here | From the Webhook Events dashboard |
| Dedupe on | txn_id plus the last payment_status (pending and completed share a txn_id) | The event id |
| Answer within | 30 seconds | Not stated; answer fast with a 2xx |
The verification row is the real difference. IPN verification is a round trip: you can't trust anything until PayPal says VERIFIED. Webhook verification can be done locally, with no call to PayPal at all.
What IPN events become
PayPal doesn't publish a mapping. This one pairs events by the descriptions on PayPal's own IPN variables and webhook event names pages, and only where the two describe the same thing:
| IPN | Webhook event |
|---|---|
payment_status=Completed on a one-time payment | PAYMENT.CAPTURE.COMPLETED |
payment_status=Pending | PAYMENT.CAPTURE.PENDING |
payment_status=Denied | PAYMENT.CAPTURE.DENIED |
payment_status=Refunded | PAYMENT.CAPTURE.REFUNDED |
payment_status=Reversed (a chargeback or other reversal) | PAYMENT.CAPTURE.REVERSED |
txn_type=subscr_signup | BILLING.SUBSCRIPTION.ACTIVATED |
txn_type=subscr_payment | PAYMENT.SALE.COMPLETED ("A payment is made on a subscription") |
txn_type=subscr_failed | BILLING.SUBSCRIPTION.PAYMENT.FAILED |
txn_type=subscr_cancel | BILLING.SUBSCRIPTION.CANCELLED |
txn_type=new_case | CUSTOMER.DISPUTE.CREATED |
txn_type=adjustment (dispute resolved and closed) | CUSTOMER.DISPUTE.RESOLVED |
Two catches. IPN folds the payment state into one variable on one message type, so an IPN handler is usually a big if on payment_status; webhooks split it into event types you subscribe to one by one, and you only receive what you subscribed to. And the webhook PAYMENT.CAPTURE.* events belong to captures made through the Orders and Payments APIs. A subscription payment arrives as PAYMENT.SALE.COMPLETED, not as a capture, which is the line most migrations miss.
Verifying a PayPal webhook
Each delivery carries PAYPAL-TRANSMISSION-ID, PAYPAL-TRANSMISSION-TIME, PAYPAL-TRANSMISSION-SIG, PAYPAL-CERT-URL and PAYPAL-AUTH-ALGO. PayPal documents two checks (PayPal):
- Self-verification. Build
transmission_id|transmission_time|webhook_id|crc32, wherewebhook_idis the ID of your webhook subscription (not in the request) andcrc32is the decimal CRC32 of the raw body. CheckPAYPAL-TRANSMISSION-SIGagainst it with the public key from the certificate atPAYPAL-CERT-URL, SHA256 with RSA. PayPal calls this "the preferred method", because it's faster and adds no API dependency. - Postback. Send the five header values, your
webhook_idand the event toPOST /v1/notifications/verify-webhook-signatureand check forverification_statusofSUCCESS. It needs an OAuth token, and it doesn't work for the simulator's mock events, which only self-verification can check.
Both break the same way: hand them anything other than the raw bytes PayPal sent. PayPal says to compute the CRC32 over the original body and not a re-stringified one, and to post the event back "exactly as it was received". This Flask handler self-verifies, refuses a certificate from anywhere but a PayPal host, and dedupes on the event id before anything else runs:
import base64
import json
import os
import sqlite3
import zlib
from urllib.parse import urlparse
import requests
from cryptography import x509
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
from flask import Flask, abort, request
app = Flask(__name__)
WEBHOOK_ID = os.environ["PAYPAL_WEBHOOK_ID"] # from your app's webhook settings
_keys = {}
db = sqlite3.connect("webhooks.db", check_same_thread=False)
db.execute("CREATE TABLE IF NOT EXISTS paypal_events "
"(id TEXT PRIMARY KEY, type TEXT, body BLOB, processed_at TEXT)")
def _public_key(cert_url):
"""Fetch PayPal's signing cert once per URL. Only ever from a PayPal host."""
url = urlparse(cert_url)
host = url.hostname or ""
if url.scheme != "https" or not (host == "paypal.com" or host.endswith(".paypal.com")):
raise ValueError(f"refusing cert from {host!r}")
if cert_url not in _keys:
resp = requests.get(cert_url, timeout=5)
resp.raise_for_status()
_keys[cert_url] = x509.load_pem_x509_certificate(resp.content).public_key()
return _keys[cert_url]
def verify_paypal(raw_body, headers):
try:
if headers["PAYPAL-AUTH-ALGO"] != "SHA256withRSA":
return False
signature = base64.b64decode(headers["PAYPAL-TRANSMISSION-SIG"])
key = _public_key(headers["PAYPAL-CERT-URL"])
message = "|".join([
headers["PAYPAL-TRANSMISSION-ID"],
headers["PAYPAL-TRANSMISSION-TIME"],
WEBHOOK_ID,
str(zlib.crc32(raw_body)), # decimal CRC32 of the raw bytes
]).encode()
key.verify(signature, message, padding.PKCS1v15(), hashes.SHA256())
return True
except (KeyError, ValueError, InvalidSignature, requests.RequestException):
return False
@app.post("/webhooks/paypal")
def paypal_webhook():
raw = request.get_data() # raw bytes: never re-serialize before verifying
if not verify_paypal(raw, request.headers):
abort(400)
event = json.loads(raw)
with db: # the primary key on id makes a redelivery a no-op
db.execute("INSERT OR IGNORE INTO paypal_events (id, type, body) "
"VALUES (?, ?, ?)", (event["id"], event["event_type"], raw))
# A worker processes rows where processed_at IS NULL, off the request path.
return "", 200
The certificate host check is ours, not PayPal's. The URL arrives in a header the sender controls, so without it a forger can sign with their own key and point you at their own cert. Note what the code doesn't do: it applies no timestamp window. The transmission time is inside the signed string, but PayPal doesn't say whether a retry three days later carries a fresh one, so a tight window could reject real retries. The primary key on the event id does the replay work instead.
If you'd rather have PayPal do the crypto, the postback works too. Splice the raw body in rather than parsing and re-dumping it:
import json
import requests
API_BASE = "https://api-m.paypal.com" # https://api-m.sandbox.paypal.com in sandbox
def verify_by_postback(raw_body, headers, access_token, webhook_id):
fields = {
"auth_algo": headers["PAYPAL-AUTH-ALGO"],
"cert_url": headers["PAYPAL-CERT-URL"],
"transmission_id": headers["PAYPAL-TRANSMISSION-ID"],
"transmission_sig": headers["PAYPAL-TRANSMISSION-SIG"],
"transmission_time": headers["PAYPAL-TRANSMISSION-TIME"],
"webhook_id": webhook_id,
}
# Splice the event in byte for byte. json.loads then json.dumps can
# change the bytes PayPal signed, and the check fails.
body = json.dumps(fields)[:-1].encode() + b', "webhook_event": ' + raw_body + b"}"
resp = requests.post(
f"{API_BASE}/v1/notifications/verify-webhook-signature",
data=body,
headers={"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"},
timeout=10,
)
return resp.ok and resp.json().get("verification_status") == "SUCCESS"
Retries, duplicates and order
PayPal retries any non-2xx response up to 25 times over 3 days, then marks the delivery Failed; you can resend it from the Webhook Events dashboard (PayPal). A retry redelivers the same event, so the event id is your dedupe key, and your store has to remember it for at least those 3 days plus any manual resend. PayPal's docs say nothing about ordering, so treat events as unordered and fetch the order or subscription from the API before acting on a state change. Webhook idempotency covers the store design, and Stripe webhooks has the same handler on Stripe's HMAC scheme if you run both.
Migrating from IPN
- Run both for a while. Subscribe to webhooks, log them next to your IPNs, and compare until every IPN you act on has a webhook partner.
- Dedupe by business object, not notification. During the overlap one payment can arrive through both channels. Make "mark order paid" idempotent on your order, so the second notification is a no-op whichever channel it came through.
- Switch the integration, not just the listener. IPN belongs to the legacy integrations. Moving to webhooks properly means moving the checkout to Orders v2 or the JavaScript SDK as well, which is what chapter 10 builds.
The seven events to subscribe to first. From chapter 10.
Essential Webhook Events
Start with these seven events. Add others when you actually need them.
IMPORTANT_EVENTS = [
'PAYMENT.CAPTURE.COMPLETED', # One-time payment succeeded
'PAYMENT.CAPTURE.DENIED', # One-time payment failed
'BILLING.SUBSCRIPTION.CREATED', # New subscription created
'BILLING.SUBSCRIPTION.ACTIVATED', # Subscription approved and active
'BILLING.SUBSCRIPTION.CANCELLED', # Subscription cancelled by customer
'BILLING.SUBSCRIPTION.SUSPENDED', # Subscription suspended (payment issues)
'CUSTOMER.DISPUTE.CREATED' # Customer opened a dispute/chargeback
]
PayPal next to Stripe, Paddle, Adyen and Square on retries, ordering and signatures. From chapter 39.
How Five Providers Deliver
The handler code later in this section is provider-agnostic on purpose. The numbers it runs on aren't. The two tables below are what each provider's documentation said in September 2026; retry schedules change without an API version bump, so check the docs before you hard-code any of them. Where a provider's docs don't state a policy, the cell says so instead of guessing.
| Provider | Retry schedule and window | Ordering | How duplicates present |
|---|---|---|---|
| Stripe | Live: exponential backoff for up to 3 days. Sandbox: 3 tries over a few hours. Manual resend for 15 days in the Dashboard, 30 days via the CLI | Not guaranteed. created has one-second resolution, so don't order by it | Same event.id on every retry. Occasionally two distinct events for one change; dedupe those on data.object.id plus type |
| PayPal | Up to 25 attempts over 3 days, then marked Failed. Manual resend from the Webhook Events dashboard | Not stated in the docs. Treat as unordered | Retries redeliver the event; dedupe on the event id |
| Paddle | Live: 60 attempts over 3 days, 20 of them in the first hour. Sandbox: 3 attempts in 15 minutes. Respond 200 within 5 seconds | Not guaranteed. Docs say to store occurred_at and compare before applying a change | Same event may arrive more than once; dedupe on the event ID, not the ntf_ notification ID |
| Adyen | Three quick tries at 9, 18, and 27 seconds, then a per-endpoint queue that backs off to 8-hour intervals and keeps trying for up to 30 days. Acknowledge with a 2xx within 10 seconds | Docs tell you to order by timestamp yourself; some webhook types carry a sequenceNumber | Duplicates share eventCode and pspReference; eventDate can differ. Adyen says use the latest |
| Square | 11 attempts over 24 hours, backing off from 1 minute to 8 hours, then discarded. square-retry-number counts resends | Not guaranteed | May be sent more than once; dedupe on event_id |
| Provider | Signature scheme and header | Replay protection | Local testing |
|---|---|---|---|
| Stripe | HMAC-SHA256 over t.body, hex, in Stripe-Signature: t=...,v1=.... Several v1 values for up to 7 days after you roll the secret, if you delay the old one's expiry | t is in the signed string; libraries default to a 5-minute tolerance. Each retry gets a fresh t and signature | stripe listen --forward-to for a signed tunnel, stripe trigger to fire events |
| PayPal | Certificate-signed; five PAYPAL-* headers plus your webhook_id, checked by calling verify-webhook-signature. Self-verification against the cert and a CRC32 of the body is documented | Transmission time is in the signed string; the docs don't say how strictly the API checks it | Webhooks simulator in the Developer Dashboard, a sandbox app, resend from Webhook Events |
| Paddle | HMAC-SHA256 over ts:body, hex, in Paddle-Signature: ts=...;h1=.... More than one h1 during rotation | ts is in the signed string; Paddle's default tolerance is 5 seconds | Paddle > Developer tools > Simulations sends signed events; pair with ngrok or the Hookdeck CLI |
| Adyen | Base64 HMAC-SHA256 over eight colon-joined fields, not the body, inside additionalData.hmacSignature. Hex key from the Customer Area | None in the signature. Your idempotency store and eventDate are all you have | Customer Area > Developers > Webhooks > Test configuration; Troubleshoot > Retry to resend a failed event |
| Square | Base64 HMAC-SHA256 over notification_url + body in x-square-hmacsha256-signature | None in the signature. Idempotency store only | Developer Console > subscription > More > Send test event, or POST /v2/webhooks/subscriptions/{id}/test; square-environment header says Sandbox or Production |
Sources: Stripe, PayPal, Paddle, Adyen, and Square webhook documentation, 2026.
Two things in those tables should change your design. First, four of the five retry windows are longer than the 48-hour Redis TTL in the code below, and Adyen's runs right up to the 30-day database retention. A retry that lands after your Redis key expires has to hit the database check or it gets processed twice. Second, Adyen and Square put no timestamp in what they sign, so a captured request stays valid forever. For those two, the idempotency store is your only replay protection.
Questions
Is PayPal IPN deprecated?
PayPal calls it legacy, not deprecated. Its IPN docs say NVP/SOAP is a legacy integration method that PayPal still accepts and supports, with newer solutions available. We found no published shutdown date. Build new integrations on webhooks.
What is the difference between PayPal IPN and webhooks?
IPN sends name-value posts from PayPal's legacy integrations, and you verify each one by posting it back for a VERIFIED or INVALID answer. Webhooks send signed JSON events from the REST APIs, and you verify the signature yourself or through the verify-webhook-signature API.
How do I verify a PayPal webhook signature?
Build transmission_id|transmission_time|webhook_id|crc32 from the PAYPAL-* headers, your webhook ID and the decimal CRC32 of the raw body, then check PAYPAL-TRANSMISSION-SIG against it with the certificate at PAYPAL-CERT-URL using SHA256 with RSA. Or post the headers, webhook ID and unaltered event to verify-webhook-signature and check for SUCCESS.
How many times does PayPal retry a webhook?
Up to 25 times over 3 days for any non-2xx response, after which the delivery is marked Failed and can be resent from the Webhook Events dashboard. IPN resends for up to four days, with at most 15 retries.
Why does PayPal webhook verification fail?
Usually because the body was parsed and re-serialized before verifying, which changes the bytes PayPal signed. Use the raw request body for the CRC32, and post the event back exactly as received. Mock events from the simulator can't be checked with the postback at all, only by self-verification.