Overview
This tutorial covers how to use Fingerprint to strengthen chargeback dispute evidence by linking purchases to a visitor over time, even when a customer claims an unauthorized transaction. You’ll begin with a starter app that includes a simple event ticket storefront where you can make purchases, a personal order history view where you can simulate a chargeback, and a merchant/admin view where you can view purchase details. From there, you’ll add the Fingerprint JavaScript agent to identify each visitor and use server-side logic to link purchases together with a visitor identifier to prove a consistent pattern of legitimate activity tied to the same visitor. By the end, you’ll have a sample app that creates a browser-linked purchase history you can reference when a customer disputes a charge, claiming the purchase wasn’t made by them (AKA friendly fraud). This tutorial uses just plain JavaScript and a Node server with SQLite on the back end. For language- or framework-specific setups, see our quickstarts.Estimated time: < 15 minutes
Prerequisites
Before you begin, make sure you have the following:- A copy of the starter repository (clone with Git or download as a ZIP)
- Node.js (v20 or later) and npm installed
- Your favorite code editor
- Basic knowledge of JavaScript
1. Create a Fingerprint account and get your API keys
- Sign up for a free Fingerprint trial, or log in if you already have an account.
- After signing in, go to the API keys page in the dashboard.
- Save your public API key, which you’ll use to initialize the Fingerprint JavaScript agent.
- Create and securely store a secret API key for your server. Never expose it on the client side. You’ll use this key on the backend to retrieve full visitor information through the Fingerprint Server API.
2. Set up your project
- Clone or download the starter repository and open it in your editor:
Terminal
- This tutorial will be using the
chargeback-disputefolder. The project is organized as follows:
Project structure
- Install dependencies:
Terminal
- Copy or rename
.env.exampleto.env, then add your Fingerprint API keys:
Terminal
- Start the server:
Terminal
- Visit http://localhost:3000 to view the mock events storefront and make a few test purchases, then open your order history page to simulate a chargeback on one of them, and finally switch to the merchant view to inspect the disputed order where you’ll see only limited evidence to help you prove the purchase was actually appropriately authorized.
3. Add Fingerprint to the front end
In this step, you’ll load the Fingerprint client when the page loads and trigger identification when the user clicks Complete purchase. Fingerprint returns both avisitorId and a requestId. Instead of relying on the visitorId from the browser, you’ll send the requestId to your server along with the purchase data. The server will then call the Fingerprint Events API to securely retrieve the full identification details, including Smart Signals you can use as evidence during chargeback disputes.
- At the top of
public/index.js, load the Fingerprint JavaScript agent:
public/index.js
- Make sure to change
regionto match your workspace region (e.g.,eufor Europe,apfor Asia,usfor Global (default)). - Near the bottom of
public/index.js, the Complete purchase button already has an event handler for submitting the purchase details. Inside this handler, request visitor identification from Fingerprint using theget()method and include the returnedrequestIdwhen sending the purchase details to the server:
public/index.js
get() method sends signals collected from the browser to Fingerprint servers, where they are analyzed to identify the visitor. The returned requestId acts as a reference to this specific identification event, which your server can later use to fetch the full visitor details.
For lower latency in production, check out our documentation on using Sealed Client Results to return full identification details as an encrypted payload from the get() method.
4. Receive and use the request ID to get visitor insights
Next, pass therequestId through to your server-side purchase logic, initialize the Fingerprint Server API client, and fetch the full visitor identification event so you can access the trusted visitorId and any additional Smart Signals you want to store for dispute evidence.
- In the back end, the
server/server.jsfile already defines API routes for the app. Notice that thePOST /api/purchasesroute simply passes the request body to apostPurchasefunction that is defined in theserver/purchases.jsfile:
server/server.js
- The
server/purchases.jsfile contains the logic for handling purchase submissions and chargebacks. Start by importing and initializing the Fingerprint Server API client there, and load your environment variables withdotenv:
server/purchases.js
- Make sure to change
regionto match your workspace region (e.g.,EUfor Europe,APfor Asia,Globalfor Global (default)). - Update your purchase handler function to extract
requestIdand use it to fetch the full identification event details from Fingerprint so you can log thevisitorIdalongside each purchase:
server/purchases.js
requestId, the Fingerprint server client will retrieve the full data for the visitor identification request. The returned object will contain the visitor ID, IP address, device, and browser details, and Smart Signals like bot detection, browser tampering detection, VPN detection, and more.
You can see a full example of the event structure and test it with your own device in our demo playground.
For additional checks to ensure the validity of the data coming from your front end, view how to protect from client-side tampering and replay attacks in our documentation.
5. Link purchase history with visitor IDs
Next, use the trustedvisitorId from the event object to link purchases together. Instead of relying only on an account email or IP address, you’ll associate each purchase with the visitorId, so you can later show that the same visitor has a history of legitimate purchases when a chargeback happens.
Note: The starter app includes a SQLite database with a table already created for you:
SQLite database tables
- First update the existing
postPurchasefunction so it stores thevisitorIdalongside each new row in thepurchasestable.
server/purchases.js
- Update the
getRelatedPurchasesfunction so it looks up related orders based on both email and visitorId. This lets you see the full history for a visitor even if they change accounts.
server/purchases.js
- In the merchant/admin view (
public/admin.js), update the following functions to include thevisitorIdwhen displaying and exporting the history related to a purchase:
public/admin.js
- Then in the
admin.htmlfile, uncomment the visitor ID header and template column:
public/admin.html
This is a minimal example showing how to use Fingerprint data to support
chargeback disputes. In a real application, make sure to implement proper
security practices, perform robust server-side validation, and follow your
organization’s standards for storing and transmitting evidence related to
payments and disputes.
6. Test your implementation
Now that everything is wired up, you can see how the visitor ID provides additional evidence for chargeback disputes.- Start your server if it isn’t already running and open http://localhost:3000:
Terminal
- Make a few purchases from the main Events page. Each one will be logged with both your account email (you are logged in as
jamie@example.com) and your visitor ID. - Open your personal Order history page and simulate a chargeback on one of them.
- Switch to the Merchant view and view the purchase history related to the purchase with the chargeback. You’ll see your full purchase history including visitor ID, showing that the disputed purchase and the earlier successful purchases all originated from the same browser.