# 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="/pages/BzUOnmbZrD6XvYxn5Z2l" %}
[Error Handling](/developer-console/merchant-embed-sdk/android/sdk-api-reference/error-handling.md)
{% 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);
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.prophius.com/developer-console/merchant-embed-sdk/android/sdk-api-reference/initialize.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
