How are free trial days left calculated by shopify?

sharanbrar
Visitor
1 0 0

I have created a 7 day free trial for new app users and want to show inside the app how many days of free trial are left. 
I reduce the number of days after every 24 hours from when the app was installed, but have noticed that shopify calculates the days left in a different way and sometimes reduces the days left earlier than I do, which causes confusion for the users.
Does anyone understands how shopify calculates the days left?

Replies 3 (3)

bburke4
Tourist
4 1 0

I just check the 

"trial_ends_on"=>"2021-01-01",

field in the RecurringApplicationCharge response object. I believe it is set when the charge is activated

Chandra_Meghwal
Shopify Partner
2 0 0

@bburke4  Knowing the trial end date only (if time is not given along with date), how can we get how (at what time) Shopify daily updates trial days left?

 

@sharanbrar  Have you resolved this?

RavindraPatel
Shopify Partner
29 1 5

Hi @sharanbrar @bburke4 @Chandra_Meghwal 

The trial ends on calculated based on the RecurringApplicationCharge's activation time.

So simple formula for

trial_ends_on = datetime when charge activated + trial_days


For example: for any application, I created a RecurringApplicationCharge with 10 trial days on 2022-12-07 10:07:40 IST. When the user accepts the charge it will activate so the charge activated on 2022-12-07 10:17:23 IST.


So their trial will expire on = 2022-12-07 10:17:23 + 10 days = 2022-12-17 10:17:23 IST

Also, you can count how many trial days are left based on the current date.