In-App Purchase
Offer content and services in your app across Apple platforms using a Swift-based interface.
Overview
With the In-App Purchase API, you can offer customers the opportunity to purchase digital content and services in your app. Customers can make the purchases within your app, and find your promoted products on the App Store.
The StoreKit framework connects to the App Store on your app’s behalf to prompt for, and securely process, payments. The framework then notifies your app, making the transactions for In-App Purchases available to your app on all of the customer’s devices. For each transaction that represents a current purchase, your app delivers the purchased products. To validate purchases, you can verify transactions on your server, or rely on StoreKit’s verification.
[Image]
The App Store can also communicate with your server. It notifies your server of transactions and auto-renewable subscription events through App Store Server Notifications, and provides the same transaction information, and more, through the App Store Server API.
To learn how adding In-App Purchases fits in an overall app development workflow for the App Store, see App Store Pathway. For an overview of In-App Purchases and its features, including its configuration, testing capabilities, marketing for your products, and more, see Simple and safe In-App Purchases. For an overview on subscriptions, including creating subscription groups, Family Sharing, and more, see Auto-renewable subscriptions.
Configure In-App Purchases
To use the In-App Purchase API, you first need to configure the products that your app merchandises.
In the early stages of development, you can configure the products in the StoreKit configuration file in Xcode, and test your code without any dependency on App Store Connect. For more information, see Setting up StoreKit Testing in Xcode.
When you’re ready for sandbox testing and production, configure the products in App Store Connect. You can add or remove products and refine or reconfigure existing products as you develop your app. For more information, see Configure In-App Purchase settings.
You can also offer apps and In-App Purchases that run on multiple platforms as a single purchase. For more information on universal purchase, see Add platforms.
Support a store in your app
The In-App Purchase API takes advantage of Swift features like concurrency to simplify your In-App Purchase workflows, and SwiftUI to build stores with StoreKit views. Use the API to manage access to content and subscriptions, receive App Store-signed transaction information, get the history of all In-App Purchase transactions, and more.
The In-App Purchase API offers:
Transaction information that’s App Store-signed in JSON Web Signature (JWS) format.
Transaction and subscription status information that’s simple to parse in your app.
An entitlements API, currentEntitlements, that simplifies determining entitlements to unlock content and services for your customers.
To support a store in your app, implement the following functionality:
Listen for transaction state changes using the transaction listener, updates, to provide up-to-date service and content while your app is running.
Use StoreKit views to merchandise your products; or request products to display from the App Store with products(for:) and enable purchases using purchase(options:). Unlock purchased content and services based on the purchase result, Product.PurchaseResult.
Iterate through a customer’s purchases anytime using the transaction sequence all, and unlock the purchased content and services.
Optionally, validate the signed transactions and signed subscription status information that you receive from the API.
Topics
In-App Purchase merchandising
Product and subscription information
Implementing a store in your app using the StoreKit APISupporting monthly subscriptions with a 12-month commitmentManaging the life cycle of monthly subscriptions with a 12-month commitmentProductProduct.SubscriptionInfoSubscriptionInfoSubscriptionStatus
Purchase requests and results
Transaction history and entitlements
JWS verification
Subscription status and renewal information
Product.SubscriptionInfo.StatusProduct.SubscriptionInfo.RenewalInfoSubscriptionRenewalInfoProduct.SubscriptionInfo.RenewalStateSubscriptionRenewalStateSubscriptionPeriod
Offers
Supporting offer codes in your appSupporting win-back offers in your appMerchandising win-back offers in your appProduct.SubscriptionOfferProduct.SubscriptionOffer.OfferType
Promoted In-App Purchases
Supporting promoted In-App Purchases in your appPurchaseIntentProduct.PromotionInfoTesting promoted In-App Purchases
App Store interactions
Storefront information
In-App Purchase Testing
Testing at all stages of development with Xcode and the sandboxTesting In-App Purchases with sandboxTesting refund requestsTesting win-back offers in XcodeTesting Ask to Buy in Xcode
Advanced Commerce API interactions
AdvancedCommerceProductSending Advanced Commerce API requests from your appGenerating JWS to sign App Store requests