Hi everyone,
We’re encountering an intermittent issue with our Shopify app’s Billing API integration when trying to create or require a subscription.
Here’s the scenario:
We’re using billing.require() as follows:
// Available plans
const ESSENTIAL_PLAN = ‘Essential Plan’;
const ADVANCED_PLAN = ‘Advanced Plan’;
await billing.require({
plans: [ESSENTIAL_PLAN, ADVANCED_PLAN],
isTest: true,
returnUrl: ‘https://test-discounts.myshopify.com/admin/apps/test-discount/app/subscriptions’,
onFailure: async () => billing.request({
plan: plan === “essential” ? ESSENTIAL_PLAN :
plan === “advanced” ? ADVANCED_PLAN : “”,
returnUrl,
isTest,
}),
});
When the subscription process starts, we sometimes get the following error before any redirect happens:
Billing error: Response {
size: 0,
status: 401,
statusText: ‘Unauthorized’,
headers: {
‘x-shopify-api-request-failure-reauthorize-url’:
‘https://demo-sales-volume-discounts.myshopify.com/admin/charges/.../confirm_recurring_application_charge?…’
}
}
After this “Application Error” appears, if we refresh the page and retry, it works perfectly fine.
What We’ve Noticed
-
The issue doesn’t happen consistently, it appears intermittently.
-
It seems related to reauthorization (
401 Unauthorized+x-shopify-api-request-failure-reauthorize-urlheader). -
Once reloaded, the app is authorized again and the billing flow completes successfully.
What We’d Like to Know
-
Has anyone else experienced this intermittent
401 Unauthorizedwhen creating billing subscriptions? -
Is there a recommended way to handle or preempt reauthorization before calling
billing.require()orbilling.request()? -
Could this be related to app bridge session handling or token expiration timing?
Any insights or workarounds would be greatly appreciated!
