How to validate in app purchase on server?

Asked on 2024-07-30

1 search

To validate an in-app purchase on the server, you can follow these steps using the App Store server APIs:

  1. Receive the Signed Transaction Info: When a customer makes a purchase, your app sends the signed transaction info to your server. This info is crucial for validating the purchase.

  2. Verify the Signature: Your server should verify the signature of the transaction info to ensure its authenticity. This can be done using the App Store server library, which is available for Java, Node, Python, and Swift.

  3. Grant Content: Once the transaction is verified, your server grants the user access to the purchased content. For example, if the purchase is for in-game currency, update the user's balance on your server.

  4. Mark Transaction as Finished: Signal back to your app that the content has been granted, and the app should mark the transaction as finished. This indicates to the App Store that the purchase is complete and the customer can make another purchase.

  5. Handle Refunds: If a customer requests a refund, the App Store server may send a consumption request notification to your server. You can respond by calling the send consumption information endpoint with the necessary details. The App Store will then decide on the refund and notify your server of the result.

For more detailed information, you can refer to the session Explore App Store server APIs for In-App Purchase at the 06:45 mark.

Relevant Session