> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encorekit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add Subscription Product

> Connect your subscription billing to the Encore KMP SDK.

## Overview

When a user accepts an offer, the SDK fires `onPurchaseRequest` with the product to purchase. Your handler triggers the purchase through your billing library.

***

## Setup

Register your purchase handler at app startup, after `configure()`:

```kotlin theme={null}
Encore.onPurchaseRequest { request ->
    // request.productId    — store product to purchase
    // request.placementId  — which placement triggered this
    // request.promoOfferId — promotional offer ID (iOS only, nullable)

    yourBillingService.purchase(request.productId)
}
```

## Example: RevenueCat

```kotlin theme={null}
Encore.onPurchaseRequest { request ->
    val product = Purchases.sharedInstance
        .getProductsAsync(listOf(request.productId))
        .firstOrNull() ?: return@onPurchaseRequest

    Purchases.sharedInstance.purchaseProduct(product)
}
```

<Tip>
  If you use a third-party subscription manager (RevenueCat, Adapty, etc.), always set `onPurchaseRequest` so purchases route through your manager's SDK for proper attribution and receipt validation.
</Tip>

***

## Native Billing Fallback

If no `onPurchaseRequest` handler is set, the native SDK falls through to platform billing (Play Billing on Android, StoreKit on iOS).

Use `onPurchaseComplete` to be notified when a native purchase completes:

```kotlin theme={null}
Encore.onPurchaseComplete { result, productId ->
    // result.purchaseToken  — Android Play Billing token
    // result.transactionId  — iOS StoreKit transaction ID
    // result.productId      — the purchased product
}
```
