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

前端 未结 2 1978
天命终不由人
天命终不由人 2020-12-12 23:32

I\'m creating a service which allows users to register on any number of devices (web, Android, Roku, iOS, Apple TV), and then purchase a monthly subscription to watch video

2条回答
  •  一生所求
    2020-12-13 00:21

    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.

提交回复
热议问题