# Finix.js Reference

Finix.js is a client-side JavaScript library for securely collecting and tokenizing payment details. It renders an embedded payment form inside an iframe, keeping sensitive card and bank data out of your application and ensuring PCI compliance.

## Including finix.js

Always load the library directly from `https://js.finix.com`. Never self-host or bundle finix.js — doing so breaks PCI compliance.


```html
<script src="https://js.finix.com/v/2/finix.js"></script>
```

## Fraud Detection

For best fraud detection, initialize the `Finix.Auth` service on every page of your site, not just the checkout. This allows Finix to monitor potential malicious behavior. See the [Fraud Detection API Reference](/js/auth) to learn how to integrate Finix.js's built-in fraud detection in your application.

## Global API

| Method | Description |
|  --- | --- |
| [Finix.PaymentForm()](/js/payment-form) | Create and render a secure payment form for collecting card and bank details. |
| [Finix.Auth()](/js/auth) | Initialize fraud detection and session tracking. |


## Quick start


```html
<!-- 1. Include the script -->
<script src="https://js.finix.com/v/2/finix.js"></script>

<!-- 2. Add a mount point -->
<div id="payment-form"></div>

<script>
  <!-- 3. Initialize fraud detection -->
  const finixAuth = Finix.Auth("sandbox", "MUeDVrf2ahuKc9Eg5TeZugvs");

  <!-- 4. Initialize the form -->
  Finix.PaymentForm(
    "payment-form",
    "sandbox",
    "APgPDQrLD52TYvqazjHJJchM",
    {
      onSubmit: function (error, response) {
        if (error) {
          console.error("Error:", error);
          return;
        }
        const tokenData = response.data || {};

        // Send token and fraud session key to your backend
        fetch("/your/backend", {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify({
            token: tokenData.id,
            fraud_session_id: finixAuth.getSessionKey(),
          }),
        });
      },
    }
  );
</script>
```