VerifyPurchaseWithProviderResult

VerifyPurchaseWithProviderResult#

Result type returned by verifyPurchaseWithProvider().

Result envelope from verifyPurchaseWithProvider. Carries isValid plus the underlying provider response. See Validation docs.

NameTypeSummary
providerPurchaseVerificationProviderThe provider used for verification.
iapkitRequestVerifyPurchaseWithIapkitResult?IAPKit verification result (optional).
errorsVerifyPurchaseWithProviderError[]?Error details if verification failed (see below).

VerifyPurchaseWithProviderError#

NameTypeSummary
messagestringHuman-readable error description
codestring?Optional machine-readable error code

RequestVerifyPurchaseWithIapkitResult#

Individual verification result from IAPKit. The verified product ID is independent of optional public product payload enrichment.

NameTypeSummary
storeIapStoreThe store that processed the purchase: 'apple', 'google', 'horizon', or 'amazon'.
isValidbooleanTrue only for entitled, pending-acknowledgment, or ready-to-consume. Still require an exact productId match and a platform/product-type-aware fulfillment path.
environmentstring?Available in OpenIAP Spec 3.2.0 / openiap-apple 3.2.0 / openiap-google 3.3.0. Opaque, provider-defined store environment. Handled Amazon responses currently report 'Sandbox' or 'Production', and other stores omit it today, but the value space belongs to the provider — App Store Server also names 'Xcode' and 'LocalTesting'. Forward it and never fail a verification because the value is unrecognised.
stateIapkitPurchaseStateThe current state of the purchase.
productIdstring?Product identifier verified by the upstream store, when the provider returns one. Use this value instead of trusting a client-supplied expected product ID.
clientPayloadIapkitProductClientPayload?Public app-facing product data. Present only for an opted-in, valid Apple or Google verification when that product has a currently visible catalog row and a payload in IAPKit.

IapkitProductClientPayload#

Public app-facing data attached to one IAPKit product. It is stored separately from App Store Connect and Play Console metadata and is never sent to either store.

NameTypeSummary
formatIapkitClientPayloadFormatSerialization hint: 'toml', 'json', or 'text'.
bodystringPayload content, limited to 16 KiB measured as UTF-8 bytes.
versionnumberServer-managed revision that increments when the payload is updated. Apps can use it to replace stale cached content.
updatedAtnumberLast update time as Unix epoch milliseconds.

The field is omitted by default and for invalid receipts, absent or removed catalog products, missing payloads, Horizon verification, and Amazon verification. IAPKit does not deliver it through APNs or FCM; the app receives it only when it requests the value during verification or through a product endpoint.

IapkitPurchaseState#

Unified purchase states from IAPKit verification response.

ValueSummary
'entitled'User is entitled to the product (purchase is complete and active).
'pending-acknowledgment'Google Play purchase still needs acknowledgment or consumption.
'pending'Purchase is pending completion.
'canceled'Purchase was canceled, refunded, or revoked.
'expired'Subscription has expired.
'ready-to-consume'Consumable is ready for durable fulfillment, then consumption.
'consumed'Consumable product has been consumed.
'unknown'Purchase state could not be determined.
'inauthentic'Purchase failed authenticity validation (potentially fraudulent).

IapStore#

Enumeration of stores supported by IAPKit.

ValueSummary
'apple'Apple App Store.
'google'Google Play Store.
'horizon'Meta Horizon Store.
'amazon'Amazon Appstore for Fire OS and Vega OS.

PurchaseVerificationProvider#

Supported verification providers.

ValueSummary
'iapkit'IAPKit - Server-side purchase verification service.

Usage Example#

Grant access only when the store-verified productId is present and matches the product requested by the app. Use the local purchase ID only as the expected value; do not fall back to it when verification omits the ID.

swift
import OpenIAP

let result = try await OpenIapModule.shared.verifyPurchaseWithProvider(
    VerifyPurchaseWithProviderProps(
        iapkit: RequestVerifyPurchaseWithIapkitProps(
            apiKey: "openiap-kit_pk_<your-publishable-key>",
            apple: RequestVerifyPurchaseWithIapkitAppleProps(
                jws: purchase.purchaseToken ?? ""
            ),
            includeClientPayload: true
        ),
        provider: .iapkit
    )
)

if let verified = result.iapkit,
   verified.isValid,
   verified.state == .entitled,
   let verifiedProductId = verified.productId,
   verifiedProductId == purchase.productId {
    unlockEntitlement(productId: verifiedProductId)
    if let payload = verified.clientPayload {
        // Parse according to format and apply in memory; do not log the body.
        applyPublicRules(payload)
    }
}

These examples cover non-consumables and subscriptions: Apple examples require entitled, while Google examples also allow pending-acknowledgment. Choose the finish path from the app-owned product type and platform, not the state alone. Apple, Amazon, and catalog-known Google consumables use ready-to-consume. When the catalog type is unknown, an unconsumed Google product may instead be entitled or pending-acknowledgment. Persist consumable delivery before finishing it; see the state-aware flow.