Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cancelling paypal subscriptions using their API - how to keep the account active for the already paid peroid?

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:

  • Subscribing already works by using this paypal button: https://www.npmjs.com/package/react-paypal-button-v2#subscription-example-usage
  • Cancelling also works using this API call: https://developer.paypal.com/docs/subscriptions/full-integration/subscription-management/#cancel-subscription This also triggers a webhook of my app with the event BILLING.SUBSCRIPTION.CANCELLED. Then immediately the account is cancelled and the user cannot use the features he already paid for.

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?

like image 271
matthias Avatar asked Oct 27 '25 08:10

matthias


1 Answers

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.

like image 90
Preston PHX Avatar answered Oct 29 '25 07:10

Preston PHX



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!