how to verify a storekit 2 transaction

Generated on 9/14/2024

1 search

To verify a StoreKit 2 transaction, you can utilize the App Store server APIs. Here's a general approach based on the information from the WWDC sessions:

  1. Receive Notifications: When a purchase is made, the App Store server sends a notification to your server. This notification includes a signed transaction.

  2. Verify and Decode: Use a signed data verifier to verify and decode the payload of the notification. This will help you ensure the authenticity of the transaction data.

  3. Link Transaction Data: You can link the transaction data to the customer using the app account token set during the purchase. This does not require the device to be involved.

  4. Fetch Transaction History: If you suspect missing transactions, use the getTransactionHistory endpoint of the App Store server API. This allows you to retrieve the full transaction history for a customer using any single transaction ID.

For more detailed implementation, you can refer to the session Explore App Store server APIs for In-App Purchase (06:45) which discusses how to handle server notifications and verify transactions.

Relevant Sessions