export async function loader({ request }) {
const { billing: billingApi, session } = await authenticate.admin(request);
console.log(“–session—”, session);
let currentPlan = FREE_PLAN;
let buildsUsed = 0;
let appSubscriptions = [];
try {
console.log(“PRO_PLAN:”, PRO_PLAN);
console.log(“MAX_PLAN:”, MAX_PLAN);
console.log(“--------------------------------------”);
console.log(“STARTER_PLAN:”, STARTER_PLAN);
console.log(“IS_TEST_MODE:”, IS_TEST_MODE);
// console.log(“Billing config keys:”, Object.keys(shopify.billing.config));
const billingCheck = await billingApi.check({
plans: [STARTER_PLAN],
isTest: IS_TEST_MODE,
});
appSubscriptions = billingCheck?.appSubscriptions || [];
if (billingCheck?.hasActivePayment && appSubscriptions.length > 0) {
currentPlan = appSubscriptions[0]?.name || FREE_PLAN;
}
} catch (error) {
console.error(“Billing check failed:”, error);
}
return Response.json({
currentPlan,
buildsUsed,
appSubscriptions,
plans: APP_PLANS || [],
});
}
while using the above code in my shopify public app a getting error like
Billing check failed: HttpResponseError: Received an error response (403 Forbidden) from
Shopify:
16:47:18 │ React Router │ {
16:47:18 │ React Router │ “networkStatusCode”: 403,
16:47:18 │ React Router │ “message”: “GraphQL Client: Forbidden”,
16:47:18 │ React Router │ “response”: {}
16:47:18 │ React Router │ }