How can I implement in-app purchases
Generated on 8/9/2024
1 search
To implement in-app purchases in your app, you should use the StoreKit framework. Here are the key steps and some useful information from the WWDC sessions:
-
Use StoreKit 2: Starting with iOS 18, the original API for in-app purchases is deprecated. StoreKit 2 offers many improvements, such as automatic cryptographic validation and modern language features like the Swift Async/Await pattern. It also provides access to new App Store features even on older operating systems. For more details, refer to the What’s new in StoreKit and In-App Purchase session.
-
Testing in Xcode: You can test your in-app purchase flows using StoreKit testing in Xcode. This includes testing purchase intents and billing issue messages directly in your app. For more information, see the What’s new in StoreKit and In-App Purchase session.
-
Handling Purchase Intents: The purchase intent API allows you to handle purchases initiated outside your app, such as promoted in-app purchases or win-back offers. You can either continue the purchase immediately or store the intent for later use. For more details, check out the Implement App Store Offers session.
-
Server-Side Integration: Use the App Store server APIs to handle transactions and deliver content. This includes sending new and updated transactions from the device to your server and enabling App Store server notifications. For more information, refer to the Explore App Store server APIs for In-App Purchase session.
-
Merchandising: Use SwiftUI to create custom UI for handling incoming purchase intents and merchandising products. If you do nothing, the payment sheet will present itself once your app launches. For more details, see the What’s new in StoreKit and In-App Purchase session.
Relevant Sessions
- What’s new in StoreKit and In-App Purchase
- Implement App Store Offers
- Explore App Store server APIs for In-App Purchase
These sessions provide comprehensive guidance on implementing and testing in-app purchases using the latest StoreKit features.
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.
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.
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.