Skip to main content
Version: Live

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
}
Keytypedescription
successBooleantrue when the Messenger connected.
errorStringWhy 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​

  • initialize adds 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: true without reconnecting.
  • If it fails, call it again to retry.
  • The ready event fires when the connection opens.