Hi,
I am developing a Shopify app and looking to add a recurring charge of just 1 USD every month. I just want to add one plan and I am unable to find a proper step by step guide to get this. I followed https://workshops.shopify.dev/workshops/usage-billing#4 and now I can see the app is asking for approval when I try to install my app. But I am able to access my app even after I click on cancel button.
Here is the code I added in my code [index.js]
import { BillingInterval } from "@shopify/shopify-api";
export const billingConfig = {
"Monthly charge": {
amount: 1.00,
currencyCode: "USD",
interval: BillingInterval.Every30Days,
usageTerms: "One euro per button click",
},
};
app.get(
shopify.config.auth.callbackPath,
shopify.auth.callback(),
async (req, res, next) => {
const plans = Object.keys(billingConfig);
const session = res.locals.shopify.session;
const hasPayment = await shopify.api.billing.check({
session,
plans: plans,
isTest: true,
});
if (hasPayment) {
next();
} else {
res.redirect(
await shopify.api.billing.request({
session,
plan: plans[0],
isTest: true,
}),
);
}
},
shopify.redirectToShopifyOrAppRoot()
);
Can someone please help me understand how to add recurring charge for my app code ?