Include the javascript sdk on each page of your site where your payment form exists. It should always be loaded directly with a script tag rather than included in a bundle.
Copy
Ask AI
<script src="js.gravity-legal.com/hosted-fields.js" />// Or in the Sandbox Environment<script src="js.sandbox.gravity-legal.com/hosted-fields.js" />
The script will use window.postMessage to post a message when it has finished loading and is ready for initialization. You can setup a listener to get notified.
Copy
Ask AI
const myListener = (e) => { if (e.data === "confido_hosted_fields_script_loaded") { console.log("sdk is loaded!"); }};window.addEventListener("message", myListener);
Then initialize the sdk with the Payment Token. For a more detailed explanation of the init() method, see the Hosted Fields SDK Reference Docs.