knownprintDocs

Guides

Stop payment fraud

Count cards per browser, hold risky payments before capture and trace chargebacks back to the browser that made them, with the knownprint event of each payment attempt.

The threat

Stolen card numbers are tested with small payments, one card after another, and the cards that pass are then used for real orders. The chargebacks land on you weeks later, with fees, lost goods and a dispute rate your payment processor watches.

A card tester changes cards, emails, accounts and cookies with every try. The browser stays the same far more often. knownprint gives your backend a visitor_id for the browser behind each payment attempt, so your code can count cards per browser instead of per account, and hold a payment when the count or the suspect score runs high.

This guide covers where to identify, which fields to read, a decision table to start from, a complete backend example, how to review held payments, what to do when a chargeback arrives, and the mistakes to avoid.

Where to identify

Identify the visitor at every payment attempt, right before the request that charges the card, and send the request id with it. A retry after a decline is a new attempt and gets a new request id.

MomentWhy
The customer presses PayThe attempt you decide on: allow, challenge with 3-D Secure, hold for review, or refuse
A card is added to a wallet or accountCard testing often happens on "add a card" pages that verify the card with a small authorisation
A gift card or stored balance is redeemedStolen cards are turned into gift cards and spent elsewhere
A refund or payout destination is changedOften the next step after a takeover (Account takeover)

In the page, identify inside the payment handler, not when the checkout page loads: your backend accepts a request id only within 10 seconds of the identification, and only once.

checkout.js
// Once, when the page starts. Resolves null when the script is blocked or fails to load.
const agentReady = window.knownprint
  ? window.knownprint.load({ pk: 'pk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' }).catch(() => null)
  : Promise.resolve(null);

/** A fresh request id, or null when the agent is blocked, fails or takes longer than 3 seconds. */
function requestId(action) {
  const timeout = new Promise((resolve) => setTimeout(() => resolve(null), 3000));
  const attempt = agentReady
    .then((agent) => (agent === null ? null : agent.identify({ tags: { action } })))
    .then((result) => (result === null ? null : result.requestId))
    .catch(() => null);
  return Promise.race([attempt, timeout]);
}

async function pay(paymentToken) {
  // null when blocked or failed: the payment goes without one and the backend treats it as unknown.
  const kp_request_id = await requestId('payment');
  const res = await fetch('/payments', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ order_id: orderId, payment_token: paymentToken, kp_request_id }),
  });
  return res.json();
}

Add the browser agent shows how to load the agent; Protect a form does the same for a plain HTML form.

Which fields to read

Your backend reads the event with GET /v1/events/{request_id} (Events has the full reference).

FieldWhat it tells you at a paymentHow to use it
visitor_idThe browser behind this attemptStore it with every attempt; count distinct cards and declines per browser
confidenceHow sure knownprint is about visitor_id, from 0 to 1Act on a browser's history automatically only above a level you choose
match_typenew when knownprint has not seen this browser before, as far as it can tellA new browser has no history of its own; read high_recall_id
high_recall_idThe past visitor this browser most likely is, when knownprint was not sure enough to match it, or nullIf that visitor has chargebacks, review the payment; never refuse on it alone
anonymity_set_sizeThe lookalike count: 1 plus the known browsers that look the sameAbove 1, give high_recall_id less weight
signals.suspect_score.value0 to 100: how much of the visit's signals your site should worry aboutYour main threshold (Suspect score)
signals.bot.valuebad when automation drove the browserCard testing is usually scripted: refuse (Bots)
signals.tor, signals.proxy, signals.vpnThe payment came through Tor, a proxy or a VPNContext; a challenge rather than a refusal on its own (Network signals)
network.countryThe country of the address the request came from, as a two-letter upper-case code such as DE, or nullCompare with the card's billing country, in the same two-letter form
signals.tampering, signals.virtual_machineThe browser misreports what it is, or runs in a virtual machineWeighed in the suspect score; worth showing a reviewer (Browser signals)
integrity.replayedTrue when this identification was sent beforeRefuse it: never charge on a replayed request (Integrity)

Every signal holds value, confidence and reasons. A signal can be null when it could not be read on that visit: treat null as unknown, not as false.

Decision table

The thresholds below are starting points to tune on your own traffic, not knownprint defaults. Rows are checked from the top; the first that applies decides.

What you seeDecision
The request id was used before, the event was replayed, or it was made on another originBlock
signals.bot.value is badBlock
This browser, or a visitor merged into it, tried 3 or more distinct cards in the last 24 hours (this one included)Block
This browser had 3 or more declined attempts in the last hourBlock
No request id, the event is not found or stale, or knownprint did not answerChallenge with 3-D Secure, or hold for review if you cannot challenge
This browser, or a visitor merged into it, has a past chargeback, and confidence is at least 0.9Review
match_type is new and high_recall_id names a visitor with a past chargebackReview
signals.suspect_score is missing or nullChallenge
signals.suspect_score.value at or above 70Review: authorise, and capture only after a person approves
signals.tor.value or signals.proxy.value is trueChallenge
network.country differs from the card's billing country, and the suspect score is 40 or moreChallenge
signals.suspect_score.value from 40 to 69Challenge
None of the aboveAllow

A VPN alone is not on the list: many honest customers use one. It counts toward the suspect score, which is where it belongs.

Backend example

A complete Express handler in Node 22 with Postgres. It uses the knownprint.js module from Read and verify the event, counts cards and declines per browser over the browser and every visitor merged into it, applies the decision table, and records the attempt with its visitor_id and request_id. The secret key needs events:read for the reads and events:write for the PATCH.

payments.js
import express from 'express';
import { db, fired, kp, readEvent, suspectScore } from './knownprint.js';

const app = express();
app.use(express.json());

// create table payment_attempts (
//   id bigserial primary key,
//   order_id text not null,
//   account_id text,
//   request_id text,                 -- null when the page sent none
//   visitor_id text,                 -- null when there was no verified event
//   card_key text not null,          -- a stable id of the card from your processor
//   decision text not null,          -- allow, challenge, review, block
//   declined boolean not null default false,
//   chargeback boolean not null default false,
//   created_at timestamptz not null default now()
// );
// create index on payment_attempts (visitor_id, created_at);

/** The visitor id and every visitor id merged into it. */
async function idsOf(visitorId) {
  const visitor = await kp(`/v1/visitors/${visitorId}`);
  return visitor === null ? [visitorId] : [visitor.visitor_id, ...visitor.aliases];
}

async function historyOf(ids, cardKey) {
  const { rows } = await db.query(
    `select
       count(distinct card_key) filter (
         where created_at > now() - interval '24 hours' and card_key <> $2) as other_cards,
       count(*) filter (where declined and created_at > now() - interval '1 hour') as declines,
       bool_or(chargeback) as chargeback
     from payment_attempts where visitor_id = any($1)`,
    [ids, cardKey],
  );
  return {
    cards: Number(rows[0].other_cards) + 1, // the card of this attempt included
    declines: Number(rows[0].declines),
    chargeback: rows[0].chargeback === true,
  };
}

/** The decision table above. The thresholds are examples to tune. */
async function decide(result, payment) {
  if (result.outcome === 'invalid') return { decision: 'block', why: result.reason };
  if (result.outcome === 'unknown') return { decision: 'challenge', why: result.reason };

  const { event } = result;
  if (event.signals?.bot?.value === 'bad') return { decision: 'block', why: 'bot' };

  const ids = await idsOf(event.visitor_id);
  const history = await historyOf(ids, payment.cardKey);
  if (history.cards >= 3) return { decision: 'block', why: 'cards_per_browser' };
  if (history.declines >= 3) return { decision: 'block', why: 'declines_per_browser' };
  if (history.chargeback && event.confidence >= 0.9) {
    return { decision: 'review', why: 'browser_with_chargeback' };
  }

  if (event.match_type === 'new' && event.high_recall_id !== null) {
    const lead = await historyOf(await idsOf(event.high_recall_id), payment.cardKey);
    if (lead.chargeback) return { decision: 'review', why: 'likely_browser_with_chargeback' };
  }

  const score = suspectScore(event);
  if (score === null) return { decision: 'challenge', why: 'no_score' };
  if (score >= 70) return { decision: 'review', why: `suspect_score ${score}` };
  if (fired(event, 'tor') || fired(event, 'proxy'))
    return { decision: 'challenge', why: 'network' };
  const country = event.network.country;
  if (score >= 40 && country !== null && country !== payment.billingCountry) {
    return { decision: 'challenge', why: 'country' };
  }
  if (score >= 40) return { decision: 'challenge', why: `suspect_score ${score}` };
  return { decision: 'allow', why: 'clean' };
}

app.post('/payments', async (req, res) => {
  const account = req.user; // your own session, or null for a guest checkout
  const order = await loadOrder(req.body.order_id); // your own order lookup
  const card = await describeCard(req.body.payment_token); // your processor: card key, country

  const result = await readEvent(req.body.kp_request_id);
  let decided;
  try {
    decided = await decide(result, { cardKey: card.key, billingCountry: card.country });
  } catch {
    decided = { decision: 'challenge', why: 'knownprint_unavailable' }; // a read failed
  }
  const { decision, why } = decided;
  const event = result.event ?? null;

  if (event !== null && result.outcome === 'ok') {
    const patch = { tags: { action: 'payment', order: order.id, decision } };
    if (account) patch.linked_id = String(account.id); // a string of 1 to 128 characters
    // Best effort: a failed update must not fail the payment.
    await kp(`/v1/events/${event.request_id}`, { method: 'PATCH', body: patch }).catch(() => {});
  }

  const attempt = await db.query(
    `insert into payment_attempts
       (order_id, account_id, request_id, visitor_id, card_key, decision)
     values ($1, $2, $3, $4, $5, $6) returning id`,
    [
      order.id,
      account?.id ?? null,
      event?.request_id ?? null,
      event?.visitor_id ?? null,
      card.key,
      decision,
    ],
  );
  const attemptId = attempt.rows[0].id;

  if (decision === 'block') return res.status(402).json({ ok: false, error: 'payment_declined' });

  // Your processor: challenge runs 3-D Secure, review authorises without capturing.
  const charge = await chargeCard(order, req.body.payment_token, {
    threeDSecure: decision === 'challenge',
    capture: decision === 'allow' || decision === 'challenge',
  });
  if (charge.declined) {
    await db.query('update payment_attempts set declined = true where id = $1', [attemptId]);
    return res.status(402).json({ ok: false, error: 'payment_declined' });
  }
  if (decision === 'review') await queueForReview({ order, attemptId, why }); // your queue
  return res.json({ ok: true, status: decision === 'review' ? 'pending' : 'paid' });
});

loadOrder, describeCard, chargeCard and queueForReview stand for your own order store, payment processor and review queue. Every route, status code and limit used here is in the API reference, and Verify a request in your backend explains the checks in readEvent.

The example attaches no linked_id to a guest checkout. To link guest orders across visits, use an id of your own that is not personal data, such as a customer number, never an email address or a card number.

Review held payments

A reviewer deciding on a held payment needs the browser's whole story. Three reads give it:

Shell
# Every event of this browser and of every visitor merged into it, newest first.
curl "$KNOWNPRINT_API/v1/events?visitor_id=v_v4seh2kvj72ceuvw75efr6edt4&limit=50" \
  -H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"

# The accounts and other browsers related to it.
curl "$KNOWNPRINT_API/v1/visitors/v_v4seh2kvj72ceuvw75efr6edt4/related" \
  -H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"

# Everything from the same address range during a card-testing burst.
curl "$KNOWNPRINT_API/v1/events?ip=198.51.100.0/24&start=2026-12-01T09:00:00Z&end=2026-12-01T10:00:00Z" \
  -H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"

Each search answers { "data": [ ...events ], "next_cursor": "..." }; pass next_cursor back as cursor for the next page until it is null. A daily sweep of risky payments is one more search, GET /v1/events?min_suspect_score=70&start=..., whose events you match to your orders by request_id. The Events API lists every filter.

For an alert as payments happen, subscribe a webhook to event.identified and act on the events whose tags.action is payment and whose suspect score is high. The delivery carries the event as it was when it was identified, with the tags the page sent; a PATCH made afterwards is not in it. Verify every delivery (Verify a webhook) and answer with a 2xx quickly; see Webhooks.

When the reviewer decides, release or void the authorisation in your processor and label the event:

review.js
import { kp } from './knownprint.js';

await kp(`/v1/events/${attempt.request_id}/feedback`, {
  method: 'POST',
  body: { label: approved ? 'legit' : 'fraud', note: `review of order ${attempt.order_id}` },
  idempotencyKey: `review-${attempt.id}`,
});

When a chargeback arrives

A chargeback is the truth about a payment, weeks late. Use it three ways:

  1. Label the event. POST /v1/events/{request_id}/feedback with label: 'fraud', using the request_id you stored with the attempt (Feedback).
  2. Mark the browser. Set chargeback = true on the attempt. The decision table above then reviews every later payment from that browser and from browsers knownprint names as likely the same.
  3. Find the rest. Search the browser's other events with GET /v1/events?visitor_id=... and match their request_id to your orders: a card tester rarely stops at one card. Hold or refund the orders still open.

Pitfalls

  • Approving a payment without a request id. A card-testing script that posts to your payment endpoint directly sends no request id. Treat a missing request id as unknown: challenge or hold, never approve on "no data".
  • Counting per account or per cookie. Card testers make a new account and clear cookies for every card. Count per visitor_id, over every visitor merged into it.
  • Treating high_recall_id as a match. It is the most likely past visitor when knownprint was not sure, and on popular phones several browsers can look the same (anonymity_set_size above 1). Use it to send a payment to review, not to refuse it.
  • Refusing every VPN. Plenty of honest customers pay through a VPN. Let the suspect score weigh it, and keep refusals for automation, replays and card counts.
  • Identifying when the checkout page loads. Your backend accepts a request id only within 10 seconds of the identification, and only once. Identify when the customer presses Pay, and again for every retry.
  • Telling the tester which check failed. "Too many cards from this browser" teaches them to switch browsers. Answer every refusal with the same plain decline.
  • Keeping only knownprint's copy. Chargebacks can arrive months later, and events are deleted after your account's event retention period, between 30 and 365 days (Privacy). Store request_id and visitor_id with every attempt, as the example does.
  • Failing open when knownprint is slow. Give the event read a short timeout, and treat a timeout as unknown: for payments that means a challenge or a hold, not an approval.