# Initialize

**Initialization of the PayContactlessEmbed Library**

After invoking the `start` method of `PayContactlessEmbed`, the next crucial step is to initialize the Embed library. This function serves as a foundational call; subsequent functions from the library will be inaccessible unless the Embed library is properly initialized.

To facilitate this, the function requires an `InitializeListener` interface as an argument. It's essential for the merchant application to implement the `InitializeListener` class, as the library leverages its methods as delegates, ensuring seamless communication and functionality between the app and the SDK.

```kotlin
PayContactlessEmbed.getInstance().initialize(@NonNull String apiKey, @NonNull MerchantInfo merchantInfo, @NonNull InitializeListener listener)
```

**Handling Initialization Outcomes in PayContactlessEmbed Library**

Upon successful completion of the `initialize` function, the `onSuccess` method is triggered. This will return a `deviceId` to the integrating application, signifying a successful initialization.

However, should there be any issues during initialization, the `onFailure` method will be activated. In the event of such a failure, it's imperative to diagnose the error and undertake the necessary corrective measures. For a comprehensive understanding of possible errors and their resolutions, please refer to the **Error Handling** section.

{% content-ref url="error-handling" %}
[error-handling](https://developer.prophius.com/developer-console/merchant-embed-sdk/android/sdk-api-reference/error-handling)
{% endcontent-ref %}

## **Merchant Info**

Find the details at Section 3.2.

```kotlin
data class MerchantInfo (
    val merchantId: String,
    val terminalId: String,
    val merchantCategoryCode: String? = null,
    val businessName: String? = null,
    val city: String? = null,
    val state: String? = null,
    val country: String? = null,
    val firstName: String? = null,
    val lastname: String? = null,
    val email: String? = null,
    val phoneNumber: String? = null,
    val taxIdentificationNumber: String? = null,
    val apiKey: String
)
```

## **Initialize Listener**

```kotlin
public interface InitializeListener {
    void onSuccess(String deviceId);
    void onFailure(Error error);
}
```
