How do I write a code(blocks) where my app will auto check the paid subscription from database and then give access to full functionality?

When user log in to my app, he will be given 7 days trail to use the app n later user need to pay subscription price to use the functions of the app.

So everytime they open the app or if they minimize the app for 5 min n then maximize the app, the app by itself need to auto check if the user have 7 days trial left, if not then did they pay or not

Then only open the functions or else give a msg that they need to purchase or x number of trial days left

If anyone can provide me the blocks or a video

Thanq in advance

Happy thunkable

1 Like

There are no blocks to do such particular process. You need to do it by your own.

First decide what kind of logging system you will use, yours or the SignIn component of Thunkable. If you decide to use the component in Thunkable then you have to first create a Firebase account to use the SignIn component. There are sample projects as well as video tutorials to use it.

Next you need to decide if you will continue to use Firebase as your database to store user activities or you would prefer a table like database such as Google sheet or Airtable

After deciding on the above two then you start building your coding blocks to check on number of days from first login or number of days from last payment.

[Edit]
How are you managing the payment? Currently In App Purchase feature is not available. This means you need to code the integration of a payment system and the service provided should be allowed by Google/Apple to use external payment systems.

2 Likes

For the 7-days trial, you first need a stored variable that has the date that they first started the free trial.
Next, you’re going to need to use the “Seconds since 1970” block to do a little math. If it’s been 7 days since the stored var’s value, then you can have the subscription end.

4 Likes

If you are doing everything locally and not creating a database, you can create something like a subKey in a stored variable, like what you get when you buy a software and you enter in a licences key. For payments, you could try setting up an exterior payment method like Stripe, Paypal, Square, ect. and send them a confirmation email with the Paid license key for them to enter into the app.

3 Likes

Although stored variable lends itself to such condition it has a major drawback. It is stored in the device with the app and is wiped out when the app is uninstalled.

So, if I was one of the users of this app, the stored variable method will be a bonus on my side. I just have to install the app, register for free trial, use it for 7 days and then uninstall the app to get rid of registration info in the stored variable and innsall again to use it for another 7 days. Not ethical but it happens.

3 Likes

But there is a sign in, so people have to sign in to use the app. The only way around that is using a new log in, and that is a way around it all. So if someone reinstalls the app and uses the same login, it would lock them out without a key. Someone only gets a key when they pay, so the app just checks the user’s first login date, and does the math like @jonathonschnoor6x4b5 said.

3 Likes

Yes, and therefore does not need to rely on stored variables.

If you use Seconds since 1970 then just add the number of user’s first login to 86400 multiplied by the number of days for the trail or subscription to check if the time has expired.

1 Like

Yes, that makes sense. The point of the subscription key that I was mentioning was referring to whether or not that person is paid. Not about the trial is over. Sorry if I didn’t clarify that.

EDIT
At that point, One could just add another data column in the database for that. The one thing I’m trying to figure out is how the database communicates with the payment system.

1 Like

@muneer To a different part of this post, I found this docs page which links Firebase and the payment company Stripe. Do you think this could be incorporated?
https://firebase.google.com/docs/use-cases/payments

1 Like

I created my Stripe, PayTab and BahrainPay payment modules and connect them to Firebase but have not created all options. I made only the options that were required by the client.

1 Like

Sorry, what do you mean by this? Were you able to get something built to accept payments and store info via Firebase?

1 Like

Yes, I did and already in use. I was just saying that it does not cover all features in the payment platform. I only coded what I required for the app.

1 Like

Cool! It sounds like this is something you set up beforehand and not with the information in the link I found? Would you be able to share your code, or at least an outline of it so other users who are looking to process payments can use it as a guide? I have had questions on payment options before, but I haven’t had a direct use for it, YET!

2 Likes

Sure,
Will do that when next using the computer. It’s now half an hour before midnight my time.

2 Likes

This is true. Rather, what you could do instead, you could have it send to the database when the trial started.

If you’re not going to use the database, then stored vars are your best bet :frowning:

2 Likes