Callback/webhook when shopify charge my clients

552 views Asked by At

I'm working on a Shopify app, so my business plan is to charge user monthly for using the app, i have three plans each plan has a limit of actions, so we can say I'm using a combination of a monthly limited plan for example :

plan 1 => 50$/month for 5000/month actions (actions = click on a button)
plan 2 => 99$/month for 15000/month actions (actions = click on a button)
plan 3 => 119$/month for 20000/month actions (actions = click on a button)

so the problem is how I can get a callback or webhook from Shopify when the user has paid the monthly fee so i can update his actions count at the end of each month.

thanks

1

There are 1 answers

0
bknights On

I don't think you can get a webhook or callback for this. You have to query the api on some periodic basis.

When a customer installs your app you should use the RecurringApplicationCharge api call so the customer can set up your terms and Shopify will charge them.

You can either record the charge id or just query for it as part of your app's process.

Once you have the recurring charge and have activated it you can query it for the "billing_on" date. Your app can record that and check only on that date for that app which saves some API governance. If the RecurringApplicationCharge status is active and the billing_on date advances then the customer has been successfully charged. As long as you have a standard process for running your checks (e.g. use the shop's midnight which you can determine from their iana_timezone then it's an easy thing to explain to customers when their limits will reset.

If they update their plan mid-month due to running out of actions then your app will be part of that update (e.g. you'll send them a notice with a link to your app) so you'll be able to track the application charge status and reset their limits as soon as you successfully activate the new charge.