App billing - how to charge app usage by order count

Shopify Partner
7 0 2



Been trying to understand what would be the correct way of doing the following.

We have an app and would like to charge according to the order count per month. The way I see it, there are 2 options:

1. Use /admin/api/{version}/orders/count.json?status=any

2. Subscribe to orders create webhook.


The first option, however, requires me to ask for protected data access, otherwise it seems to be impossible to subscribe to that webhook topic. We don't need any sensitive information/any order info at all, only the count.


The second option seems quite difficult yet imprecise from our backend's side. I have to run a cronjob each day to track each store (the app has more than 1k users, thus many requests). For very small stores it will be a overkill as we'd only bill 1$ for every additional 100 orders. Thus, for ~80% of cases we'd be making redundant requests to Shopify api. And for very, very large stores we'd be getting it wrong if ran too infrequently. And then each day have to check if there's been already issued a bill for the next 100 orders by aggregating the previous' days results.

Another issue is - how do I know what is the date from which to start count these orders? Should I query on graphql currentAppInstallation -> activeSubscriptions -> currentPeriodEnd and deduct 30 days from it?


Any suggestions, am I missing something? Or those literally are the only options? Tried finding anything similar on the web, but without any luck.



Replies 0 (0)