> ## Documentation Index
> Fetch the complete documentation index at: https://developer.tazapay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrate with risk SDK

> This allows you to integrate with risk SDK and fetch the `session_id`

For the best performance of Tazapay's Fraud Detection system, you should integrate the risk SDK into every payment process initiated by shoppers. It captures advanced signals that are leveraged in Tazapay's fraud model. These signals include:

* Device Identification
* Geolocation
* Spoofing Attempts
* Fingerprinting Data

## How it works

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/tazapay-58ae360f/api-reference/tazapay-api/javascript-sdk/images/image-2.png" alt="How it works" />
</Frame>

## Integrate the risk SDK

### Set up tazapay.js

<CodeGroup>
  ```html Production (livemode) theme={null}
  <head>
    <title>Checkout</title>
    <script type="text/javascript" src="https://js.tazapay.com/v3.js"></script>
  </head>
  ```

  ```html Sandbox (Testmode) theme={null}
  <head>
    <title>Checkout</title>
    <script type="text/javascript" src="https://js-sandbox.tazapay.com/v3.js"></script>
  </head>
  ```
</CodeGroup>

<Warning>
  **Dynamic Injection**

  Before injecting the SDK dynamically, please use the following event listener to determine when the script has finished loading.

  ```javascript theme={null}
  window.addEventListener('tazapaySDKReady', () => {
  // continue to use library 
  });
  ```
</Warning>

### Initialising tazapay.js with your public key

```html HTML theme={null}
const tazapay = await window.tazapay('pk_test_TYooMyTiskhfuvdEDq54NiTphI7jx');
```

The above code creates an instance of the Tazapay object. This created object now serves as an entry-point to the rest of Tazapay’s JS SDK.

> You can fetch the public key from the <a href="https://dashboard.tazapay.com"> Tazapay dashboard</a>.

### Retrieve the session\_id

When the customer clicks to pay, publish the device data and retrieve the session\_id

```javascript JavaScript theme={null}
const session_id = await tazapay.publishRiskData();
```

> The function tazapay.publishRiskData() will create a promise when called which resolves into a session\_id string.

## Attach the session\_id to the transaction

* Pass the session\_id to your server.
* Pass the session\_id in the API calls to the following depending on your use case
  * <a href="/api-reference/tazapay-api/checkout/create-checkout"> Create Checkout</a>
  * <a href="/api-reference/tazapay-api/payin/create-payin"> Create Payin</a>
  * <a href="/api-reference/tazapay-api/payin/confirm-payin"> Confirm Payin</a>
  * <a href="/api-reference/tazapay-api/create-escrow-api"> Create Escrow</a>
