Skip to main content
When you initialize the Unity Payment Links SDK, you need to provide a customerId. This ID allows the SDK to manage cases where a player closes the browser during checkout and later returns to the game. In such scenarios, the SDK uses the customerId from initialization and the purchaseId from the checkout session to validate the order. It then communicates with the Appcharge server to determine the order status, and responds to the app with the appropriate next step. Additionally, the customerId ensures proper validation even when multiple players share the same device. For example, if multiple players log into the same game on one phone, the SDK uses customerId to correctly identify each player and validate their purchases with the Appcharge server. Use the following function to initialize the SDK:
This initialization method is sufficient if you’ve already set the Environment and Checkout Public Key fields in the configuration file. If you prefer to set these values programmatically, use the initialization method described in the next section.

Re-initialize the SDK

You may need to re-initialize the SDK in the following cases:
  1. When switching environments at runtime, for example, when testing the SDK.
  2. When a new player logs in and replaces the current session.
  3. When certain configuration details are managed manually instead of being defined in the configuration file.
In such cases, re-initialize the SDK using the extended method below:
Always ensure the correct environment, checkoutPublicKey and customerId are used when re-initializing. Incorrect values can cause failed checkout validations.