3

I am currently integrating Paypal subscriptions into my ReactJS WebApp.

A user shall be able to subscribe (and pay a small fee) to use premium features.

I wonder how to handle cancellations. What I would expect is when a user subscribes for a one-year period and then immediately cancels, he/she shall still be able to use the service for the paid period (one year).

With my current solution, however, upon cancelling, the access to premium features vanish immediately and does not let the user to access the service he paid for(and cancelled later).

My current solution looks like this:

How do the events BILLING.SUBSCRIPTION.CANCELLED, BILLING.SUBSCRIPTION.EXPIRED, BILLING.SUBSCRIPTION.SUSPENDED, BILLING.SUBSCRIPTION.ACTIVATED relate to each other ? I did not find any documentation about his. Is there an event or a workflow that I can use to accomplish what I intend ? I currently develop this using the sandbox features.

Or do I have to implement the necessary logic by myself?

Patrick
  • 1,635
  • 2
  • 13
  • 23
matthias
  • 43
  • 8

1 Answers1

2

PayPal only keeps track of whether the subscription is active.

Cancelled or Expired are how it became inactive.

On cancellation, you need to implement any "already paid for" logic yourself, PayPal does not do this.

Preston PHX
  • 27,642
  • 4
  • 24
  • 44
  • Hi Preston, thanks for your anwser! I wonder how the "expired" state is reached then, I think it cannot be triggered by the rest API? Given this, I would store the remaining time directly upon subscription. Is there any webhook which is called when a new billing cycle starts? – matthias Aug 28 '20 at 19:34
  • The expired state is reached when it reaches the end of a finite number of cycles. When a cycle is successfully payed for you'll receive a PAYMENT.SALE.COMPLETED, per https://developer.paypal.com/docs/api-basics/notifications/webhooks/event-names/#subscriptions – Preston PHX Aug 28 '20 at 20:28
  • 3
    Finally got it running. I did not use `BILLING.SUBSCRIPTION.EXPIRED` because I use infinite subscriptions. I also ignored `BILLING.SUBSCRIPTION.SUSPENDED` and `BILLING.SUBSCRIPTION.ACTIVATED` because they seem optional. The solution for me was listening to `PAYMENT.SALE.COMPLETED`, fetching the details from the subscription the payment has been made for and store `billing_info.next_billing_time` in my apps database. Thanks again! – matthias Aug 29 '20 at 21:03