1

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!

Noddy
  • 11
  • 1
  • 2

1 Answers1

2

This is the worklow as I would do it

  1. Logged-in user makes an in-app-purchase
  2. Purchase receipt is sent via request to backend
  3. Backend verifies this receipt and saves info to database (i.a. the user_id, transaction_id etc.)
  4. You can listen to AppStore Server Notifications and get informed on refund, cancel, updates.... For every event you can search in your database for the transaction_id to get the corresponsing user
Jonas Reif
  • 324
  • 2
  • 5