Search code examples
restpaypal

What event is triggered from PayPal on successful recuring payment (for subscription)?


I have a subscription based web site where I would like to get statistics about all the current active subscribers and how many cycles they have made. This would have been easy task if the PayPal API had an endpoint for fetching all subscriptions but this is missing from their API. So I'm tracking this in our DB. I'm successfully recording the new subscriptions and the cancellations. But I'm not sure what event I should expect from PayPal to be triggered when a subscription renews.

In PayPal's documentation I have found only few events related to the subscriptions, and none of those seems to serve my needs. There are also an event called BILLING.SUBSCRIPTION.RE-ACTIVATED but it comes from "Billing plans and agreements" which is deprecated.

In SO I have found this post which advises to check for the PAYMENT.SALE.COMPLETED, but this is not perfect as I will get all sort of payments that hit this PayPal account (it is used not only for subscriptions but also for one-time payments).


Solution

  • It's PAYMENT.SALE.COMPLETED

    For one time payments, a /v2/checkout/orders integration shouldn't trigger that same event, only the deprecated /v1/payments does AFAIK.

    You can tell whether it's a subscription payment by the payload, subscription IDs begin with I-