The Paysight Widget uses a message-based system to communicate events and state changes between your application and the widget. This guide explains how to implement effective event handling.
Event System Overview
Events are handled through theonMessage callback provided during widget initialization:
- Event Structure
- Event Flow
Each event message has a consistent structure:
Event Types
Lifecycle Events
Lifecycle Events
Events related to the widget’s lifecycle:
The
READY event indicates that the widget is fully initialized and ready to accept user input. This is a good time to hide any loading indicators.Payment Events
Payment Events
Events related to the payment process:
3D Secure Events
3D Secure Events
Events related to 3DS verification:
3DS events are only triggered when 3D Secure authentication is enabled in your widget configuration.
Form Events
Form Events
Events related to form interactions:
Form events can be useful for tracking user progress and implementing custom validation logic.
Implementing Event Handlers
Best Practices
1
Handle Critical Events
Always implement handlers for these critical events:
2
Implement Error Recovery
3
Maintain UI State
4
Provide User Feedback
Always update your UI based on event messages to keep users informed about the payment process status.
Clear user feedback improves conversion rates and reduces support inquiries.
Next Steps
Styling Guide
Learn how to customize the widget appearance to match your brand.
Localization Guide
Implement multi-language support for global customers.
Events Reference
Complete events documentation