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:
-
Receive Notifications: When a purchase is made, the App Store server sends a notification to your server. This notification includes a signed transaction.
-
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.
-
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.
-
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
- Explore App Store server APIs for In-App Purchase
- What’s new in StoreKit and In-App Purchase (21:06) for updates on StoreKit 2.
What’s new in StoreKit and In-App Purchase
Learn how to build and deliver even better purchase experiences using the App Store In-App Purchase system. We’ll demo new StoreKit views control styles and new APIs to improve your subscription customization, discuss new fields for transaction-level information, and explore new testability in Xcode. We’ll also review an important StoreKit deprecation.
Explore App Store server APIs for In-App Purchase
Learn how to leverage your server to build great In-App Purchase experiences with the latest updates to the App Store Server API, App Store Server Notifications, and the open source App Store Server Library. After a recap of current APIs, we’ll introduce updated endpoint functionality, new transaction fields, and a new notification type. We’ll also discuss best practices for the purchase lifecycle, delivering content, and targeting offers, so you can become a server power user.
Implement App Store Offers
Learn how to engage customers with App Store Offers using App Store Connect, as well as the latest StoreKit features and APIs. Discover how you can set up win-back offers (a new way to re-engage previous subscribers) and generate offer codes for Mac apps. And find out how to test offers in sandbox and Xcode to make sure they work smoothly.