iOS Setup

Configure StoreKit 2 and App Store Connect

Prerequisites

  • Apple Developer Program membership ($99/year)
  • Xcode 14 or later
  • iOS 15.0+ deployment target (for StoreKit 2)
  • React Native 0.70+

Step 1: Create Your App in App Store Connect

  1. Go to App Store Connect

    Visit appstoreconnect.apple.com and sign in

  2. Create a new app

    Click "My Apps" → "+" → "New App"

  3. Fill in app details

    Enter name, primary language, bundle ID, and SKU

Step 2: Create In-App Purchase Products

For Subscriptions:

  1. Navigate to Subscriptions

    In your app, go to "Features" → "Subscriptions"

  2. Create a Subscription Group

    Click "+" to create a new subscription group (e.g., "Premium")

  3. Add subscriptions to the group

    Create individual subscription products (monthly, yearly, etc.)

For One-Time Purchases:

  1. Navigate to In-App Purchases

    Go to "Features" → "In-App Purchases"

  2. Create the product

    Select type: Consumable, Non-Consumable, or Non-Renewing Subscription

Product ID Naming Convention

We recommend using a consistent naming convention:

com.yourcompany.appname.product_type_duration

Example: com.acme.myapp.premium_monthly

Step 3: Configure Pricing

  1. Select price tier

    Apple uses price tiers. Select the appropriate tier for your product.

  2. Set availability

    Choose which countries/regions the product is available in.

  3. Configure introductory offers (optional)

    Set up free trials, pay-as-you-go, or pay-up-front offers.

Step 4: Set Up Server Notifications

Configure App Store Server Notifications to receive real-time updates about subscription events.

  1. Go to App Information

    In App Store Connect, navigate to "General" → "App Information"

  2. Find "App Store Server Notifications"

    Scroll down to the notifications section

  3. Enter your webhook URL
    https://api.croissantlabs.com/api/webhooks/apple

    For self-hosted: https://your-domain.com/api/webhooks/apple

  4. Select Version 2

    Choose "Version 2 Notifications" for the best compatibility

Step 5: Get Your Shared Secret

The shared secret is used to validate receipts server-side.

  1. Navigate to Shared Secret

    In App Store Connect, go to "General" → "Shared Secret"

  2. Generate or copy your secret

    Click "Generate" if you don't have one, or copy the existing secret

  3. Add to CroissantPay

    In your app settings, paste the shared secret in the Apple configuration section

Keep your shared secret secure

Never expose this in your client-side code. Only use it on your server or in CroissantPay configuration.

Step 6: Configure Your Xcode Project

Enable In-App Purchase Capability

  1. Open your project in Xcode
  2. Select your target

    Click on your app target in the project navigator

  3. Go to Signing & Capabilities
  4. Add In-App Purchase capability

    Click "+ Capability" and search for "In-App Purchase"

Install the SDK Pod

After installing the npm package, run pod install:

Terminal
cd ios && pod install

Testing In-App Purchases

Sandbox Testing

  1. Create a Sandbox tester account

    In App Store Connect, go to "Users and Access" → "Sandbox Testers"

  2. Sign out of App Store on device

    Settings → iTunes & App Store → Sign Out

  3. Test purchases in your app

    When prompted, sign in with your sandbox account

Sandbox Subscription Durations

In sandbox, subscriptions renew faster for testing:

Production DurationSandbox Duration
1 week3 minutes
1 month5 minutes
2 months10 minutes
3 months15 minutes
6 months30 minutes
1 year1 hour

Next Steps