IAP has been officially released ! šŸš€

First of all, the Purchase Items is a list of all purchases made by the email address used in the mobile device.

This means that it starts simple for the first app but then goes to be complicated when you have more that a single app with In-App Purchase details.

So you need to be sure you are reading the correct purchase item and from their you need to poll the receipt from the App/Play Store to read the details of the purchase and read the expiry date. Compare the expiration date of the purchase with the current day to determine what to do next.

See this from App Store to see how to read receipts.
https://developer.apple.com/documentation/storekit/original_api_for_in-app_purchase/validating_receipts_with_the_app_store

1 Like

@muneer @jared @cassandra Thank you for your response.
Unfortunately Iā€™m at a stoping point. Iā€™m not a programmer nor do I have computer science schooling. The validating_receipts link is over my head.

Ultimately I need specific thunkable block examples of someone already doing these. Iā€™ll have to chalk it up to a ā€˜winā€™ that I was able to figure out how to execute purchases on apple/android store. Perhaps that is enough for now.

I may learn more about Object blocks as they seem important here. Thank you again for your help.

1 Like

One workaround, which is not a good way, I must admit, is to actually record the subscription in your own database (Google sheet, Airtable or Firebase) and record all relevant information you need such as subscription start time and compute the subscription end time.

Next time the user logs on to the app you need to read the data from your own database and decide if you open the premium services or not.

Of course this is not a good solution because App Store and Play Store allows users to cancel the subscription from the user account management not from your app and therefore you need to retrieve such information from the Store directly to know if the subscription is cancelled and if the Store has automatically renewed the subscription.

Happy Thunking!

4 Likes

Can you or anyone provide the blocks to do this? Honestly I spent the whole weekend trying to figure this out. With nothing to show. @muneer @domhnallohanlon @cassandra

Getting the blocks to check if the user has an active subscription, yes or no. It not only would unblock me but it would enable me to launch my edu app made with thunkable and propel me into creating more! Thank you anyone and everyone thank you!

1 Like

A good catch here. You are trying to use the Purchase History or Get Most Recent Active purchase and both gives you essential information and the receipt ID which you should query the AppStore and get the details of the purchase.

As of now, Thunkable does not have a block to retrieve that and I believe they should not attempt to make one as Apple/Google recommends that this should be done by a server service outside of the app.

See this WARNING

1 Like

How do I do this with Thunkable blocks?

How do I do this with Thunkable blocks? Using a ā€˜server service outsideā€™ how do I achieve this?

Thank you :pray:

1 Like

The short answer for both is:
No blocks available in Thunkable.

1 Like

Iā€™m confused, then how do you do this?

1 Like

For a server side code, you need to create that server side code and then the server you have chosen will have more or less instructions how to connect it to other apps/platforms.

Right, I get it as @muneer is saying ā€“ you canā€™t verify the subscription status from the stores directly and instead you should record it and keep tabs on it on, say, Firebase. But, as @muneer also kindly pointed out, the stores allow for the user to cancel the subscription, which then doesnā€™t automatically inform the app and the connected backend, such as Firebase. So the user could activate the subscription, and the app would record this on Firebase, but if the user then cancelled the subscription from the store, the app/Firebase backend would have no clue about this.

How on earth do you then solve this problemā€¦ There must be some way to do this, as evidently there are a ton of subscription apps out there. Does anyone have an idea. :confused:

Edit. Ah, it seems that youā€™d need to utilize your own server to even confirm the subscription in the first place (didnā€™t read the thread carefully enough), i.e. to avoid the subscription of being cancelled. Well, I must also admit that I donā€™t have a clue about setting up such a connection via my own server. Maybe the promised and upcoming (more extensive) Thunkable docs on IAP could address these issues, perhaps even offer to set up the server connection automatically (via Thunkable servers)?

2 Likes

I must say that this situation is not that bad. If you recorded the subscription in your own database (Firebase for example) then you will continue giving premium access to the user for the length of the subscription whether the user cancelled or not.

The issue becomes more complicated if the subscription fee is refunded due to Store rules and regulations and you are not aware. In this case you have provided premium access for free.

Another more important situation is when the Store automatically renews the subscription, how would you know if you should extend the premium access or not???

Typically, you will have the following:

  • You will create a server side code (app) to inquire the Store using the Original Order ID and Transaction Receipt ID.
  • Every time the app starts, you will get these info from the blocks and pass them to your server app to get the required info from the Store. You would most probably use the Web API block in Thunkable to communicate with your server side app.
  • Your server side app will pass back the required info to your app to decide what to show and what to hide.

A good candidate for server side apps is GCP (Google Cloud Platform) which you can design your code on it. There are many other servers like Heroku which can server for the same. I made my code inside Firebase using the Firebase Functions which is a Node.js server but Google now recommends porting it to GCP.

Hope this is clear.

1 Like

Got it, thanks! But the real problem for me is that I havenā€™t never created such cloud functions, nor operated with Node.js. Well, of course one can always learn. :slight_smile:

But, may I just ask to clarifyā€“have you, indeed, built such a system for Thunkable subscriptions? Or are you talking just more generally about the possibilities for integration.

And if you have built such a system (for Thunkable subscriptions), could you perhaps offer some guidance as to how me or the others could set up similar systems of our own? Like some line of code for the cloud functions etc.

Of course, ultimately, this is something the Thunkable docs could/should address (when theyā€™re updated for IAP to be more comprehensive), but if you can provide anything at this point, @muneer , it would certainly help us all strugling with implementing the IAP.

1 Like

As I have said in my last post YES. I was saving subscriptions/ one time payments in Firebase so I used Firebase Functions to inquire from the Play Store.

You will need to include the relevant libraries (SDK)
Provide your developer access token and then issue this command to get the detailed info

"https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.your-app-name/purchases/subscriptions/your-subscription-name/tokens/".[ Your Transaction Receipt ID];

You should get the result in JSON and you could decide to continue your necessary checking in the server side app or just pass the info to your Thunkable app to decide what to do.

1 Like

Got it, big thanks for this!

Although, at the end of the day, it will still require a lot of figuring out for how to implement this all in practiceā€“also for iOS. Not afraid of trying things out myself, but Iā€™m very much hoping that the updated IAP docs would cover these issues and offer at least one concrete example, from start to finish (including, for instance, setting up the Firebase-side of things), for how to build such a subscription service for Android as well as iOS. It just doesnā€™t make sense that weā€™re all figuring these things out piecemeal and on our own. :slight_smile:

Ping @jared

1 Like

I havenā€™t done the iOS part therefore I cannot comment on it at this time.

For more details about subscription in Android

If you are doing a subscription, isnā€™t that what this block is for? If user has an active sub it will return the info. If they donā€™t have an active sub it wonā€™t return any data? If user got a refund in any way that would affect what this block returns?

1 Like

One thing to note that this block name is confusing. From experience, this block returns nothing for One Time Payment and only for Subscription.

The other thing, again, it gives the purchase done by the app and does not give enough details.

Another issue, this block will not reflect purchases that are in a state of on hold, blocked, cancelled, paused, renewed, expired which will lead you to the same issue we are discussing.

Server Side App

This will show you how to start a GCP to retrieve subscription info.

2 Likes

Excuse me, were you able to work with the One Time Purchase block? Since I couldnā€™t get it to work on iOS

1 Like

See my detailed explanation for it.

There was an issue with that block that occurred after our upgrade to expo 43. The error has since been corrected! Sorry for any downtime this caused any of you!

2 Likes