Using remix billing API to set calculated trial days

Solved

Using remix billing API to set calculated trial days

andrew_upo
Shopify Partner
7 1 1

Hey, everybody!
I don't know where to turn, so I'll write here. I would like to get clarifications from the developers of Billing API.
1. In the documentation on using billing API for remix it seems to be a mistake, lineItems is specified as an array, but written as an object (see screenshot).

andrew_upo_0-1718010438049.png
2. Can I write billing plans in shopify.server.js, and then on pages in action when calling await billing.require(...) pass here the calculated number of test days?
For example, if a user installed an app, got a trial period of 10 days, uninstalled the application after 3 days, so that the next time he installs it, I can give him only 7 days of trial period, but all 10.
Or is it necessary to use only GraphQL queries for such a case?

 

Accepted Solution (1)

andrew_upo
Shopify Partner
7 1 1

This is an accepted solution.

I realized that I can pass the calculated trial days to the function for remix.

await
billing.require({
      plans: [plan],
      isTest: true,
      trialDays: calculatedDays,
      onFailure: async () => billing.request({ plan: plan, isTest: true, trialDays: calculatedDays, }),
      returnUrl: ``,
    });

View solution in original post

Reply 1 (1)

andrew_upo
Shopify Partner
7 1 1

This is an accepted solution.

I realized that I can pass the calculated trial days to the function for remix.

await
billing.require({
      plans: [plan],
      isTest: true,
      trialDays: calculatedDays,
      onFailure: async () => billing.request({ plan: plan, isTest: true, trialDays: calculatedDays, }),
      returnUrl: ``,
    });