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 |
---|---|---|
close | undefined | It's triggered when the user closes a widget. |
error | { | Widget error message (not payment-related), see error codes. |
loaded | undefined | It indicates the module is loaded with necessary data and ready to receive extra data if needed. |
payment-status | { | Possible statuses: |
position | { | Notifies changes in user flow position. |
rate-update | { | 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({
...options,
listeners: {
position: (data) => console.log("step:", data.step),
},
});
To subscribe to the payment status data, you can do the following:
const widget = new WertWidget({
...options,
listeners: {
'payment-status': data => console.log('Payment status:', data)
},
});
This will only be triggered when simulating the purchase, not in intermediary steps.
Updated 18 days ago