Listeners object

The listeners object helps you keep track of events in the module and respond accordingly.

The following events are available:

Event Expected data Description
closeundefinedIt's triggered when the user closes a widget.
name: String;
message: String;
Widget error message (not payment-related), see error codes.
loadedundefinedIt indicates the module is loaded with necessary data and ready to receive extra data if needed.
This event may duplicate if the user is redirected to their bank's 3-D Secure verification page.
status: String
payment_id: String
order_id: String
tx_id: String // if available
Possible statuses: 
Events may not be unique for each status.
tx_id appears in the pending status.
step: String
Notifies changes in user flow position.
ticker: String,
fee_percent: String,
currency_amount: String,
fee_amount: String,
commodity_amount: String,
purchase_amount: String,
miner_fee: String,
currency_miner_fee: String
Updates when the widget rate changes. We fix the exchange rate for 30 seconds.

Add the listeners object like this: the key is the event type, and the value is your callback function.

const widget = new WertWidget({
  listeners: {
    position: (data) => console.log("step:", data.step),

To subscribe to the payment status data, you can do the following:

const widget = new WertWidget({
  listeners: {
    'payment-status': data => console.log('Payment status:', data)

This will only be triggered when simulating the purchase, not in intermediary steps.