How to get app subscription status from Shopify API

Is there a way to determine the subcsription status of an app via the Shopify node client or in the GraphQL API?

Given a user has signed up to our public app, when they log in. then I should be able to check if their Shopify subscription to our app is still active.

I can see via the GraphQL API I can query

currentAppInstallation {
   activeSubscriptions {
     id
     name
     test
   }
}

This seems to return an empty array, implying my test store I doesn’t have any active subscriptions. This may be due to my app and shop being in test mode though.

Does anybody know if this is the case or is there another way to get the subscription status?
Also, it would be good to do via the Shopify client if that is possible?

2 Likes

Haven’t tested a GraphQL method, so not quite what you’re looking for… but Via the rest API you would query this endpoint with the charge_id present in the query parameter at the return url.

GET /admin/api/2021-01/recurring_application_charges/{charge_id}.json

https://shopify.dev/api/admin/rest/reference/billing/recurringapplicationcharge#show-2021-07

1 Like

Update, if you use the query below:

currentAppInstallation {
   activeSubscriptions {
     status
   }
}

it will return something similar to:

{ activeSubscriptions: [ { status: 'ACTIVE' } ] }

ie. an array with an object containing the status

You can test this by first running a mutation to create a recurring subscription charge, making sure to include “test: true” in the mutation. Once you have this active subscription in your demo store then the query above will stop returning an empty array for your further testing pleasure :smiley:

If you don’t first have a test recurring subscription charge activated then the array will just return completely empty.

:smiley:

3 Likes

Is there any REST API to get the App Subscription Status

1 Like

The only negative I have encountered using this method is that if you query using a session token of a staff member that doesn’t have access to managing the app subscription this will return an error of ‘Access Denied’