SenseJS

SenseJS is a JavaScript library for the browser that is used as a device fingerprint and to track simple page events like loading, pasting, resizing. It also allows the matching between this user's session and their order.


Overview

SenseJS is embeded and invoked on the checkout page.

SenseJS is embedded and invoked on the checkout page.


Prerequisite

  • Your test checkout page must be hosted using HTTPS protocol
  • Please share the url of your test environment so that we can whitelist it

1. Add SenseJS script to <head>

What is SenseJS?

  • SenseJS is a minimal script provided by Flex that is embedded on your checkout page.

Why do I need SenseJS?

  • SenseJS collects important session and fraud detection information (NOT payment data) and delivers it to Flex. This information is matched with the encrypted payment request and allows Flex to leverage the combined data to make real-time decisions for decline rescue.
  • SenseJS does not transmit card data, tokens, or order information. All relevant transaction data and payment information is delivered through explicit API calls secured by TLS and oAuth2.

The snippet to embed SenseJS can be found in your Sandbox account. Developers > Sites > View/Edit > SenseJS

midYour Flex Merchant Identification Number. Get your Mid
siteIdUnique id for each of your websites.
If you are implementing Flex on several websites, make sure that SenseJS snippet contains the right siteId.

❗️

Content Security Policy

If you use CSP (Content Security Policy) headers on your site, you must allow the "*.flex-charge.com" in connect-src directive for full functionality based on your host configuration.

Content-Security-Policy: connect-src 'self' https://*.flex-charge.com;

2. Add this script to <body>

Sense JS needs to be invoked with your orderId for all of your payment transactions, as soon as possible in the payment flow, before you receive the response for your payment transaction from the PSP.

Invoke this function

This is how a customer session can be matched with their specific order.

<script>
    window.addEventListener('load', function() {
            window.fc.setOrderId({ orderId: 'your order id' });
        });
</script>
<script>
    window.addEventListener('load', function() {
            window.fc.createOrderId(); //FlexCharge will generate an orderId for you
        });
</script>

3. Pass the orderId in /evaluate

If that transaction is declined, make sure to pass the same unique orderId in POST /evaluate.