Greeting Card Builder SDK
Methods
Open, preload, close, inspect, update, and destroy a Greeting Card Builder instance.
window.GreetingCardBuilder(config) returns an isolated SDK instance.
const builder = window.GreetingCardBuilder({
closeOnComplete: true,
})
Instance surface
| Member | Signature | Behavior |
|---|---|---|
open | (initData?: object) => instance | Creates or reuses the iframe, opens the modal, and queues initialization. |
preload | (initData?: object) => instance | Creates the iframe and queues initialization without opening the modal. |
close | (reason?: string) => instance | Closes an open modal. The default reason is 'api'. |
updateConfig | (nextConfig?: object) => instance | Shallow-merges configuration. Rebuilds the iframe when its URL changes. |
getConfig | () => object | Returns a shallow copy of current configuration. |
getIframe | () => HTMLIFrameElement | null | Returns the current iframe, if one exists. |
isOpen | () => boolean | Reports whether the modal is open. |
isLoaded | () => boolean | Reports whether the iframe's browser load event fired. |
isReady | () => boolean | Reports whether the trusted builder emitted gm/ready. |
destroy | () => void | Closes the modal, removes DOM and message listeners, and makes the instance unusable. |
Preload before a user action
Preloading can reduce the delay when the shopper opens the card builder.
builder.preload(cardInitData)
openButton.addEventListener('click', () => {
builder.open()
})
The SDK sends init data only after the iframe reports ready. Calling
preload(nextInitData) again queues and sends the newer payload with a new
requestId.
Update configuration
builder.updateConfig({
closeOnBackdrop: true,
modalPadding: '24px',
borderRadius: '16px',
})
Modal accessibility and style fields update immediately. A change that alters the iframe URL tears down the old frame; if the modal is open, the SDK creates the replacement frame immediately.
Destroy permanently
Call destroy() during application teardown when the SDK instance will not be
used again. Calls to open(), preload(), or updateConfig() after destruction
throw an error. Create a new instance if the integration needs to start again.
