Fize Handler Methods

After configuring the Fize SDK with configure method, configure method returns the methods which can be used programmatically by the user to do certains actions on Fize SDK.

MethodInline Mode SupportOverlay Mode Support
launchNoYes
closeNoYes
destroyYesYes

launch

In overlay mode this method is used to launch the Fize Modal. This method also accepts the custom configuration as its argument.

πŸ“˜

Note: After successful launch of Fize Modal it will call onLaunch callback function if is passed in configuration.

If you are using launch method to setup the configuration on onSuccess Callback and if on_success_redirect is set to true then configuration from configure method will be respected.

<html lang="en">
  <head>
    <script src="https://cdn.getfize.com/sdk/v1.0/getfize.js"></script>
  </head>
  <body>
    <button id="launchFize">Launch Fize</button>
    <script>
      (function () {
        var handler = FIZE.configure({
          client_id: "FIZE_PROVIDED_CLIENT_ID"
        });

        document.getElementById("launchFize").onclick = () => handler.launch({
          config: {
            theme_config: {
              theme_color: "#7d71de",
              primary_text_color: "#403c33",
              secondary_text_color: "#827f78",
              primary_header_color: "#000000",
              secondary_header_color: "#7d6f52",
              border_color: "#e6e5e3",
              link_color: "#1a73e8",
              hover_bg_color: "#ebdec5",
              font_family: "Poppins",
            }
          }
        });

      })();
    </script>
  </body>
</html>

close

In overlay mode this method is used to programatically close the Fize Modal at any point of time.

πŸ“˜

Note: After successful close of Fize Modal it will call onClose callback function if is passed in configuration. It will not return any metadata in onClose callback.

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Fize SDK</title>
  </head>
  <body>
    <button id="launch-btn">Launch</button>
    <script src="https://cdn.getfize.com/sdk/v1.0/getfize.js"></script>
    <script>

      let fizeHandler = window.FIZE.configure({
        client_id: "FIZE_PROVIDED_CLIENT_ID", // fize provided client_id
        onLaunch: () => {
          setTimeout(()=>{
            fizeHandler.close()
          }, 5000)
        }
      });

      document.getElementById("launch-btn").onclick = () => fizeHandler.launch();
    </script>
  </body>
</html>

destroy

This method is used to programatically remove the DOM artifacts (Fize Modal/Container) and remove the subscribed callbacks and other feature configuration that is passed in configure/launch method of SDK.

πŸ“˜

Note: After successful remove of DOM artifacts (Fize Modal/Container) and the subscribed callbacks it will call onDestroy callback function if is passed in configuration.

<html lang="en">
  <head>
    <script src="https://cdn.getfize.com/sdk/v1.0/getfize.js"></script>
  </head>
  <body>
    <button id="destroyBtn">Launch Fize</button>
    <script>
      (function () {
        var handler = FIZE.configure({
          client_id: "FIZE_PROVIDED_CLIENT_ID"
        });

        document.getElementById("destroyBtn").onclick = () => handler.destroy();

      })();
    </script>
  </body>
</html>

What’s Next