We are trying to work out how the subscription system works with Zero. On the page - TenantRegistration/SelectEdition the page has editions and features. The user selects an edition, if the option is to buy now the logic is straightforward. If the option is for a free trial we are having difficulty testing how the system works. Could someone help me with what Zero is doing in the back end given the folllowing scenario.
- Our edition has a 14 day trial and a 3 day "grace period".
- We create a new tenant on a 14 day trial.
- We stop Zero.
- We go into the database and backdate the CreationTime of the tenant to 18 days ago (we understand CreationTime is used for subscription start, which makes sense).
- As the trial is now ended (14 days plus 3 day grace period) we emulate this by setting IsInTrialPeriod to false.
- We also set the subscription date backwards to before today.
- We start Zero.
- We can still sign in as the tenant and continue using the system - what are we doing wrong?
At some time in the past I remember setting this up on a test machine and letting it run. Somehere there is a background job which fires off emails warning that the trial period is about to end and then sends an email telling the user the grace period has started. Where is the code for these background emails and does it send an email to tell the user the trial is ended - does it give a final option to pay at this stage?
Zero places a reminder on header bar reminding the tenant that the trial is about to end and then states that the trial ended -NN days ago, how is it possible to see a message telling me that the trial is ended and the grace period is finished but I can still continue to work with the system if I really want to? At some stage Zero flicks a switch to make the tenant inactive after which the sub-domain is no longer reachable, when does this happen and what code carries out this task?
Can someone tell me exactly what is happening during trial periods and what is meant to happen when it has finished. Moreover, can someone tell me how to test it without having to wait for 10 days or whatever trial period the system is set to? I can't find the code anywhere and have looked through this in great depth this afteroon with a colleague.
My scenario is such that, At the end of the test trial and grace period, I want the system to notify the user that the trial and grace period has ended and invoke the Stripe payment system. Can someone help in pointing me in the right direction to get this done?
4 Answer(s)
-
0
Hello @bobingham
ASP.NET ZERO ends subscription with checking their SubscriptionEndDateUtc. If SubscriptionEndDateUtc is passed tenant will be inactive.
See: https://github.com/aspnetzero/aspnet-zero-core/blob/89589ba9cd202205d9e7102c6111c7f373c824f4/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/MultiTenancy/SubscriptionExpirationCheckWorker.cs#L44-L98
So if your
ubscriptionEndDateUtc
s null your trial will be unlimited. I created an issue about it. https://github.com/aspnetzero/aspnet-zero-core/issues/3003You can check TenantManager/EndSubscriptionAsync to see what you need to disable. To test it. https://github.com/aspnetzero/aspnet-zero-core/blob/89589ba9cd202205d9e7102c6111c7f373c824f4/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/MultiTenancy/TenantManager.cs#L267-L303
-
0
Hi @demirmusa, Thanks for getting back so promptly. That's perfect for what I need to investigate, at least I now know where to look. Where does the system trigger
SubscriptionExpireEmailNotifierWorker.DoWork()
, I can see the variableCheckPeriodAsMilliseconds
is set to every day at the top ofSubscriptionExpireEmailNotifierWorker
. I haven't been able to find documentation on how these background jobs are invoked. -
0
It is a background worker provided by aspnetboilerplate . Here is a document: https://aspnetboilerplate.com/Pages/Documents/Background-Jobs-And-Workers#background-workers
-
0
Hi @demirmusa, now I understand - I have always used Hangfire for my background jobs so took me a little while to figure out how the Zero implementation works. Now I can see it, thanks to your help.