Skip to main content

Set Up and Secure Webhooks for PayPal Checkout

Integrate PayPal webhooks to accept online payments with PayPal Checkout, and receive real-time notifications for payment events, such as completed payments, refunds, and subscription renewals. This guide shows you how to set up, secure, and test PayPal webhooks for your online payments integration.

What Are PayPal Webhooks?

Webhooks are HTTPS POST requests that PayPal sends to your server when important events occur, such as when a payment is captured or a subscription is renewed. Set up your system to respond automatically to changes without polling PayPal’s API.

Prerequisites

  • A PayPal Business account.
  • Access to the PayPal Developer Dashboard.
  • A server endpoint URL that can receive HTTPS POST requests.

1. Subscribe to webhook events

  1. Log in to the PayPal Developer Dashboard.
  2. Go to My Apps & Credentials.
  3. Select your app or create a new one.
  4. In your app details, scroll to the Webhooks section.
  5. Click Add Webhook.
  6. Enter your webhook listener URL, such as the endpoint on your server.
  7. Select the event types you want to receive, such as PAYMENT.CAPTURE.COMPLETED, CHECKOUT.ORDER.APPROVED, or BILLING.SUBSCRIPTION.CREATED. You can choose “All Events” or only those you need.
  8. Click Save. Your webhook is now active.

2. Implement your webhook listener

Create an HTTPS endpoint on your server to receive POST requests from PayPal. Review the following examples:

curl -X POST \
https://your-server.com/webhook/paypal \
-H 'Content-Type: application/json' \
-d '{
"event_type": "PAYMENT.CAPTURE.COMPLETED",
"resource": {
"id": "your_capture_id",
"amount": {
"value": "10.00",
"currency": "USD"
}
}
}'

3. Secure your webhook endpoint

Use HTTPS

Always use HTTPS for your webhook endpoint to encrypt data in transit.

Validate incoming webhook requests

  • Extract headers from PayPal’s request:

    • paypal-transmission-id
    • paypal-transmission-time
    • paypal-transmission-sig
    • paypal-cert-url
    • paypal-auth-algo
    • webhook-id (from your dashboard)
  • Verify the signature using the Verify webhook signature endpoint of the Webhooks Management API:

    • Send the headers and raw request body to PayPal’s verification endpoint.
    • Only process the event if verification succeeds.
  • Check event details, such as transaction amount and payer info, against your records to prevent fraud.

Additional security best practices

  • Idempotency: Ensure your webhook processing logic is idempotent to avoid duplicate handling.
  • Logging: Log all received events for auditing and troubleshooting.
  • Restrict access: Only allow PayPal’s IPs if possible, and never expose sensitive data in responses.
  • Keep your SDKs and dependencies up to date.

4. Test your webhook integration

  • Use PayPal’s webhook simulator in the Developer Dashboard to send test events to your endpoint and verify your handler works as expected.
  • For local development, use a tunneling tool like ngrok to expose your local server to PayPal.

5. Monitor and maintain

  • Monitor logs for unexpected or repeated webhook calls.
  • Update your webhook subscriptions as your integration evolves.
  • Regularly review PayPal’s developer updates for security changes.

You now have a secure, reliable webhook integration for PayPal Checkout. This ensures your system stays in sync with real payment events, automatically and safely.

Additional webhook endpoints

Use the following endpoints to monitor and manage your webhooks:

  • List Webhooks: Return a list of existing webhooks by sending a GET request to the List webhooks endpoint.
  • Show Webhook Details: Return details about a specific webhook by sending a GET request to the Show webhook details endpoint.
  • Delete Webhook: Delete a specific webhook by sending its webhook ID in a DELETE request to the Delete webhook endpoint.
  • Update Webhook: Update a particular webhook by sending a PATCH request with its webhook ID to the Update webhook endpoint. Supports only the replace operation.

See also