otembajelle
otembajelle

Reputation: 176

What is the signature of a PayPal webhook in node.js?

I fail to wrap my head around PayPal webhooks. They offer samples to create, delete, list webhooks. For instance, when

var create_webhook_json = {
    "url": "https://www.yeowza.com/paypal_webhook",
    "event_types": [
        {
            "name": "PAYMENT.AUTHORIZATION.CREATED"
        },
        {
            "name": "PAYMENT.AUTHORIZATION.VOIDED"
        }
    ]
};

then I expect https://www.yeowza.com/paypal_webhookto be a webhook.

My question about that sample webhook:

  1. does it receive events from PayPal when its registered events occur? (obviously yes)
  2. does PayPal issue requests of type POST?
  3. how can the webhook inspect such an event?
  4. what does PayPal expect as an response?

Finally is "webhooks" limited to PayPal or is it a general node.js concept?

Upvotes: 2

Views: 2335

Answers (2)

Manoj Sanjeewa
Manoj Sanjeewa

Reputation: 1079

PayPal REST APIs use webhooks for event notifications. Webhooks are push API calls that let your app know an event has happened.

For creating webhooks login to the paypal developer account and go to ‘My App and Credentials’ menu. In that page you can see your apps which has already added and click on the app and go to details page to add the webhook for your app. To create webhook you have to give url which starts with https:// to get event notifications from paypal. you can select which event type you want to receive notifications.

you can find complete guide to implement webhooks with node js in following link. https://techpituwa.wordpress.com/2022/08/24/paypal-webhook-notifications-with-nodejs/

Upvotes: -1

otembajelle
otembajelle

Reputation: 176

Darkrum was right when he said that the answer can be found in the docs.

1,2,4: "When an event occurs, PayPal issues an HTTP POST notification message to your app at the webhook listener URL that you defined in your webhook. ... When your app receives the notification message, it must respond with an HTTP 200-level status code. If your app responds with any other status code, PayPal tries to resend the notification message 25 times over the course of three days."

As for 3 you may want to check the example.

Upvotes: 2

Related Questions