Search code examples
paypal-subscriptionspaypal-webhooks

Paypal webhook when subscription ends/expires not fired


There are several webhooks for PayPal, I enabled the following:

  • Billing subscription activated
  • Billing subscription cancelled
  • Billing subscription created
  • Billing subscription expired
  • Billing subscription payment failed
  • Billing subscription re-activated
  • Billing subscription suspended
  • Billing subscription updated

While I receive: cancelled, created, activated, payment failed events and so on - I do not receive an event when the payment expires. However the subscription in my sandbox business account is clearly marked as expired after the period is over. Does PayPal only send webhooks when someone does something actively and not when the time of the period is over? I have just a simple PHP-Script for testing purpose and it just logs all requests together with the payload. The BILLING.SUBSCRIPTION.EXPIRED never appears in the logs.

So my question is: did I get it wrong or do I need a custom cronjob that checks for the expiration date.


Solution

  • If you are not using trial periods, the only event you need to listen for is PAYMENT.SALE.COMPLETED

    None of the BILLING.SUBSCRIPTION.* events are of any particular utility

    Cron or whichever scheduler or on-demand checking you wish to use should handle profiles that do not receive new PAYMENT.SALE.COMPLETED events by a desired date.


    Also, is worth noting that if you wish to detect when a user cancels their subscription via PP dashboard, or when the same subscription is cancelled by an admin in the dashboard - you can't use webhooks for this. The BILLING.SUBSCRIPTION.CANCELLED is not triggered from dashboard cancellations and you have no way to detect this action. You can poll subscriptions with a GET API call to see if they are still active. But the simplest solution is as above: only track PAYMENT.SALE.COMPLETED and don't concern yourself with whether the subscription is active in PayPal or not; use your own "is it active?" status based on whether payments are received on time or not.