I'm implementing subscriptions in my app using RevenueCat; however, I had already implemented consumable products, validating them on my server.
When I added RevenueCat to the project, I noticed that when a consumable product was purchased, it was automatically consumed, and when the user visited the purchase verification screen (to consume it and gain the content), an error occurred on my server because the purchase had already been consumed by RevenueCat.
I discovered that I can use Purchases.sharedInstance.finishTransactions = false
to handle consumable logic as before. However, by doing this, I'll need to manage subscription logic on my server as well, and that's not what I want.
After running some tests, I think I found a way to handle this. Let me explain what I did:
- When I initialize RevenueCat, I call
Purchases.sharedInstance.finishTransactions = false
. - When I open my subscription PayWall, I call
Purchases.sharedInstance.finishTransactions = true
. This ensures that when purchasing a subscription, everything runs smoothly with RevenueCat. - When the user opens any activity that lists consumable products like coins, credits, etc., I call
Purchases.sharedInstance.finishTransactions = false
again. This allows me to handle the consumable purchase on my server as I always did before adding RevenueCat to the project.
I'd like to know if this approach is secure and if it's appropriate to change the value of finishTransactions
when necessary. It worked correctly in my tests, but I would appreciate validation from someone on the RevenueCat team.
Thank you!