Listen to Widget events

The attachEventListener method is an optional method for attaching callback functions to specific Widget events.

instantor.attachEventListener(eventName, callbackFunction(payload))

This method attaches an event listener with a specified callback function to the specified event, eventName. When triggered, the callback function is called with an event payload.

Event Name

Payload Example

Description

load

{

status: true

}

Triggered when the Widget has loaded.

The payload contains status true if loading was successful.

processEnd

{

"process-finished"

}

Triggered when the process has ended, i.e. the user completed the last login step.

The payload contains a representation of the result:

"process-finished"

"invalid-login"

"process-error"

chooseBank

{

bankAbbreviation: "se-swedbank",

bankID: "uuid",

sessionID: "uuid"

}

Triggered when the user selects a bank.

The payload contains a representation of the bank and session data:

bankAbbreviation (bank abbreviation)

bankID (unique bank ID)

sessionID (unique session ID).

error

{

message: "error message"

}

Triggered when an error occurs.

The payload contains a description of the error.

displayChange

{

display:

"bankLogin"

}

Triggered when the Widget changes content.

The payload contains a representation of what is displayed:

"bankLogin" (the Widget renders a bank login form)

"bankChooser" (the Widget renders the bank chooser)

Example

An example of how to use attachEventListener

const instantor = new Instantor('produktKey.example')
  
instantor.attachEventListener('chooseBank', function(payload) {
  console.log("The user selected this bank: " + payload.bankAbbreviation);
})
  
instantor.load('#instantor_div');

Last updated