How can I add Test Charge for Development stores in Public APP
So it creates
Real charge IF store is live
Test charge IF store is developer. I am currently handling billing like this:
export const loader = async ({ request }) => {
const { admin, billing, session } = await authenticate.admin(request);
const { shop } = session;
const subscriptions = await getSubscriptionStatus(admin.graphql);
const { activeSubscriptions } = subscriptions.data.app.installation;
if (activeSubscriptions.length < 1) {
await billing.require({
plans: [MONTHLY_PLAN],
isTest: false,
onFailure: async () =>
billing.request({
plan: MONTHLY_PLAN,
returnUrl: `https://${shop}/admin/apps/bbd-big-bulk-discount/app`,
isTest: false
}),
});
}
return json({ apiKey: process.env.SHOPIFY_API_KEY || "" });
};