Apple In-App Purchase

Last updated: June 17, 2026

When your iOS app sells digital products — premium features, credits, subscriptions — Apple requires those purchases to go through Apple's In-App Purchase system, not your website's payment gateway. The Apple IAP bridge is what connects your existing website purchase flow to Apple's native payment sheet.

How It Works

  1. The user taps a purchase button on your website.
  2. Your website sends a message to the app via the bridge, specifying the product to purchase.
  3. The app opens Apple's native payment sheet.
  4. Apple processes the payment.
  5. The app sends the result back to your website.
  6. Your website delivers the product (or shows an error).

Triggering a Purchase

javascript
appilix.postMessage(JSON.stringify({
    type: "apple_iap_init",
    props: {
        product_id: "com.example.app.premium_monthly",
        product_type: "subscription",
        app_account_token: "550e8400-e29b-41d4-a716-446655440000"
    }
}));

Parameters

ParameterRequiredDescription
product_idYesThe Product ID exactly as created in App Store Connect
product_typeYes"consumable", "non-consumable", or "subscription"
app_account_tokenNoA UUID string linking the purchase to your internal user account. Included in Apple's purchase notification for server-side verification

The product_id must match exactly what you created in App Store Connect — including capitalization and any dots or underscores.

Handling the Response

Set up the listener before triggering the purchase:

javascript
appilix.onmessage = function(event) {
    const data = JSON.parse(event.data);

    if (!data || data.type !== 'apple_iap_init') return;

    if (data.response.status === true) {
        const { product, purchase } = data.response;

        // Send the receipt to your backend for verification before unlocking anything
        fetch('/api/unlock-premium', {
            method: 'POST',
            body: JSON.stringify({
                product_id: product.id,
                transaction_id: purchase.id,
                verification_data: purchase.verification_data,
                verification_source: purchase.verification_source
            })
        });
    } else {
        // Purchase failed or cancelled
        console.log('Purchase failed:', data.response.message);
    }

    appilix.onmessage = null;
};

Response Fields

FieldPresent WhenDescription
statusAlwaystrue if the purchase succeeded, false otherwise
messagestatus is falseReason for the failure (e.g. user cancelled, payment failed)
productstatus is trueDetails of the purchased product, as returned by App Store Connect
purchasestatus is trueDetails of the completed transaction

product object

FieldDescription
idThe Product ID, matching what you passed in product_id
titleLocalized product name from App Store Connect
descriptionLocalized product description from App Store Connect
priceLocalized, formatted price string (e.g. "$4.99")
rawPricePrice as a number, useful for calculations or analytics
currencyCodeISO currency code (e.g. "USD")

purchase object

FieldDescription
idThe transaction ID. Keep this for support requests, refund lookups, and to avoid double-crediting the same purchase
transaction_dateWhen the transaction completed
verification_dataThe signed receipt data. Send this to your backend to verify with the App Store Server API before granting any entitlement
verification_sourceIdentifies which Apple verification flow produced the receipt

Never grant the purchased entitlement based on the client-side response alone — always verify verification_data against the App Store Server API from your backend first.

Product Types

TypeDescription
consumableCan be purchased multiple times. Use for credits, coins, or one-time boosts.
non-consumablePurchased once and owned permanently. Use for lifetime access or removing ads.
subscriptionRenews automatically on a schedule. Use for monthly or yearly plans.

Important Notes

  • This bridge is for iOS only. On Android, your website's existing payment gateway works normally.
  • Always verify the purchase on your backend before delivering the product. Do not rely solely on the client-side response.
  • Test purchases using Apple's Sandbox environment before submitting to the App Store.
  • Implementing this correctly requires modifying your website's purchase button logic and handling the bridge response. Involve a developer if needed.

For App Store Connect product setup instructions, see the Apple In-App Purchase article.