A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
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
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.