Widget SDK Reference
API Reference
Complete API reference for the PaySight Widget SDK
API Reference
This document provides a comprehensive reference for the PaySight Widget SDK API, including all available methods, events, and types.
Core API
createWidget
Creates a new instance of the PaySight Widget.
Parameters
targetId
(string) - ID of the HTML element where the widget will be mountedconfig
(WidgetConfig) - Widget configuration optionsonReady
(function, optional) - Callback when widget is readyonError
(function, optional) - Error handler callbackonMessage
(function, optional) - Message handler callback
Returns
Returns a Widget instance with the following methods:
Widget Methods
update
Updates the widget configuration.
destroy
Destroys the widget instance and removes it from the DOM.
reset
Resets the widget to its initial state.
validate
Validates the current widget state.
getState
Returns the current widget state.
Configuration
WidgetConfig
Configuration options for the widget.
WidgetTheme
Theme configuration for customizing the widget appearance.
Events
Event Types
WidgetMessage
Structure of messages received in the onMessage callback.
Event Payloads
Payment Success
Payment Error
3DS Events
Error Handling
Error Types
Error Codes
Common error codes returned by the widget:
Code | Description |
---|---|
VALIDATION_INVALID_CARD | Invalid card number |
VALIDATION_EXPIRED_CARD | Card has expired |
VALIDATION_INVALID_CVV | Invalid CVV code |
NETWORK_CONNECTION_ERROR | Network connection failed |
NETWORK_TIMEOUT | Network request timed out |
PAYMENT_DECLINED | Payment was declined |
PAYMENT_3DS_FAILED | 3D Secure verification failed |
INITIALIZATION_ERROR | Widget failed to initialize |
CONFIG_ERROR | Invalid widget configuration |
State Management
WidgetState
Structure of the widget state object.
Type Definitions
Field Types
Theme Types
Usage Examples
Basic Integration
Custom Styling
Error Handling
State Management
Next Steps
- Basic Integration Example - Simple implementation example
- Custom Styling Example - Customize widget appearance
- 3DS Integration Example - 3D Secure implementation
- Error Handling Example - Advanced error handling