Skip to main content
To launch the checkout, follow these steps:
  1. From your server, call the Create Checkout Session API to create a checkout session.
    • When calling the Create Checkout Session API, don’t pass the redirectUrl parameter, as 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 Unity Project.
  2. After receiving the API response on your server, extract the values from the session object:
    {
        "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"
    }
    
    ParameterDescription
    checkoutSessionTokenA unique token to identify and validate the checkout session.
    purchaseIdID to track the purchase.
    urlThe base URL of the Appcharge checkout page.
    parsedUrlThe Parsed URL of the Appcharge checkout page.
  3. Use the values returned in the checkout session response to open the checkout on the client. Depending on your integration version, use one of the following methods:

    This method is deprecated and should not be used for new implementations.
    Use the following values from the session response:
    PaymentLinksController.Instance.OpenCheckout(
        sessionToken: "CHECKOUT_SESSION_TOKEN", 
        purchaseId: "PURCHASE_ID",
        url: "URL" 
    )
    
    The session response values must be passed exactly as received. Modifying them may result in the checkout failing to load.
  4. You can also override in run-time how the checkout page is opened (optional):
    • External browser
      Open the checkout in the device’s default browser. This flow will redirect the player back to the app.
      // Unity Android
      PaymentLinksController.Instance.SetConfiguration("browserMode", AndroidBrowserMode.External)
      
      // Unity iOS
      PaymentLinksController.Instance.SetConfiguration("browserMode", iOSBrowserMode.External);
      
      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. This flow will use the URL scheme provided in the configuration file to return back to the app. For more information, see Sell Outside IAP.
      // Unity Android with an internal custom Chrome tab
      PaymentLinksController.Instance.SetConfiguration("browserMode", AndroidBrowserMode.CCT)
      
      // Unity Android with an internal Trusted Web Activity
      PaymentLinksController.Instance.SetConfiguration("browserMode", AndroidBrowserMode.TWA)
      
      // Unity iOS
      PaymentLinksController.Instance.SetConfiguration("browserMode", iOSBrowserMode.SFSVC);
      
  5. For Unity iOS only, you can force the Checkout page to display in portrait orientation, even if the app is currently in landscape mode. (optional):
    PaymentLinksController.Instance.SetConfiguration("portraitOrientationLock", "true")