---
title: Initialize
slug: 4XY3-initialize
docTags: 
createdAt: 2025-05-02T10:40:00.253Z
---

The Unity SDK needs to be initialised with configuration information associated with the mobile application,  firebase realtime database and Pay3 environment settings.

&#x20;**Initialization Parameters**

1. **pay3HostName**: Pay3 will be opened in a new window using this hostname prefix. The host name is environment dependent.&#x20;
2. **pay3ClientId**: A unique client id is created for each client application. The client id is environment dependent.
3. **appNotify\* Configs**: These are config parameters for firebase realtime database. This is used to publish realtime events to the app.
4. **appDeepLink**:  This string in the form of `scheme://resource` can be passed during initalization. This will be used by Pay3 as referrer / redirect intent. The string needs to be whitelisted in Pay3 backend for proper working of the Pay3 services.&#x20;

Following are the **sample code** **snippets** for your reference. The entire package with complete example will be provided during onboarding.

Game can use **Pay3SDKConfig.cs** which extends *ScriptableObject.*  This accepts all settings required for Pay3 SDK. Game can create an asset using this. The asset needs to be passed to *Pay3Helper.cs* instance.

:::CodeblockTabs
Pay3SDKConfig.cs

```cpp
using UnityEngine;

[CreateAssetMenu(fileName = "Pay3SDKConfig", menuName = "ScriptableObjects/Pay3SDKConfig", order = 1)]
public class Pay3SDKConfig : ScriptableObject
{
    public string androidPackageId;
    public string appNotifyApiKey;
    public string appNotifyAppId;
    public string appNotifyProjectId;
    public string appNotifyDatabaseUrl;
    public string appNotifyStorageBucket;
    public string appDeepLink;
    public string pay3ClientId;
    public string pay3HostName;
}

```
:::

Game can instantiate **Pay3Helper.cs** that extends *MonoBehaviour*.  This loads configuration from Pay3SDKConfig during the Start.&#x20;

:::CodeblockTabs
Pay3Helper.cs

```cpp
namespace Pay3.SDK.Helper {
  
  // Import essential packages
  using Firebase.Auth; 
  using Firebase.Database;
  using Firebase;
  using UnityEngine;
  

  public class Pay3Helper : MonoBehaviour {

    // Attach the Pay3SDKConfig to this Behaviour
    public Pay3SDKConfig sdkConfig; 
    
    
    // When the app starts, check to make sure that we have
    // the required dependencies to use Firebase, and if not,
    // add them if possible.
    public virtual void Start() { 
      InitializeFirebaseAuth();
    }

    // Handle initialization of the necessary firebase modules:
    private void InitializeFirebaseAuth() {
        authOptions = new Firebase.AppOptions {
            // Use Configuration from Pay3SDK Config
        };
        fbApp = Firebase.FirebaseApp.Create(authOptions, "Pay3");      
        auth = Firebase.Auth.FirebaseAuth.GetAuth(fbApp);
        SignInAnonymously();
    }

    // Request anonymous sign-in and wait until asynchronous call completes.
    private void SignInAnonymously() {  
      auth.SignInAnonymouslyAsync().ContinueWith((authTask) => {
        if (authTask.IsCompleted) {
            Firebase.Auth.FirebaseUser user = authTask.Result.User;
            StartTransactionListener(user.UserId);
            }
        });
    }
  }
}
```
:::

***

