iTunes cross-platform IAP subscriptions - how does Netflix do it?

余生颓废 提交于 2019-11-28 17:06:10

I know this is old, but Apple recently introduced Status Update Notifactions which accomplishes what the OP asked for via webhooks:

  1. Configure Apple to send notifications to your specified endpoint. (Apple's small guide)
  2. Handle the JSON object that's sent via HTTP POST from the App Store and validate latest receipt.
  3. Update/save data to your database.
  4. Respond with a 200 status code to report a success.

You'll be able to handle the following notification types: INITIAL_BUY, CANCEL, RENEWAL, INTERACTIVE_RENEWAL, DID_CHANGE_RENEWAL_PREFERENCE

The documentation in the link above explains implementation and types in more detail.

For the initial subscription purchase:

  1. User initiates a purchase on the iDevice
  2. Device contacts Apple, Apple issues a receipt and sends it back to the device
  3. The device sends the receipt to my server
  4. The server validates that the receipt is legit through Apple's receipt validation API
  5. Once the receipt is validated, the server stores it in my DB
  6. The server responds to the app saying it's all good

To keep the server in sync with the iTunes subscription:

  1. Setup a cron job to retrieve expiring receipts from the DB on a daily basis or something
  2. Validate each receipt with Apple
  3. Apple will respond with an updated version of the receipt that contains details regarding whether or not the subscription was canceled/renewed/etc.
  4. Server replaces the original receipt with this updated version in the DB

Now if someone logs into their account on a Roku or some other device, the subscription can be honored because my DB is the source of truth.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!