- Load Script – Inject the SDK script and wait for
onRevupSDKLoaded
- Wait for SDK + orderId – Only run
renderForm() when sdkLoaded && orderId (and optionally form options).
- Single listener –
document.addEventListener('onRevupMessage', onRevupMessageHandler) to capture all events (and e.g. store them in state).
- Config – Build
config from environment (env), apiKeys, and current orderId; set merchantDomain from window.location.host (or override for local/dev).
- Create and init –
revup = new Revup(config) then await revup.init({ containerId: 'revup-container', form: { ...formOptions } }).
- Optional – Call
revup.getApmsAvailable() after init and use the result as needed.
- Cleanup – On unmount or before re-init, abort the event listener and clear the container inner HTML.