We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

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

Replies 2 (2)

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: ``,
    });
Adityaaa
Shopify Partner
5 0 0

@andrew_upo where did you give calculatedDays value?