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

# App Store integration

> Add App Store Connect issuer ID, shared secret, and in-app purchase key, then configure App Store Server Notifications for your iOS app.

App Store integration lets PNLight validate iOS purchases and process App Store Server Notifications. Configure it for every PNLight project that receives production or sandbox iOS purchases.

## Prerequisites

* App Store Connect access with the Admin or Account Holder role.
* A PNLight project with the correct iOS bundle ID and App Store ID.
* At least one in-app purchase or subscription created in App Store Connect.

## Open AppStore settings in PNLight

<Steps>
  <Step title="Open Integration">
    In the project dashboard, open **Integration**.
  </Step>

  <Step title="Find AppStore">
    Scroll to the **AppStore** section.
  </Step>

  <Step title="Copy the notification URL">
    Copy the **AppStore Connect notification URL**. You will add it in App Store Connect after saving the credentials.
  </Step>
</Steps>

## Create an in-app purchase key

The in-app purchase key is a `.p8` private key from App Store Connect. PNLight uses it to verify StoreKit 2 purchases, decode App Store Server Notifications, and recover subscription history.

<Steps>
  <Step title="Open App Store Connect">
    Sign in to App Store Connect and open **Users and Access**.
  </Step>

  <Step title="Open integrations">
    Open **Integrations** and then **In-App Purchase**.
  </Step>

  <Step title="Generate the key">
    Generate an in-app purchase key and download the `.p8` file.
  </Step>

  <Step title="Copy the issuer ID">
    Copy the issuer ID from the same App Store Connect page.
  </Step>
</Steps>

<Warning>
  Apple lets you download the `.p8` key only once. Store it securely and do not rename the file before uploading it to PNLight.
</Warning>

## Save credentials in PNLight

In **Integration → AppStore**, fill in:

| Field                   | What to enter                                                                                  |
| ----------------------- | ---------------------------------------------------------------------------------------------- |
| Issuer ID               | The issuer ID from **Users and Access → Integrations → In-App Purchase** in App Store Connect. |
| App Store shared secret | The app-specific or primary shared secret used for legacy receipt validation.                  |
| In-App Purchase Key     | The downloaded `.p8` in-app purchase key. Keep the original file name.                         |

Click **Save AppStore settings** after entering the issuer ID and shared secret. Upload the `.p8` file with the **Upload \*.p8** button.

## Configure server notifications

App Store Server Notifications let PNLight receive subscription renewals, cancellations, refunds, billing retry events, and other subscription lifecycle changes without waiting for the app to open.

<Steps>
  <Step title="Copy the PNLight notification URL">
    In **Integration → AppStore**, copy the **AppStore Connect notification URL**.
  </Step>

  <Step title="Open the app in App Store Connect">
    In App Store Connect, open **My Apps** and select the iOS app that matches this PNLight project.
  </Step>

  <Step title="Open App Information">
    Open **App Information** and find **App Store Server Notifications**.
  </Step>

  <Step title="Paste the URL">
    Paste the PNLight URL into both **Production Server URL** and **Sandbox Server URL**.
  </Step>

  <Step title="Use version 2">
    If App Store Connect asks for a notification version, select **Version 2**.
  </Step>

  <Step title="Save changes">
    Save the App Store Connect settings.
  </Step>
</Steps>

<Note>
  If the App Store Server Notifications section is missing in App Store Connect, create at least one in-app purchase or subscription for the app and check again.
</Note>

## What to verify before testing

* The `.p8` file belongs to the same App Store Connect account.
* The bundle ID matches the app that includes the SDK.
* The App Store ID matches the app listing.
* The notification URL is copied from the same PNLight project.
* The notification URL is saved for both production and sandbox.
* App Store Server Notifications use version 2.

<Note>
  App Store changes can take time to affect sandbox and production events. Test with a fresh sandbox purchase after saving the integration settings.
</Note>
