Solved

How to preserve trial days after reinstalling a Shopify app?

geobertz
Shopify Partner
27 0 22

Hello shopify community,

I am building a simple app, but I am having a problem with setting up the trial days.. I am using the latest node boilerplate where in i have to setup billing config upon installation.

const billingConfig = {
  "Premium": {
    interval: BillingInterval.Every30Days,
    amount: 1.99,
    currencyCode: "USD",
    trialDays: 21,
    replacementBehavior: BillingReplacementBehavior.ApplyImmediately,
    test: true,
  }
};

THE PROBLEM:

When a merchant has lets say 10days left.. after uninstalling and re-installing the app, the trial days resets to 21 days. Upon checking all the charges, upon uninstall status updates to "cancelled", if merchant re-installs the app, a new charge is being created with status 'active' upon confirming and trial days resets to 21 days. I dont want this to happen because they can have unlimited trial.

What is the best approach here, shall i not include billing config and leave undefined, when app loads shall i check database if the merchant has a charge record if not create a charge with 21 days trial then save to database, then if it uninstall the app i can use that data from my database to compute remaining days?

Im not really sure how this works.
20daysleft.png

after re-installl

21daysleft.png
Thank you. Appreciate help
geobertz
Accepted Solution (1)

oscprofessional
Shopify Partner
16116 2409 3125

This is an accepted solution.

Hi @geobertz ,

You can achieve this by saving the shop id or unique id to your database. That means, when any users install your app you should save users shop id or unique id to your database table and create some more field for status(active/inactive), start date(installed date) and end date(date after 21 days). 

For example : 

Suppose person A install the app, same time you have to save user's(person A) shop id with status 'Active' and start date + end date(21 days).

 

After installation he notified with 21 trial days.

 

Next after some days like 10th day he uninstall the app status should change to 'Inactive' and update start date(current date) you will get remaining days and save these days(ex: 11 days)

 

Next time when he reinstall app again then check for shop id if it is true then update start date and calculate end date with remaining days which you already having.  

 

Hope you get an idea, if you have any queries you can post here again.

Thanks....

Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: pallavi@oscprofessionals.com | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing | Oscp Upsell & Cross sell App : Free | Oscp Sales & Volume Discount App : Free | Custom Pricing Wholesale App : Free

View solution in original post

Replies 9 (9)

oscprofessional
Shopify Partner
16116 2409 3125

This is an accepted solution.

Hi @geobertz ,

You can achieve this by saving the shop id or unique id to your database. That means, when any users install your app you should save users shop id or unique id to your database table and create some more field for status(active/inactive), start date(installed date) and end date(date after 21 days). 

For example : 

Suppose person A install the app, same time you have to save user's(person A) shop id with status 'Active' and start date + end date(21 days).

 

After installation he notified with 21 trial days.

 

Next after some days like 10th day he uninstall the app status should change to 'Inactive' and update start date(current date) you will get remaining days and save these days(ex: 11 days)

 

Next time when he reinstall app again then check for shop id if it is true then update start date and calculate end date with remaining days which you already having.  

 

Hope you get an idea, if you have any queries you can post here again.

Thanks....

Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: pallavi@oscprofessionals.com | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing | Oscp Upsell & Cross sell App : Free | Oscp Sales & Volume Discount App : Free | Custom Pricing Wholesale App : Free
geobertz
Shopify Partner
27 0 22

Hi thank you for your response.

I get the idea, so my theory is correct.. Ill definitely try this..
I have another question though, how do we make an app 100% FREE?

There is no option in billing API to make it FREE.. cant set 0$ as price. and more than 1000 days as trial days.

geobertz
oscprofessional
Shopify Partner
16116 2409 3125

Hello @geobertz ,

Recently we launched custom pricing app and its free.

Login to your shopify partner account go to your app and select the option.

Please refer screen shot: 

oscprofessional_0-1677501010265.png

You can manage your app pricing here.

 

Thanks ......

Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: pallavi@oscprofessionals.com | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing | Oscp Upsell & Cross sell App : Free | Oscp Sales & Volume Discount App : Free | Custom Pricing Wholesale App : Free
geobertz
Shopify Partner
27 0 22

Oh i see and just set billing to undefined right? 
Thank you so much

geobertz
AndyHung
Shopify Partner
63 0 16

Hi @oscprofessional ,

I also setup 14-days trial, but I don't know when trial ends, how can I update remain trial days in database? Do you have solution for this?

geobertz
Shopify Partner
27 0 22

You have to check every time the merchant enters your app, compare current date and date of installation. You can redirect them to billing after the trial ends.

geobertz
temurbek
Shopify Partner
24 0 2

Hello, Can you please clarify one behavior?
Does Shopify handle it? I mean, every time the user uninstalls and reinstalls again, the trial day will apply again? 
Example: The user used the app for 20 days and the app has 21 days trial, so If a user uninstalls and installs again, Shopify gives 21 days trial again, right?

geobertz
Shopify Partner
27 0 22

Yep, it will will give them 21 days trial again.

That is why its important to save the initial installation date,

If they re-install, check your database if the store is already recorded with the initial installation date.

Compute how many days they still have for the trial, if they already used 21 days.. then you can redirect them to billing in short, they must have an active billing charge in order to proceed using the app

Goodluck!

geobertz
temurbek
Shopify Partner
24 0 2

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?