How to integrate trustedforms with UNiK360

 

 

 

Copy paste the code below : 

 

<script type="text/javascript">
  (function() {
      var field = 'xxTrustedFormCertUrl';
      var provideReferrer = false;
      var invertFieldSensitivity = false;
      var tf = document.createElement('script');
      tf.type = 'text/javascript'; tf.async = true;
      tf.src = 'http' + ('https:' == document.location.protocol ? 's' : '') +
        '://api.trustedform.com/trustedform.js?provide_referrer=' + escape(provideReferrer) + '&field=' + escape(field) + '&l='+new Date().getTime()+Math.random() + '&invert_field_sensitivity=' + invertFieldSensitivity;
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(tf, s); }
  )();
let checkInterval;

function trustedFormCertUrlCallback(certificateUrl) {  
  // If certificateUrl is null, start or continue checking every second
  if (certificateUrl === null) {
    if (!checkInterval) {
      checkInterval = setInterval(function() {
        // This will re-trigger the trustedForm API. 
        // I'm assuming the API will call `trustedFormCertUrlCallback` again once it has a value.
        // If not, you might need a different approach to recheck the value.
      }, 1000);
    }
    return;
  }

  // If we've reached here, certificateUrl is not null.
  // If there's an interval checking, clear it.
  if (checkInterval) {
    clearInterval(checkInterval);
    checkInterval = null;
  }

  // Now set the value and dispatch the event.
  document.querySelector('[data-q="xxtrustedformcerturl"]').value = certificateUrl;
  document.querySelector('[data-q="xxtrustedformcerturl"]').dispatchEvent(new Event("input"));
}

</script>
<noscript>
    <img src="http://api.trustedform.com/ns.gif" />
</noscript>