I want to retrieve the usage status of the recurring_application_charges and redirect to the subscription page if it’s not active, but I’m unable to retrieve the usage status.
I’m also trying to wrap my head around this. How would Remix app look like using managed pricing model. Docs say shopify hosts that subscription page and url https://admin.shopify.com/charges/{app_handle}/pricing_plans is provided, but I can’t seem to find any information on how to use it in Remix app. As an example with “Manual Pricing” I do
to check if subscription is active and redirect request page. I should probably redirect to https://admin.shopify.com/charges/{app_handle}/pricing_plans but this page is outside the app context and all redirects seem to fail. If I enter that url manually it all works of course. Any example would be very valuable.
I have faced the same problem you described, the Shopify documentation did not mention how to proceed having this Managed Pricing enabled.
What I ended up doing was:
Create you plans array in your code using the same name you have used when you have set the pricing plans
In the app main page loader you will be able to retrieve the subscription plans enabled, then you won’t be able to redirect to the price managed page from the loader but you can set on the settings that will be used front end the information regarding the plan and also the shop name.
In the front end side, having the properties related to the payment status on your settings object, you can redirect the user the managed payment page, eg:
useEffect(() => {
if (settings.redirectPayment) {
window?.top?.location.replace(`https://admin.shopify.com/store/${shopName}/charges/${appName}/pricing_plans`);
}
}, []);
It is just a workaround until they guide us into a solution.
That’s the way - it’s a modification to app.jsx with this:
// Check whether the store has an active subscription
const { hasActivePayment } = await billing.check();
// If there's no active subscription, redirect to the plan selection page...
if (!hasActivePayment) {
return redirect(`shopify://admin/charges/${appHandle}/pricing_plans`, {
target: "_top", // required since the URL is outside the embedded app scope
});
}
// ...Otherwise, continue loading the app as normal
return json({ apiKey: process.env.SHOPIFY_API_KEY || "" });
};