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

# Launch the Checkout

To launch the checkout, follow these steps:

1. From your server, call the [Create Checkout Session API](https://docs.appcharge.com/../../api-reference/checkout/checkout-session/create-checkout-session) to create a checkout session.

   > [!WARNING]
   >
   > * When calling the Create Checkout Session API, don't pass the `redirectUrl` parameter. The SDK already handles the redirect automatically using the configuration file.
   > * Call the API from your server to ensure session integrity and security. Never invoke this endpoint from your client-side code.

2. After receiving the API response on your server, extract the values from the session object:

   ```json theme={"system"}
   {
       "checkoutSessionToken": "session_token_identifier",
       "purchaseId": "pr_purchase_id",
       "url": "https://checkout-v2-sandbox.appcharge.com",
       "parsedUrl": "https://checkout-v2-sandbox.appcharge.com/session_token_identifier#boot=checkout_boot_data"
   }
   ```

   | Parameter | Description |
   | - | - |
   | `checkoutSessionToken` | A unique token to identify and validate the checkout session. |
   | `purchaseId` | ID to track the purchase. |
   | `url` | The base URL of the Appcharge checkout page. |
   | `parsedUrl` | The base URL with data configurations. |

3. Use the values returned in the Create Checkout Session API response to open the checkout on the client, and pass your player's `customerId`. The SDK uses this ID with the session `purchaseId` to validate the order if the player closes the browser during checkout and later returns to the game. It also identifies the correct player when multiple players share the same device.

   ```swift Swift theme={"system"}
   ACBridgeAPI.openCheckout(
       purchaseId: "PURCHASE_ID",
       parsedUrl: "PARSED_URL",
       customerId: "CUSTOMER_ID"
   )
   ```

   ```c Objective-C theme={"system"}
   [ACBridgeAPI openCheckoutWithPurchaseId:@"PURCHASE_ID"
                               parsedUrl:@"PARSED_URL"
                               customerId:@"CUSTOMER_ID"];      
   ```

   > [!CAUTION]
   >
   > The session response values must be passed exactly as received. Modifying them may result in the checkout failing to load.

4. You can also configure how the checkout page is opened (optional):

   * **External browser** \

     Open the checkout in the device’s default browser. This flow will use the `redirectUrl` provided in the initialization to return back to the app.

     ```swift Swift theme={"system"}
     ACBridgeAPI.setBrowserMode(.external)
     ```

     ```c Objective-C theme={"system"}
     [ACBridgeAPI setBrowserMode:0];
     ```

     > [!WARNING]
     >
     > Running the checkout in an external browser may cause inconsistent behavior across devices, incomplete transactions, or app unexpected lifecycle behavior.

   * **Non-external browser (default)** \

     The checkout opens in the device's internal browser or [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller). This flow will use the url scheme provided in the **plist** file to return back to the app. For more information, see [Sell Outside IAP](https://docs.appcharge.com/../../guides/payment-links/sell-outside-iap).

     ```swift Swift theme={"system"}
     ACBridgeAPI.setBrowserMode(.internal)
     ```

     ```c Objective-C theme={"system"}
     [ACBridgeAPI setBrowserMode:1];
     ```
