Widget tokens expire after 5 minutes and are scoped to a specific card. Generate a new token on each page load or when the user initiates a new PIN change.
The widget dispatches lifecycle events across two phases:
Phase
Events
Description
Initialization
load or error (mutually exclusive)
Fires once when the widget first renders and its secure input fields load (or fail to load).
Submission
success or failure
Fires after the user submits the form.
load — Widget initialized successfully, all fields are ready for user input.
error — Widget failed to initialize (field load failure, network error, or timeout).
success — PIN was set successfully.
failure — PIN setting failed (PINs do not match, expired widget token, or API error).
error fires only during widget initialization (e.g., a secure input field failed to load). If the widget loads successfully but the user’s submission fails — mismatched PINs, expired token — that triggers failure, not error.
You can listen for events using either addEventListener or callback properties:
Dispatched when the widget fails to initialize. This means one or more secure input fields could not load, and the widget is not functional. Show an error message or retry UI to the user.
Property
Type
Description
instanceId
string
Unique ID for this widget instance
error
string
Human-readable error message (safe to display)
failedFields
string[]
List of field types that failed to load
<script> document.getElementById('setpin-widget').addEventListener('error', (event) => { const { error, failedFields } = event.detail; console.error('Widget initialization failed:', error, failedFields); // Show error UI or offer a retry button });</script>
The load and error events are mutually exclusive — exactly one will fire during widget initialization. Always listen for both to handle all scenarios.
Dispatched after the user submits the PIN form. Common failure reasons include mismatched PINs and expired widget token.The success event exposes only non-sensitive status metadata:
Property
Type
Description
status
string
Submission status returned by the widget
message
string
Optional human-readable success message
instanceId
string
Unique ID for this widget instance
PIN values are never included in host-page event details.