Embed and clean up legal consent
Handle consent acceptance, reset and cleanup in a merchant application.
Get the URL before embedding
Request the application’s legal consent URL before loading the helper. Consent must be complete before submission. The sandbox helper below expects the URL returned for that application.
Load the helper
<div id="consent"></div> <button id="submit" disabled>Submit application</button> <script src="https://sandbox.signup.nmi.com/build/consent-helper-1.0.0.umd.js"></script> <script> const submit = document.getElementById("submit"); LegalConsent.load("<CONSENT_URL>", { selector: "#consent", overlay: "transparent" }, { onAccepted: ({ accepted }) => { submit.disabled = !accepted; }, onError: () => { submit.disabled = true; } }); </script>
Configuration and events
Parameter / event Behavior url Required consent-page URL selector Optional CSS container; defaults to document body overlay Optional background; defaults to transparent onLoad Consent page loaded onAccepted({accepted}) true when signed; false if the signature resets onError({message}) Loading or operation error
Remove the component
Call destroy when removing the widget, including React effect cleanup. It removes the iframe and its listeners. // Run when the consent view unmounts. LegalConsent.destroy();