Recurring Charge - Is there a "Declined" Webhook

Recurring Charge - Is there a "Declined" Webhook

Paul_Hughes1
Tourist
3 0 3

Hello, everyone;

First post in this forum—I did a search for some information on this and found a lot of threads, although none that answered this questions specifically, so far as I could tell. I'm building an app that uses the Recurring billing API. I've been successful in setting it up, and dealing with both the situation in which a customer accepts the charge versus when they decline it by hand (at initial install). If they decline, then they can then request a charge again. Obviously, if they try to load the app, I can immediately check if a given billing ID is active/accepted or not, and if not, do that same functionality (so, they load the app after it has later been declined. The trick is that my app's server is only touched on the admin screen. From there, templates are modified/added such that the app doesn't even need to load on the frontend in all situations—so it might never have to be authorized unless they visit the app's admin page.

My question, then, is whether there is a webhook that can be sent to my app's server upon the failed charge from the recurring charge, such that my server would be notified and it could then execute the actions necessary to "deactivate" app functionality (and the stuff in the templates). Is that possible? Or would I have to set the app up to check after 30 days automatically from the time when the recurring charge was activated? Ideally, I wouldn't have to store and check the charge's status every single time the app is used in a given shop.

Thanks in advance for your help! 🙂

Paul

Replies 4 (4)

HunkyBill
Shopify Partner
4851 60 555

This one is dead simple! Write a for next loop, or each, or whatever your favourite enumerator method is, over the shop entries in your persistence mechanism. Perhaps you store the myshopify_domain value and the oAuth token in there. In your loop, check the status of your recurring charges by asking for the value of the current charge. If it is nil, you know they are not current, and you can kill their entry. When their account is frozen, your access to their shop details returns a code you can react to by not killing them off. 

This script can be run using CRON daily, hourly etc. Problem solved. No need to wait for the merchant to login to your App. 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com

Paul_Hughes1
Tourist
3 0 3

Thanks a lot for your reply; clears up what will be necessary for the process. 🙂 Up-voted.

Paul

Hussien
Tourist
12 0 1

I do exactly what HunkyBill says.

I loop over all the shops through a scheduler that runs every 24 hours that does the Billing API call to check if the shop has an active charge.

I also do that every time the user goes through the app directly through shopify (not the inner pages). I then set the Recurring  charge_id to null in my DB if they have no active charge.

 

This way if they go to the inner pages of the app, I check for if the Recurring charge_id is null in the database and avoid doing an API call on every page.

Paul_Hughes1
Tourist
3 0 3

Definitely makes sense. One handy thing I'm noticing is that the Billing API does return the billing_on date, which means you could definitely limit the number of API calls that would need to get run by the cron on any given day (and then of course, like you say, run a confirmation if accessed from within the shop as well).