Shopify API 2021-01 Deprecated calls to Recurring Application Charge

20 Jan 2021 by

The Promo Banner app server is build using the popular Ruby on Rails framework. We use the shopify_app gem published by Shopify to integrate with their API. The Shopify API releases a new version a few times a year, and sometimes these new versions introduce changes to behavior that require updates to how the gem is used. The 2021-01 release was no exception, but it was the first time Promo Banner found a warning on the partner dashboard.

API health. Fix by Oct 1.

A deeper dive into the notification leads us to this message from Shopify:

Recurring Application Charge. Admin • REST

Your app is subject to breaking changes. Check the release notes to keep your app up to date. [View change](

When we follow the link to “View change” we see a list of breaking changes.

Auto-activate billing charges using the REST Admin API

We've removed the accepted value for the status field and the activate endpoint on the ApplicationCharge and RecurringApplicationCharge resources.

As of the 2021-01 API version, when a merchant accepts a charge, the charge immediately transitions from pending to active. This means that you no longer need to activate the charge to finalize it.

What it’s telling us is that the charge should already be active by the time our callback fetches the resource from their API. The deprecated call is happening when we are trying to activate the charge - this is the API that is going away by October 2021.

So how did we fix it? All of the current developer tutorials use the GraphQL Billing API to manage application charges, but we’re still using the REST API. So here’s our callback code (it is called after the merchant accepts the charge) in git diff format to see what we had before and what we changed to fix this deprecated call.

   def callback
     @charge = ShopifyAPI::RecurringApplicationCharge.find(params[:charge_id])
-    if @charge&.status == 'accepted'
-      @charge.activate
-      shop.upgrade!
-    end
+    shop.upgrade! if @charge&.status == 'active'
     redirect_to root_path

That’s it! Now the shop is upgraded if the charge is already “active”, no need to make another API call to activate the charge.

Install Promo Banner today