Is there a way to configure Revenue cat to revoke entitlements immediately when billing fails and the subscritpion enters a billing retry or grace period? I’m using stripe. I noticed that my past_due stripe account have an active entitlement that doesn’t expire until end of next billing cycle! I currently have code like this but it feels ugly and I prefer revenue cat handle it:
// Check if all subscriptions are either not active or not trialing
const hasActiveOrTrialingSub = subscriptionData?.some(
(sub) => sub.status === 'active' || sub.status === 'trialing'
);
// Check if any subscription is past_due
const hasPastDueSub = subscriptionData?.some(
(sub) => sub.status === 'past_due'
);
// Step 3: Fetch active entitlements for the owner
const activeEntitlements = await getActiveEntitlements(ownerProfileId);
console.log("activeEntitlements", activeEntitlements);
if (!activeEntitlements || activeEntitlements.length === 0) {
return;
}
const fleetEntitlement = activeEntitlements.find((entitlement) => {
return entitlement.entitlement_id === REVENUE_CAT_FLEET_ENTITLEMENT_ID;
});
// If we have a fleet entitlement but no active/trialing subscription and at least one past_due subscription
// we should revoke the fleet entitlement
if (fleetEntitlement && !hasActiveOrTrialingSub && hasPastDueSub) {
try {
const revokeResponse = await fetch(
`https://api.revenuecat.com/v1/subscribers/${ownerProfileId}/entitlements/${REVENUE_CAT_FLEET_ENTITLEMENT_ID}/revoke_promotionals`,
{
method: 'POST',
headers: createHttpHeaders({
accessToken: process.env.REVENUECAT_API_KEY_V1!,
includeContentType: true
})
}
);
