How can i add multiple plan in shopify billing api?

Topic summary

The discussion centers on implementing multiple billing plans using Shopify’s billing API, specifically the shopify.api.billing.request method.

Initial Problem:
The original poster shared code attempting to add multiple plans but encountered issues with the implementation, including reversed/garbled text in their code snippet.

Key Solution Provided:

  • Users must select a plan before calling shopify.api.billing.request
  • Reference the multi-plan setup documentation
  • Implementation requires creating a /api/select-plan endpoint where users choose their desired plan

Follow-up Questions:

  1. Whether custom UI is needed for plan selection (Answer: Yes, no built-in UI exists)
  2. Choosing between RecurringApplicationCharge REST API vs. shopify.billing.request (Answer: Use shopify.billing.request as it calls the correct endpoint internally)
  3. Whether multiple API calls are acceptable (Answer: Should be avoided)
  4. How to handle trial days (Answer: Add as an additional parameter to shopify.billing.request)

Status: The conversation provides working guidance with code references, though some technical details remain for the original poster to implement.

Summarized with AI on November 20. AI used: claude-sonnet-4-5-20250929.

export async function requestBilling(res, next) {
const plans = Object.keys(billingConfig);
const session = getCurrentSession(res);
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,
},
{
session,
plan: plans[1],
isTest: true,
}
)
);
}
}

export const billingConfig = {
“My plan1”: {
amount: 100.0,
currencyCode: “USD”,
interval: BillingInterval.Every30Days,
trialDays: 30
}
};

Following this documentation page Javascript shopify.billing.request → Multi-plan setup - charge based on user selection you have to let the user select the plan he wants before calling shopify.api.billing.request

app.get('/auth/callback', async () => {
  const callback = await shopify.auth.callback({
    rawRequest: req,
    rawResponse: res,
  });

  // Check if we require payment, using shopify.billing.check()

  const confirmationUrl = await shopify.billing.request({
    session: callback.session,
    plan: 'My billing plan',
    isTest: true,
  });

  res.redirect(confirmationUrl);
});

Does it help?

Hello @snakecase ,
Thank you for providing a solution to my question. I appreciate your assistance. Additionally, I have a few more questions.

As per documentation we need to create a post api `/api/select-plan`.

1. Do we need to create the UI for select-plan api?
2. We are using RecurringApplicationCharge API of shopify.
 [https://shopify.dev/docs/api/admin-rest/2023-04/resources/recurringapplicationcharge](https://shopify.dev/docs/api/admin-rest/2023-04/resources/recurringapplicationcharge),)
    what is the preferred way? 
    Do we need to call the shopify.billing.request API or are we correct here ?
3. Can we call the shopify.billing.request API multiple time?
4. How to handle trial days with shopify.billing.request API

I’m going to try to respond as best as I can:

  1. I’m not aware of any built-in UI for that, so I would reply yes, you do need to create the UI. Maybe someone else going through this thread can add an input?

  2. We are not using the Javascript framework but from my reading of the code you should use shopify.billing.request. This request under the hood call the right endpoint (cf. shopify-api-js/lib/billing/request.ts)

  3. I don’t see why you should do. I think it should be avoided.

  4. Trial days are one more parameter to add to you call to shopify.billing.request. cf. code shopify-api-js/lib/billing/types.ts)

I hope it is going to help you.

1 Like