Implement web paywalls in Unity SDK

Before you begin, make sure you have configured your web paywall in the dashboard and installed Adapty SDK version 3.14 or later.

Open web paywalls

If you are working with a paywall you developed yourself, you need to handle web paywalls using the SDK method. The Adapty.OpenWebPaywall method:

  1. Generates a unique URL allowing Adapty to link a specific paywall shown to a particular user to the web page they are redirected to.
  2. Tracks when your users return to the app and then requests Adapty.GetProfile at short intervals to determine whether the profile access rights have been updated.

This way, if the payment has been successful and access rights have been updated, the subscription activates in the app almost immediately.

Adapty.OpenWebPaywall(
    product,
    (error) =>
    {
        if (error != null)
        {
            Debug.LogError($"Failed to open web paywall: {error.Message}");
        }
        else
        {
            Debug.Log("Web paywall opened successfully");
        }
    }
);

There are two versions of the OpenWebPaywall method:

  1. OpenWebPaywall(product) that generates URLs by paywall and adds the product data to URLs as well.
  2. OpenWebPaywall(paywall) that generates URLs by paywall without adding the product data to URLs. Use it when your products in the Adapty paywall differ from those in the web paywall.

Handle errors

Error CodeDescriptionRecommended action
AdaptyErrorCode.WrongParamThe paywall or product doesn’t have a web purchase URL configured, or failed to open the URL in the browserCheck the error message for details. Verify the paywall/product configuration in the Adapty Dashboard, or check device settings.
AdaptyErrorCode.DecodingFailedFailed to properly encode parameters in the URLVerify URL parameters are valid and properly formatted

Check the error’s Message property to get specific details about what went wrong, as WrongParam can indicate several issues (missing purchase URL, failed to open browser, etc.).

Open web paywalls in an in-app browser

Opening web paywalls in an in-app browser is supported starting from Adapty SDK v. 3.15.

By default, web paywalls open in the external browser, which navigates users outside of your app.

To provide a seamless user experience, you can open web paywalls in an in-app browser instead. This displays the web purchase page within your application, allowing users to complete transactions without switching apps.

To enable this, pass AdaptyWebPresentation.InAppBrowser to the OpenWebPaywall method:

Adapty.OpenWebPaywall(
    product,
    AdaptyWebPresentation.InAppBrowser, // default β€” ExternalBrowser
    (error) =>
    {
        if (error != null)
        {
            Debug.LogError($"Failed to open web paywall: {error.Message}");
        }
        else
        {
            Debug.Log("Web paywall opened successfully");
        }
    }
);