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:
| Argument | Type | Description |
|---|---|---|
| Customer ID | string | Customer ID. |
| Callback | ICheckoutPurchase | Implementation of the callback interface. |
This initialization method is sufficient if you’ve already set the Environment and Checkout Public Key fields in the configuration file.
Re-initialize the SDK
You may need to re-initialize the SDK in the following cases:- When switching environments at runtime, for example, when testing the SDK.
- When a new player logs in and replaces the current session.
- When certain configuration details are managed manually instead of being defined in the configuration file.
| Argument | Type | Description |
|---|---|---|
| Environment | string | The checkout environment. One of: - sandbox: For testing.- production: For live operations. |
| Checkout Public Key | string | The public key from the Publisher Dashboard.Go to Settings → Integration and copy the Checkout Public Key. |
| Customer ID | string | The player’s unique ID. |
| Callback | ICheckoutPurchase | Implementation of the callback interface. |
