Subscriptions and app availability

I have a question regarding subscription handling in my Shopify app. Currently, users are granted access to the app if they have an active subscription with a 30-day renewal period.

The issue: I was relying on [activeSubscriptions](https://shopify.dev/docs/api/admin-graphql/2024-04/objects/appsubscription) to grant access. If there was at least one active subscription, access was granted. However, this caused a problem: when a user cancels their subscription, the activeSubscriptions array becomes empty, and access is revoked immediately. This is incorrect because the user has already paid for 30 days of access, and their subscription cancellation should not affect access during this period.

I would like to know the best way to handle access logic in this scenario. Specifically, how can I ensure that users retain access for the full 30 days they’ve paid for, even if they cancel their subscription?

Additional context:

  • I have three plans.
  • If a user upgrades, the new plan is applied instantly.
  • If a user downgrades, the changes take effect after the current billing cycle (30 days).

Hello Vlad.

As far as I know it can be found not in the activeSubscriptions, instead of the allSubscriptions.

It is because it’s indeed cancelled, but still active, and that time contains by the currentPeriodEnd property.

Hi, thanks for your response! After some thought, I’ve found a solution.

Initially, I was concerned because I’m using a different replacement behavior: “apply subscription after the billing cycle ends.” This could complicate the logic.

Here’s what I’ve done instead. I dont use all subscriptions endpoint but activeSbuscriptions :

  • I rely on the subscription update webhook and the getActiveSubscription endpoint.
  • If there’s an active subscription, I retrieve its endDate and record it.
  • If there’s no active subscription, the endDate remains unchanged.
  • By consistently tracking the endDate of the last active subscription, I use it to determine whether the user can access my app.

Thanks for your response

1 Like