Initialization

Here is the instructions on how to initialize the Wepin Widget Javascript SDK.

init

It initializes the Wepin SDK. Defines the attributes needed for the widget during initialization.

await wepinSdk.init(attributes?)

Parameters

  • attributes <object> optional

  • type <string> It determines how to display the app widget window on the first load. The default value is hide. Currently, only hide is supported. hide hides the widget window on the first load. The widget window can be displayed later using openWindow().

  • defaultLanguage: <string> It sets the default language of the widget. The default value is ko. Currently, supported languages are en , ko and ja.

  • defaultCurrency: <string> It sets the default currency of the widget. The default value is KRW. Currently, supported currencies are USD, KRW and JPY

  • loginProviders: <string[]> optional It's the list of login providers. Currently, supported providers are google, apple, naver, and discord. Define only the necessary login providers.

    • If this value is not specified, all provided providers can be used.

    • If an empty array is provided, only email login is available. (Supported from version v0.0.3)

Return value

  • Promise<void>

Example

await wepinSdk.init({
    type: 'hide',
    defaultLanguage: 'ko',
    defaultCurrency: 'KRW',
})

// google, apple login
await wepinSdk.init({
    type: 'hide',
    defaultLanguage: 'ko',
    defaultCurrency: 'KRW',
    loginProviders: ['google', 'apple']
})

// only email login
await wepinSdk.init({
    type: 'hide',
    defaultLanguage: 'ko',
    defaultCurrency: 'KRW',
    loginProviders: []
})

isInitialized

It checks if WepinSDK is initialized properly.

wepinSdk.isInitialized()

Parameters

  • <void>

Return Value

  • <boolean> It returns true if init was successful, otherwise returns false.

Example

await wepinSdk.init({
    type: 'hide',
    defaultLanguage: 'ko',
    defaultCurrency: 'KRW',
})

if(wepinSdk.isInitialized()) {
  console.log('wepinSDK is initialized!')
}

changeLanguage

It allows changing the language and currency of the widget.

wepinSdk.changeLanguage({language, currency})

Parameters

  • language <string> It specifies the language to be displayed in the widget. Currently, supported languages are en, ko and ja.

  • currency <string> It specifies the currency to be displayed in the widget. Currently, supported currencies are USD , KRW and JPY

Example

wepinSdk.changeLanguage({
   currency: 'KRW',
   language: 'ko'
})

Last updated