I've got a Turbo-enabled Rails app and a Turbo Native iOS app.
On the web app, you can purchase subscriptions via Stripe, and so I need to enable the iOS app users the ability to purchase within the app.
So far, I've got the following set up:
When in the native app, when the user hits the "Buy" button, the correct payment request is sent to Apple's servers and the "Purchase" interface pops up
Server notifications from Apple are set up such that an endpoint in my Rails app gets pinged when a subscription has been purchased, is renewed, or is cancelled with the receipt data. Right now, I'm just printing the JSON response to my logs.
What's the best way for me to connect the unique user ID from my web app to the Apple purchase?
What happens at the moment is that my Sandbox iCloud user is marked as subscribed, but that information is not connected to the app's logged in user, so they don't have access to the paid tier features.
This is the ideal workflow:
A user hits "Buy" in the app and confirms the payment
When I get a successful server notification from Apple I'm able to mark that user as paid and create a subscription object for them, storing the original transaction id and other relevant subscription information
The user is redirected to another page/view within the app once the purchase is complete
When Apple sends further server notifications, I can match up the original transaction id with the subscription in my Rails app DB and update the user's access/subscription as is necessary.
The main thing is linking the payment with the user in my Rails app backend.
Has anybody successfully set up such a workflow?
I'd love some guidance on how to approach it.
Thank you very much!