I'm building an iOS app whose backend is served by a Rails app. The majority of the iOS app is a wrapper around a Ruby web client.
Users will be able to access premium content on all platforms so I need to store subscription data against the unique user ID from my Rails database.
Right now I have it set up such that a user can make an in-app purchase for a subscription and Apple will send server notifications to my Rails server.
The issue is connecting a Subscription
object on my Rails app with the correct user ID attached.
Right now, the user, even though they've paid, does not have any access to the premium features since the Rails server has not been able to mark that user as paid.
They also remain on the "Buy" page after a successful purchase.
Ideally, upon successful payment, they are marked as 'paid' in the Rails app and are then taken to a suitable page. Or, upon a failed payment, they are shown a suitable error.
@oscaretu's answer here — https://developer.apple.com/forums/thread/674738 — is really helpful (I can just assume the user has access to paid content until I can connect the receipt original_transaction_id with the unique user ID) but I still don't understand the idea of "asking a user to connect to the app" given they will already be in the app (having just made the purchase).
Should I be storing the Rails user ID in the iOS app independent of any in-app purchases? If so, how/where?
After the INITIAL_BUY
notification, how do I immediately trigger a second request to my Rails server, somehow passing in the correct user ID from my Rails app?
To ensure a smooth user flow, how do I direct the user to another page upon successful payment?
Thank you so much to anybody who can take the time to help me out. I really appreciate it!