In-App Purchase package
Updated: Sep 4, 2026
The
Platform SDK In-App Purchase Package enables app monetization through in-app purchases, including consumables, durable items, and subscriptions. The package retrieves product information and pricing, initiates the purchase flow for items, and queries user purchase history.
Applications can mark consumable items as used after consumption. Both durable (permanent) and consumable (one-time use) items are supported, along with subscription management. This package is essential for free-to-play and premium content monetization strategies.
Add the following to your project’s ./gradle/libs.versions.toml file:
[libraries]
# Existing lines
iap-kotlin = { module = "com.meta.horizon.platform.sdk:iap-kotlin", version.ref = "horizonPlatformSdk" }
dependencies {
// Existing lines
implementation(libs.iap.kotlin)
}
In Android Studio, click File > Sync Project with Gradle Files to install the package.
Click Build > Generate App Bundles or APKs > Generate APKs.
In the “External Libraries” section of your project, confirm that these packages are listed.
com.meta.horizon.platform.sdk:core-kotlin
com.meta.horizon.platform.sdk:iap-kotlin
Now you can initialize the Platform SDK and use In-App Purchase package functions in your app.
getViewerPurchases and the other purchase getters:
Test these APIs on
Meta Spatial Simulator without a physical device. They read and write local sample data, work offline, and persist across calls. Reset the data with the
common.reset_data command.
The launchCheckoutFlow call, which walks the purchase path end to end. It evaluates what you send: an unknown SKU fails, canceling the dialog fails, and a completed purchase is stored, so buying the same SKU again returns the purchase you already have:
These use a simulated dialog.
consumePurchase and getProductsBySku. getProductsBySku appears early in a catalog flow, so that is where a signed-out session fails first, while getViewerPurchases keeps working:
These need backend access. If that access is unavailable, they return an error.