paypalpaypal-sandbox

PayPal Node SDKs: difference between paypal-rest-sdk and @paypal/checkout-server-sdk for webhooks?


I have this question regarding 2 npm PayPal packages, what is the difference between
paypal-rest-sdk and @paypal/checkout-server-sdk ? And can you implement webhooks using @paypal/checkout-server-sdk or there is no need for webhooks for this package ?

paypal-rest-sdk

checkout-server-sdk

var paypal = require('paypal-rest-sdk');

const paypal = require('@paypal/checkout-server-sdk');


Solution

  • All PayPal-*-SDK for every language have been deprecated for a long time and should not be used for anything. This includes the one for node that's in npm as @paypal/paypal-rest-sdk.

    The Checkout-*-SDK for every language, in npm for node as @paypal/checkout-server-sdk, has also been deprecated.

    Currently all developer.paypal.com documentation only references doing direct HTTPS REST API integrations, using a client id and secret to first obtain an access_token. For node in particular, there is a full stack example in the PayPal Checkout integration guide that serves as a useful starting point, although I recommend the client side onApprove function in this approval flow since that sample includes client-side error handling of the capture response (restarting or showing an error as appropriate)


    As for webhooks, they are a separate matter. There is no current SDK for them. The server-side capture API response is already sufficient for normal orders API payments so you may not need webhooks for what you're doing, but if there are specific events you're interested in listening for (such as refunds or disputes that occur on PayPal.com ) you'll need to subscribe to the event(s) you want -- either in the REST app or using webhook API calls.