Subscribe to checkout webhooks

Last updated: Sept 19th, 3:17am

To complete an end-to-end integration of alternative payment methods with the Orders API, subscribe to the following webhooks:

  • CHECKOUT.ORDER.APPROVED - Listen for this webhook and then capture the payment. Step 5 of the integration instructions for each APM describe what action to take when you receive this event. See also - Webhook event names for Orders API.
  • CHECKOUT.PAYMENT-APPROVAL.REVERSED - Listen for this webhook as an indication that a problem occurred after the buyer approved the transaction and before you captured the payment. Then notify your buyer of the problem and the reversed order. Handle Uncaptured Payments describes what action to take when you receive this event.
  • PAYMENT.CAPTURE.PENDING - Listen for this webhook as an indication that payment initiation was successful but payment completion is still pending. Do not fulfill the order until payment completion is successful. See Payments webhooks.
  • PAYMENT.CAPTURE.COMPLETED - Listen for this webhook and then fulfill the order. Step 5 of the integration instructions for each APM describe what action to take when you receive this event. See Payments webhooks.
  • PAYMENT.CAPTURE.DENIED - Listen for this webhook and then cancel fulfilling the order. Step 5 of the integration instructions for each APM describe what action to take when you receive this event. See Payments webhooks.

The rest of this topic walks you through subscribing to these webhook events.

Know before you code

Subscribe to the webhooks

To subscribe to the CHECKOUT.ORDER.APPROVED, CHECKOUT.PAYMENT-APPROVAL.REVERSED, PAYMENT.CAPTURE.PENDING, PAYMENT.CAPTURE.COMPLETED, and PAYMENT.CAPTURE.DENIED events, copy the following code and modify it.

Sample request

API endpoint used: Create webhook

    1curl -v -X POST https://api-m.sandbox.paypal.com/v1/notifications/webhooks \
    2-H "Content-Type: application/json" \
    3-H "Authorization: Bearer <Access-Token>" \
    4-d '{
    5 "url": "https://example.com/example_webhook",
    6 "event_types": [
    7 {
    8 "name": "CHECKOUT.ORDER.APPROVED",
    9 },
    10 {
    11 "name": "CHECKOUT.PAYMENT-APPROVAL.REVERSED"
    12 },
    13 {
    14 "name": "PAYMENT.CAPTURE.PENDING"
    15 },
    16 {
    17 "name": "PAYMENT.CAPTURE.COMPLETED"
    18 },
    19 {
    20 "name": "PAYMENT.CAPTURE.DENIED"
    21 }
    22 ]
    23}'

    Modify the code

    After you copy the code in the sample request, modify the following:

    • Access-Token - Your Access token.
    • url - The URL of your webhook handler that listens for webhooks you're subscribed to.

    Step result

    A successful request results in the following:

    • A return status code of HTTP 201 Created.
    • A JSON response body that contains the webhook ID.
    • An entry for the webhook in the REST API app you're using for development. Open then app you're using and scroll to the webhooks section to confirm the webhook appears with the same ID returned in this call.

    Sample response

      1{
      2 "id": "2CJ781045X895601X",
      3 "url": "https://example.com/example_webhook",
      4 "event_types": [
      5 {
      6 "name": "CHECKOUT.ORDER.APPROVED",
      7 "description": "An order has been approved by buyer."
      8 },
      9 {
      10 "name": "CHECKOUT.PAYMENT-APPROVAL.REVERSED",
      11 "description": "An order has been reversed."
      12 },
      13 {
      14 "name": "PAYMENT.CAPTURE.PENDING",
      15 "description": "The state of a payment capture changes to pending."
      16 },
      17 {
      18 "name": "PAYMENT.CAPTURE.COMPLETED",
      19 "description": "A payment capture completes."
      20 },
      21 {
      22 "name": "PAYMENT.CAPTURE.DENIED",
      23 "description": "A payment capture is denied."
      24 }
      25 ],
      26 "links": [{
      27 "href": "https://api-m.sandbox.paypal.com/v1/notifications/webhooks/2CJ781045X895601X",
      28 "rel": "self",
      29 "method": "GET"
      30 },
      31 {
      32 "href": "https://api-m.sandbox.paypal.com/v1/notifications/webhooks/2CJ781045X895601X",
      33 "rel": "update",
      34 "method": "PATCH"
      35 },
      36 {
      37 "href": "https://api-m.sandbox.paypal.com/v1/notifications/webhooks/2CJ781045X895601X",
      38 "rel": "delete",
      39 "method": "DELETE"
      40 }
      41 ]
      42}

      If you accept cookies, we’ll use them to improve and customize your experience and enable our partners to show you personalized PayPal ads when you visit other sites. Manage cookies and learn more