How to get app subscription status from Shopify API

stretch0
Tourist
5 0 1

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?

Replies 2 (2)
ConspireAgency
Shopify Expert
32 3 16

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

Conspire Agency //
Los Angeles, California //
https://conspireagency.com
View my showreel: https://www.youtube.com/watch?v=E9upo48FQUg
ConspireAgency
Shopify Expert
32 3 16

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 😃

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

😃

Conspire Agency //
Los Angeles, California //
https://conspireagency.com
View my showreel: https://www.youtube.com/watch?v=E9upo48FQUg