initialize
Connects the Messenger to Pay Theory. Call it before any other Messenger function.
Function
await messenger.initialize()
Parameters
This function takes no parameters.
Returns
{
success: Boolean
error: String
}
| Key | type | description |
|---|---|---|
| success | Boolean | true when the Messenger connected. |
| error | String | Why the connection failed, when success is false. |
Usage
const messenger = new paytheory.PayTheoryMessenger({
apiKey: 'your-api-key'
});
const result = await messenger.initialize();
if (result.success) {
// Messenger is ready for operations
} else {
console.error('Initialization failed:', result.error);
}
Notes
initializeadds a hidden iframe to the page and opens a secure channel to Pay Theory through it.- Calling it again on a connected Messenger returns
success: truewithout reconnecting. - If it fails, call it again to retry.
- The
readyevent fires when the connection opens.