How to get webhook notification when subscription's payed through date has passed

67 views Asked by At

I would like to allow my users to maintain access to the features unlocked via a subscription until the end of the payed-through period (even if the subscription has been canceled).

To do so I would need to update the user's permissions in my database, and the best way would be by receiving a webhook notification when the payed-through date has passed.

Is this possible? If not what would be the best approach to achieve this behavior?

Any help is greatly appreciated :)

1

There are 1 answers

0
SeriousMonk On

Solved the problem.

When the user cancels the subscription, instead of calling

await gateway.subscription.cancel(subscriptionId);

simply call

await gateway.subscription.update(subscriptionId, {
   numberOfBillingCycles: 1
});

this will cause the subscription to remain active until the paidThroughDate and then expire (instead of renewing) triggering the SubscriptionExpired webhook.