Skip to main content
After embed.js loads, a global window.Cuprice object is available with methods for controlling widgets programmatically. This is especially useful in SPA frameworks.

Methods

Cuprice.refresh()

Re-scans the DOM for new data-cuprice-id or data-cuprice-billing containers and initializes any that haven’t been loaded yet.
In most cases you don’t need this — embed.js uses a MutationObserver to automatically detect new containers added to the DOM.

Cuprice.reset(element)

Removes a widget from a container and allows re-initialization. Useful when you need to swap a Share ID.

Cuprice.destroy()

Removes all event listeners and disconnects the MutationObserver. Call this when your page or component unmounts.

Cuprice.origin

Returns the detected Cuprice origin URL (read-only).

Events

cuprice:plan-selected

Dispatched on document when a customer selects a plan in the billing widget.

cuprice:checkout

Dispatched on document when a buyer picks a plan and the project’s embed behavior is postMessage (set under Integration > Payment). It fires for the pricing embed and the billing widget alike. See Checkout Link.
The payload fields are described in Checkout Flow.

Explicit origin

If origin detection fails (e.g., behind a CDN), set it explicitly: