How to preserve trial days after reinstalling a Shopify app?

Topic summary

Issue: Using Shopify’s billingConfig with trialDays (e.g., 21) resets the trial to full when a merchant uninstalls and reinstalls, creating a new active charge and enabling unlimited trials.

Proposed approach: Persist trial state in your own database. Save shop ID, status (active/inactive), start date (initial install), end date (start+21), and remaining days. On uninstall, mark inactive and compute/save remaining days. On reinstall, look up the shop; if time remains, set the new charge to that remaining trial or let them continue; if exhausted, redirect to billing. Practically, recompute remaining days on each app entry by comparing current date to initial install.

Free app: Set pricing to Free in the Shopify Partner Dashboard (App pricing settings) and omit in-app billing (billing undefined).

Clarifications: Shopify does grant a new trial on reinstall by default; enforcing a single trial requires your own persistence logic. Screenshots simply illustrate the reset behavior.

Open item: A question about how currentPeriodEnd is computed when trials exist in getCurrentSubscription was asked but not answered. The thread remains partially unresolved on that specific detail.

Summarized with AI on December 28. AI used: gpt-5.

Thank you very much for your quick response
Can you help me with currentPeriodEnd
If my application has 21 days of the free trial, what will be the value of the currentPeriodEnd field in the getCurrentSubscription query?
Without trial days, I will be equal to (for a monthly subscription): the subscription created date + 30 days, how about with trial days?