Skip to main content
ZeroSettle makes it easy to determine subscription status with the ZeroSettleIAP SDK and REST API.

Getting subscription status via the SDK

The entitlements property contains all of the purchase and subscription data available about a user. This is updated whenever a purchase completes or when you call restoreEntitlements().
// Restore and get current entitlements
let entitlements = try await ZeroSettleIAP.shared.restoreEntitlements(
    userId: currentUser.id
)

// Or access cached entitlements
let cached = ZeroSettleIAP.shared.entitlements
It’s safe to call restoreEntitlements() frequently throughout your app. The SDK caches entitlements locally and the network request is lightweight.

Checking If A User Is Subscribed

The subscription status for a user can be determined using the Entitlement objects returned by restoreEntitlements(). For most apps with a single premium tier, check for a specific product:
let hasPremium = entitlements.contains {
    $0.productId == "premium_monthly" && $0.isActive
}

if hasPremium {
    // user has access to premium features
}
If your app has multiple entitlements, check if any are active:
if entitlements.contains(where: { $0.isActive }) {
    // user has access to some entitlement
}
Entitlements will be empty if no purchases have been made. Always handle the empty case in your UI.

Restoring Purchases

Restoring purchases allows users to recover their in-app purchases on a new device or after reinstalling the app. It is recommended that all apps have a way for users to trigger restore, even if you require accounts.
do {
    let entitlements = try await ZeroSettleIAP.shared.restoreEntitlements(
        userId: currentUser.id
    )
    // Update UI based on entitlements
    updatePremiumAccess(entitlements)
} catch {
    // handle error
}
This fetches entitlements from both ZeroSettle’s web checkout system and StoreKit (if syncStoreKitTransactions is enabled).

Cache

The SDK caches the user’s subscription information to reduce your app’s reliance on the network. Users who unlock entitlements will be able to access them even without an internet connection. The SDK will update the cache if it’s older than 5 minutes when you call restoreEntitlements(), make a purchase, or restore purchases. It’s a good idea to call restoreEntitlements() any time a user accesses premium content.

Listening For Entitlement Updates

Entitlements can change from various sources: web checkout completion, StoreKit transaction updates, or subscription renewals/cancellations. Use the delegate to respond to changes:
class PurchaseManager: ZeroSettleIAPDelegate {
    init() {
        ZeroSettleIAP.shared.delegate = self
    }

    func zeroSettleIAPEntitlementsDidUpdate(_ entitlements: [Entitlement]) {
        // Handle any changes to entitlements
        updatePremiumUI(entitlements)
    }
}
You can also observe the entitlements published property in SwiftUI:
struct ContentView: View {
    @ObservedObject var iap = ZeroSettleIAP.shared

    var body: some View {
        if iap.entitlements.contains(where: { $0.isActive }) {
            PremiumContent()
        } else {
            UpgradePrompt()
        }
    }
}
Entitlement updates are triggered by SDK operations (purchases, restores). They are not pushed from the backend in real-time.

Getting subscription status via the REST API

If you need to get a user’s subscription status from outside of the ZeroSettle SDK, for example, from your own backend, you should use the REST API.
curl --request GET \
  --url https://api.zerosettle.io/v1/iap/entitlements?user_id=app_user_id \
  --header 'Content-Type: application/json' \
  --header 'X-ZeroSettle-Key: your_secret_key'

Handling Refunds

ZeroSettle handles refunds for both subscription and non-subscription products. As soon as a refund is processed, the entitlements will be updated to reflect the correct status — no action required on your part. The isActive property on the affected Entitlement will be set to false.