# 초기화하기

Wepin Android PIN Pad Library를 초기화하는 방법은 다음과 같습니다.&#x20;

```kotlin
import com.wepin.android.pinlib.WepinPin
```

`WepinPin` 인스턴스를 생성하기전에 아래와 같이 앱의 Activity Context , 앱 등록 후 할당받은 App ID와 App Key를 WepinPinParams 객체에 전달해 주세요.

```kotlin
val wepinPinParams =  WepinPinParams(
            context = this,
            appId = "your-wepin-app-id",
            appKey = "your-wepin-app-key"
        )
```

앞서 생성한 `WepinPinParams` 를 전달하면서 `WepinPin` 인스턴스를 생성해 주세요.

```kotlin
val wepinPin = WepinPin(wepinPinParams)
```

`WepinPin` 인스턴스생성 후 `initialize` 메서드를 호출하여 초기화를 합니다.

```kotlin
val res = wepinPin.initialize(attributes)
```

#### parameters

&#x20;`atrributes` \<WepinPinAttributes>

* `defualtLanguage` \<String>\
  핀 패드 화면의 기본 언어 설정, 기본 값은 `'en'` 입니다. 현재 지원하는 언어는 `'ko'`, `'en'` ,`'ja'`입니다.

#### Return value

`CompletableFuture` \<Boolean>\
정상적으로 잘 된 경우 **true** , 실패한 경우 **false** 를 반환합니다.

### Example

{% tabs %}
{% tab title="Java" %}

```java
public class MainActivity extends ComponentActivity {
    //v1.1.0 부터 WepinPin.login 으로 WepinLogin 의 메서드를 사용할 수 있습니다.
    private WepinLogin wepinLogin;    
    private WepinPin wepinPin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_example_main);

        initView();
        // Wepin Login Library 초기화
        // ...

        // Wepin PIN Pad Library 초기화        
        WepinPinParams wepinPinParams = new WepinPinParams(
            this,
            "your-wepin-app-id",
            "your-wepin-app-key"
        );
        wepinPin = new WepinPin(wepinPinParams);
        
        WepinPinAttributes attributes = new WepinPinAttributes("en");
        CompletableFuture<Boolean> res = wepinPin.initialize(attributes);
        if (res != null) {
            res.whenComplete((result, error) -> {
                if (error == null) {
                    System.out.println(result);
                } else {
                    System.out.println(error);
                }
            });
        }
        // ...
    }
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
class MainActivity : ComponentActivity() {
    private lateinit var wepinLogin: WepinLogin
    private lateinit var wepinPin: WepinPin
    override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

        setContentView(R.layout.activity_example_main)
    
        initView()
        // Wepin Login Libary 초기화
        // ...
        
        // Wepin PIN Pad Libary 초기화        
        val wepinPinParams =  WepinPinParams(
            context = this,
            appId = 'your-wepin-app-id',
            appKey = 'your-wepin-app-key'
        )
        wepinPin = WepinPin(wepinPinParams)       
        var attributes = WepinPinAttributes("en")
        val res = wepinPin.initialize(attributes)
        res?.whenComplete { infResponse, error ->
          if (error == null) {
            println(infResponse)
          } else {
            println(error) 
          }
      }        
    // ...
}
```

{% endtab %}
{% endtabs %}

## isInitialized

`isInitialized`메서드를 이용해서 `WepinPin` 인스턴스가 정상적으로 초기화 되었는지 확인할 수 있습니다. &#x20;

반환값은 아래와 같습니다.&#x20;

* \<Boolean>\
  초기화가 정상적으로 잘 된 경우 **true** , 실패한 경우 **false** 를 반환합니다.

### Example

{% tabs %}
{% tab title="Java" %}

```java
if(wepinPin.isInitialized()){
    // Success to initialize WepinPin
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
if(wepinPin.isInitialized()){
    // Success to initialize WepinPin
}
```

{% endtab %}
{% endtabs %}

## changeLanguage

```kotlin
wepinPin.changeLanguage("ko")
```

핀 패드 화면에 표시되는 언어를 변경합니다. 현재 `'ko'`, `'en'`, `'ja'`만 지원됩니다.&#x20;

### **Parameters**

* &#x20;`language` \<String>

### **Return value**

* `CompletableFuture` \<Boolean>\
  정상적으로 잘 된 경우 **true** , 실패한 경우 **false** 를 반환합니다.

### **Example**

{% tabs %}
{% tab title="Java" %}

```java
wepinPin.changeLanguage("ko").whenComplete((res, err) -> {
    if (err == null) {
        System.out.println(res);
    } else {
        System.out.println(err);
    }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
wepinPin.changeLanguage("ko").whenComplete{ res, err ->
    if (err == null) {
      println(res)
    } else {
      println(err)
    }
}
```

{% endtab %}
{% endtabs %}


---

# 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://docs.wepin.io/widget-integration/android-java-and-kotlin-sdk/pin-pad-library/init.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.
