iosiphonein-app-purchaseapp-store-connectreceipt-validation

Notify server with IOS in-app purchase events (renewed,cancelled..etc)


I'm using auto recurring subscriptions in my app in my app,I need to change the subscription status if recurring fails from iOS.

I am following this documentation, but there are a few things that are still not clear to me:


Solution

  • Here are the steps I take the user to subscribe:

    1. Ask the user to sign in. If they don't sign in they can't subscribe.
    2. Send the app receipt to my server and store it there. If this fails they can't subscribe. This need this to validate get the latest_receipt info from the server at any time.
    3. The user subscribes through iTunes.
    4. Validate their receipt with the app store and check the latest_receipt to make sure they are subscribed. (This is done server side)
    5. Repeat step 4 periodically to make sure they are still subscribed

    So to answer your questions:

    What if my server missed the post data from iOS?

    Since I get the app receipt from the user before they subscribe I can check the with itunes directly from my sever any time and get the status of their subscription.

    How do I know if the subscription got renewed?

    Since you have the user receipt on your server, you can use it to get the latest receipt from apple and check the current status of the subscription. Here is how you do it Validating Receipts With the App Store

    How do I link my app user memberId (unique id) to the transaction?

    You could use the "Original Transaction Identifier" from the receipt as a unique id. This value is the same for all receipts that have been generated for a specific subscription

    What is the difference between latest_receipt form iOS post data(server to server notification) and bundle receipt url after purchase?

    When you send a receipt to the app store to be validated, it will return a JSON representation of the receipt that was send, this can be found in the "receipt" field. If your receipt contains subscriptions you will get "latest_receipt" and "latest_receipt_info" fields. These fields are useful when checking whether an auto-renewable subscription is currently active. If the bundle receipt is up to date then the "receipt" and "latest_receipt" will be the same.