fintech-compliance
Business layer (business/README.md). Money code fails differently from other code: a bug is a
support ticket, a financial bug is a discrepancy someone has to reconcile, sometimes a regulatory
finding. This block is business/data-protection's sibling, aimed at payments/ledger/regulated-finance
work instead of personal data — same posture: route the legal question to the right person, and own the
engineering consequences ourselves.
This is not legal, compliance or accounting advice. Where a question has a regulatory answer —
whether a licence is needed, whether a customer needs enhanced due diligence, whether a specific flow
is in PCI DSS scope — the answer comes from compliance/legal, not from here.
When
As soon as a feature: touches card data in any form, moves money between two parties (a customer and
the company, two customers, a customer and a third party), maintains a balance or a ledger, or onboards
a user for a regulated financial service (an account, a wallet, a payout).
Steps
1. Route the regulatory questions before writing code
Take these to compliance/legal rather than guessing — same posture as business/data-protection §2:
- Does this feature put us in PCI DSS scope? Any flow where card data (the PAN, the CVV, the
expiry) passes through, is stored by, or is transmitted by our own systems is in scope. The
practically universal fix is to never let card data touch our servers at all: collect it directly
into the payment processor's own hosted field/SDK, get back a token, and store and reuse only that
token. A flow that routes card data through our backend "just to log it" or "just to validate the
format" just put that backend in scope — that's a decision, not an implementation detail, and it goes
to whoever owns PCI compliance before it ships.
- Does onboarding this kind of user or this kind of flow trigger KYC/AML obligations? Screening
against sanctions lists (OFAC, UN, EU, national lists) at onboarding, and re-screening on a risk
change, is a compliance program's call on who gets screened and how strictly — not a threshold to
invent in the code. What the code has to provide is a hook where that screening can run, and a state
the account can sit in while it's pending.
- Does this need a money-services/e-money licence, or does it fit under someone else's? Moving
money between third parties is regulated in most jurisdictions; "we're just a technical intermediary"
is a legal characterisation, not a fact you get to assume.
2. What the code has to provide: money handling
- Money is never a float. Represent an amount as an integer minor-unit count (cents) or an exact
decimal type, never a binary float — this is
skills/design-patterns §4.5's Value Object entry
applied at its highest-stakes case; a rounding error here isn't cosmetic, it's a discrepancy in a
number someone has to reconcile.
- Every amount carries its currency, and an operation across two amounts checks the currencies
match before doing arithmetic on them — a silent add across currencies is a real, catchable bug
class, not a hypothetical one.
- Rounding is a policy, applied once, at a named point (e.g. half-up at the smallest currency
unit), not wherever a division happens to land in the code. Two different rounding results for the
same computation are how a ledger stops balancing.
3. What the code has to provide: the ledger
- A ledger is append-only. No
UPDATE, no DELETE on a posted entry — correcting a mistake is a
new, explicit reversing entry, never an edit to history. The moment history can be silently changed,
nobody can tell a bug from a cover-up, and reconciliation stops being possible.
- Every movement is (at least) two entries that net to zero — a debit and a matching credit across
two accounts, committed together or not at all. A balance is a derived read over the entries, never
a separately-stored counter that can drift out of sync with what the entries actually say.
- The atomic unit of a financial write is the whole set of entries for one transaction. Partially
applying a multi-entry movement (crediting one side, failing before debiting the other) is a
correctness bug regardless of how rare the failure window looks in testing.
4. What the code has to provide: payment operations
Every request that can be retried (network blip, timeout, a user double-clicking pay) carries an
idempotency key, and the receiving side stores the result keyed on it — a retry with the same key
returns the original result instead of charging twice. This applies to outgoing calls to a payment
processor and, separately, to incoming ones.
A webhook from a payment processor is verified before it's trusted — its signature, against the
raw request body, checked first, before any business logic runs on its payload.
A webhook is deduplicated by the event's own id, not by re-deriving "have I seen this before"
from business state: insert the event id into a processed-events table under a unique constraint
before doing any work; a unique-violation means it's already been handled, so skip. The common miss
is idempotency on the outgoing call only — the incoming webhook handler needs its own, separately.
A webhook handler re-fetches the authoritative state from the processor rather than trusting the
payload alone (design guidance: the processor's documentation allows using the event's own data or fetching the current object) for anything a business decision depends on, and only applies a state transition if
it's actually valid from where the record currently stands (no silently re-applying "paid" to an
already-refunded order).
Reconciliation is a designed-in job, not an afterthought: something that periodically compares
our ledger against the processor's own record of the same transactions and surfaces a mismatch —
stuck-pending payments, a webhook that never arrived, a refund that didn't post — rather than relying
on a customer to notice and complain first.
Idempotency keys have limits worth knowing (processor documentation read 2026-10-20). The processor
saves the first response for a key, including an error, and returns it on retry; a retry with different
parameters is rejected; keys can be pruned after at least 24 hours (stated for API v1), after which a reused key starts a new
request; and a request that failed validation or collided with a concurrent one saves nothing, so it may
be retried. Symptom: a "retry" that charges twice after a day, or that keeps returning a stale error.
Fix: generate one key per intended operation, keep it for as long as retries can happen, and never derive
it from personal data.
Webhook verification needs the untouched raw body. The processor documentation says its signature
check fails if a framework parses or alters the body first. Symptom: signature errors only in
production, behind a body-parsing middleware. Fix: verify before any parsing, with the library the
processor provides, and reject on failure.
Webhooks arrive more than once, late and out of order. The documentation says the same event can be
delivered several times (store handled event ids) and order
is not guaranteed (do not infer sequence from the timestamp, which has one-second resolution). Fix:
dedupe by event id, make every transition valid from the current state, and re-read the object from the
API when order matters.
Fulfil from the server-side event, not the browser return. The payment-status documentation says
customers may leave the page before fulfilment starts, so goods should be released on the
payment-succeeded event, handled asynchronously; polling is described as less reliable. Asynchronous
methods such as bank debits can stay in a processing state for days.
Hosted fields cut scope; they do not remove the duty. The processor's security guide says direct
handling of raw card numbers can bring more than 300 requirements, that its low-risk integrations send
card data straight to it without touching our servers, and that card type, last four digits and expiry
it returns may be stored. The merchant still attests to PCI compliance yearly, and a third-party script
on a payment page makes our security depend on that script's. The PCI council's own page says it
develops the standards but does not enforce them: card brands and acquirers decide who must comply.
Route the SAQ type to whoever owns PCI (the council's FAQ pages on scripts and hosted pages could not
be read).
Ledger storage engines make the same choices. The TigerBeetle documentation (read 2026-10-20) keeps
accounts and transfers immutable, corrects errors with new transfers, stores amounts as integers of a
scaled smallest unit, derives balances from cumulative debits and credits, separates currencies or assets
by a ledger id, makes transfer ids unique, and lets linked transfers succeed or fail together or use a
two-phase pending, post or void flow. Own guidance: these are design checks for ours, not requirements.
Sanctions screening: some facts to hand to compliance. OFAC's FAQ page (read 2026-10-20) states that
an entity owned 50 percent or more, directly or indirectly or in aggregate, by blocked persons is itself
blocked even if not listed (verified 2026-10-21 on FAQ 398-399; re-read before relying). So a name-only match against a list is not the
whole check. Who is screened and how strictly stays compliance's decision.
Output / checkpoint
No pipeline checkpoint (business layer, see business/README.md). What it owes: the PCI-scope and
KYC/AML questions routed to compliance with their answers when they come back, amounts represented
without floats and currency-checked, the ledger append-only with entries that net to zero per
transaction, idempotency on both the outgoing call and the incoming webhook, and a reconciliation
mechanism named rather than assumed.
Guardrails
- Never decide PCI DSS scope, licensing, or a KYC/AML threshold yourself — route it, the same way
business/data-protection routes a lawful-basis question.
- Never let card data reach a server we control if a hosted-field/tokenisation alternative exists —
that's the single biggest scope-reduction lever available, and skipping it is a decision someone
senior should make knowingly, not a default.
- Never edit or delete a posted ledger entry. A correction is a new entry, always.
- Never represent money as a float, and never let an amount cross a currency boundary unchecked.
- Never add idempotency "later" — like
skills/background-jobs-conventions, this is a design property,
and retrofitting it means auditing every already-shipped call site for whether it was ever double-run.
- This block has no dedicated in-house fintech/compliance expertise behind it yet: a solid set of
engineering defaults plus a routing checklist, not proven doctrine, to be confronted with a real
regulated-payments engagement.
Origin
Sourcing pass 2026-10-20 (status stays 🟡, nothing was run). Read for facts, rewritten in our own words,
no text copied: a payment processor's documentation on idempotent requests, webhooks, payment status and
integration security; the PCI council's "about" page; the TigerBeetle data-model and transfer reference pages
(documentation of an Apache-2.0 project; its LICENSE file was not opened here, so facts only); the OFAC FAQ
topic page; one accounting-for-developers article from a ledger vendor (no licence read, facts only, nothing
reproduced). Confirmed: idempotency-key behaviour, signature on the raw body, dedupe by event id, ledger
immutability with correction by new entries, derived balances, integer amounts, atomic multi-entry posting,
tokenised or hosted collection as the scope lever. Corrected: the "re-fetch authoritative state" step is
advice for ordering, not a rule from the processor, and the processor documentation also allows using the
event payload as of the event time; the block's statement now reads as design guidance. Not read: the PCI
council standard itself and its FAQ entries (404 or no text), the FATF recommendations (403), any KYC
rule. The "no dedicated expertise" guardrail stays.
Assembled from public sources, written without internal fintech/compliance expertise, the same honesty
posture as business/data-protection. PCI DSS scope and the tokenisation-as-scope-reduction mechanism:
published PCI compliance and tokenisation-vendor guidance. KYC/AML/sanctions-screening triggers
(onboarding screening, risk-driven re-screening, the OFAC/UN/EU list landscape): published AML/sanctions
compliance guides. Double-entry ledger invariants (append-only, no silent update/delete, balance as a
derived read, atomic multi-entry posting): published ledger-database design writing (Modern Treasury's
ledger engineering series, TigerBeetle's debit/credit documentation) aimed at engineers building
financial systems, not at accountants. Payment idempotency and webhook handling (idempotency keys on
outgoing calls, signature verification before trust, dedup by event id under a unique constraint,
re-fetching authoritative state rather than trusting the payload): published Stripe-style payment
integration practice, generalised beyond one named processor. The money-as-value-object point is not
new here — it cross-references skills/design-patterns §4.5, added 2026-08-11 from the real
the org catalogue's design-patterns plugin — this block is where its highest-stakes case gets spelled
out. Stamped 2026-08-11.
Independent verification 2026-10-21: 22 checked, 19 matched, 1 corrected, 2 unverified
1---2name: fintech-compliance3description: "Use when a feature touches payments, card data, a financial ledger, KYC onboarding or moving money between parties: regulatory scope, and the engineering invariants that keep it correct."4metadata:5 source: https://skillmd.com/skills/techmefr/fintech-compliance6---78# fintech-compliance910Business layer (`business/README.md`). Money code fails differently from other code: a bug is a11support ticket, a financial bug is a discrepancy someone has to reconcile, sometimes a regulatory12finding. This block is `business/data-protection`'s sibling, aimed at payments/ledger/regulated-finance13work instead of personal data — same posture: route the legal question to the right person, and own the14engineering consequences ourselves.1516**This is not legal, compliance or accounting advice.** Where a question has a regulatory answer —17whether a licence is needed, whether a customer needs enhanced due diligence, whether a specific flow18is in PCI DSS scope — the answer comes from compliance/legal, not from here.1920## When21As soon as a feature: touches card data in any form, moves money between two parties (a customer and22the company, two customers, a customer and a third party), maintains a balance or a ledger, or onboards23a user for a regulated financial service (an account, a wallet, a payout).2425## Steps2627### 1. Route the regulatory questions before writing code28Take these to compliance/legal rather than guessing — same posture as `business/data-protection` §2:29- **Does this feature put us in PCI DSS scope?** Any flow where card data (the PAN, the CVV, the30 expiry) passes through, is stored by, or is transmitted by our own systems is in scope. The31 practically universal fix is to **never let card data touch our servers at all**: collect it directly32 into the payment processor's own hosted field/SDK, get back a token, and store and reuse only that33 token. A flow that routes card data through our backend "just to log it" or "just to validate the34 format" just put that backend in scope — that's a decision, not an implementation detail, and it goes35 to whoever owns PCI compliance before it ships.36- **Does onboarding this kind of user or this kind of flow trigger KYC/AML obligations?** Screening37 against sanctions lists (OFAC, UN, EU, national lists) at onboarding, and re-screening on a risk38 change, is a compliance program's call on *who* gets screened and *how strictly* — not a threshold to39 invent in the code. What the code has to provide is a hook where that screening can run, and a state40 the account can sit in while it's pending.41- **Does this need a money-services/e-money licence, or does it fit under someone else's?** Moving42 money between third parties is regulated in most jurisdictions; "we're just a technical intermediary"43 is a legal characterisation, not a fact you get to assume.4445### 2. What the code has to provide: money handling461. **Money is never a float.** Represent an amount as an integer minor-unit count (cents) or an exact47 decimal type, never a binary float — this is `skills/design-patterns` §4.5's Value Object entry48 applied at its highest-stakes case; a rounding error here isn't cosmetic, it's a discrepancy in a49 number someone has to reconcile.502. **Every amount carries its currency**, and an operation across two amounts checks the currencies51 match before doing arithmetic on them — a silent add across currencies is a real, catchable bug52 class, not a hypothetical one.533. **Rounding is a policy, applied once, at a named point** (e.g. half-up at the smallest currency54 unit), not wherever a division happens to land in the code. Two different rounding results for the55 same computation are how a ledger stops balancing.5657### 3. What the code has to provide: the ledger581. **A ledger is append-only.** No `UPDATE`, no `DELETE` on a posted entry — correcting a mistake is a59 new, explicit reversing entry, never an edit to history. The moment history can be silently changed,60 nobody can tell a bug from a cover-up, and reconciliation stops being possible.612. **Every movement is (at least) two entries that net to zero** — a debit and a matching credit across62 two accounts, committed together or not at all. A balance is a *derived* read over the entries, never63 a separately-stored counter that can drift out of sync with what the entries actually say.643. **The atomic unit of a financial write is the whole set of entries for one transaction.** Partially65 applying a multi-entry movement (crediting one side, failing before debiting the other) is a66 correctness bug regardless of how rare the failure window looks in testing.6768### 4. What the code has to provide: payment operations691. **Every request that can be retried (network blip, timeout, a user double-clicking pay) carries an70 idempotency key**, and the receiving side stores the result keyed on it — a retry with the same key71 returns the original result instead of charging twice. This applies to outgoing calls to a payment72 processor and, separately, to incoming ones.732. **A webhook from a payment processor is verified before it's trusted** — its signature, against the74 raw request body, checked first, before any business logic runs on its payload.753. **A webhook is deduplicated by the event's own id**, not by re-deriving "have I seen this before"76 from business state: insert the event id into a processed-events table under a unique constraint77 before doing any work; a unique-violation means it's already been handled, so skip. The common miss78 is idempotency on the *outgoing* call only — the incoming webhook handler needs its own, separately.794. **A webhook handler re-fetches the authoritative state from the processor rather than trusting the80 payload alone** (design guidance: the processor's documentation allows using the event's own data or fetching the current object) for anything a business decision depends on, and only applies a state transition if81 it's actually valid from where the record currently stands (no silently re-applying "paid" to an82 already-refunded order).835. **Reconciliation is a designed-in job, not an afterthought**: something that periodically compares84 our ledger against the processor's own record of the same transactions and surfaces a mismatch —85 stuck-pending payments, a webhook that never arrived, a refund that didn't post — rather than relying86 on a customer to notice and complain first.87886. **Idempotency keys have limits worth knowing** (processor documentation read 2026-10-20). The processor89 saves the first response for a key, including an error, and returns it on retry; a retry with different90 parameters is rejected; keys can be pruned after at least 24 hours (stated for API v1), after which a reused key starts a new91 request; and a request that failed validation or collided with a concurrent one saves nothing, so it may92 be retried. Symptom: a "retry" that charges twice after a day, or that keeps returning a stale error.93 Fix: generate one key per intended operation, keep it for as long as retries can happen, and never derive94 it from personal data.957. **Webhook verification needs the untouched raw body.** The processor documentation says its signature96 check fails if a framework parses or alters the body first. Symptom: signature errors only in97 production, behind a body-parsing middleware. Fix: verify before any parsing, with the library the98 processor provides, and reject on failure.998. **Webhooks arrive more than once, late and out of order.** The documentation says the same event can be100 delivered several times (store handled event ids) and order101 is not guaranteed (do not infer sequence from the timestamp, which has one-second resolution). Fix:102 dedupe by event id, make every transition valid from the current state, and re-read the object from the103 API when order matters.1049. **Fulfil from the server-side event, not the browser return.** The payment-status documentation says105 customers may leave the page before fulfilment starts, so goods should be released on the106 payment-succeeded event, handled asynchronously; polling is described as less reliable. Asynchronous107 methods such as bank debits can stay in a processing state for days.10810. **Hosted fields cut scope; they do not remove the duty.** The processor's security guide says direct109 handling of raw card numbers can bring more than 300 requirements, that its low-risk integrations send110 card data straight to it without touching our servers, and that card type, last four digits and expiry111 it returns may be stored. The merchant still attests to PCI compliance yearly, and a third-party script112 on a payment page makes our security depend on that script's. The PCI council's own page says it113 develops the standards but does not enforce them: card brands and acquirers decide who must comply.114 Route the SAQ type to whoever owns PCI (the council's FAQ pages on scripts and hosted pages could not115 be read).11611. **Ledger storage engines make the same choices.** The TigerBeetle documentation (read 2026-10-20) keeps117 accounts and transfers immutable, corrects errors with new transfers, stores amounts as integers of a118 scaled smallest unit, derives balances from cumulative debits and credits, separates currencies or assets119 by a ledger id, makes transfer ids unique, and lets linked transfers succeed or fail together or use a120 two-phase pending, post or void flow. Own guidance: these are design checks for ours, not requirements.12112. **Sanctions screening: some facts to hand to compliance.** OFAC's FAQ page (read 2026-10-20) states that122 an entity owned 50 percent or more, directly or indirectly or in aggregate, by blocked persons is itself123 blocked even if not listed (verified 2026-10-21 on FAQ 398-399; re-read before relying). So a name-only match against a list is not the124 whole check. Who is screened and how strictly stays compliance's decision.125126## Output / checkpoint127No pipeline checkpoint (business layer, see `business/README.md`). What it owes: the PCI-scope and128KYC/AML questions routed to compliance with their answers when they come back, amounts represented129without floats and currency-checked, the ledger append-only with entries that net to zero per130transaction, idempotency on both the outgoing call and the incoming webhook, and a reconciliation131mechanism named rather than assumed.132133## Guardrails134- Never decide PCI DSS scope, licensing, or a KYC/AML threshold yourself — route it, the same way135 `business/data-protection` routes a lawful-basis question.136- Never let card data reach a server we control if a hosted-field/tokenisation alternative exists —137 that's the single biggest scope-reduction lever available, and skipping it is a decision someone138 senior should make knowingly, not a default.139- Never edit or delete a posted ledger entry. A correction is a new entry, always.140- Never represent money as a float, and never let an amount cross a currency boundary unchecked.141- Never add idempotency "later" — like `skills/background-jobs-conventions`, this is a design property,142 and retrofitting it means auditing every already-shipped call site for whether it was ever double-run.143- This block has no dedicated in-house fintech/compliance expertise behind it yet: a solid set of144 engineering defaults plus a routing checklist, not proven doctrine, to be confronted with a real145 regulated-payments engagement.146147## Origin148**Sourcing pass 2026-10-20 (status stays 🟡, nothing was run).** Read for facts, rewritten in our own words,149no text copied: a payment processor's documentation on idempotent requests, webhooks, payment status and150integration security; the PCI council's "about" page; the TigerBeetle data-model and transfer reference pages151(documentation of an Apache-2.0 project; its LICENSE file was not opened here, so facts only); the OFAC FAQ152topic page; one accounting-for-developers article from a ledger vendor (no licence read, facts only, nothing153reproduced). Confirmed: idempotency-key behaviour, signature on the raw body, dedupe by event id, ledger154immutability with correction by new entries, derived balances, integer amounts, atomic multi-entry posting,155tokenised or hosted collection as the scope lever. Corrected: the "re-fetch authoritative state" step is156advice for ordering, not a rule from the processor, and the processor documentation also allows using the157event payload as of the event time; the block's statement now reads as design guidance. Not read: the PCI158council standard itself and its FAQ entries (404 or no text), the FATF recommendations (403), any KYC159rule. The "no dedicated expertise" guardrail stays.160161Assembled from public sources, written without internal fintech/compliance expertise, the same honesty162posture as `business/data-protection`. PCI DSS scope and the tokenisation-as-scope-reduction mechanism:163published PCI compliance and tokenisation-vendor guidance. KYC/AML/sanctions-screening triggers164(onboarding screening, risk-driven re-screening, the OFAC/UN/EU list landscape): published AML/sanctions165compliance guides. Double-entry ledger invariants (append-only, no silent update/delete, balance as a166derived read, atomic multi-entry posting): published ledger-database design writing (Modern Treasury's167ledger engineering series, TigerBeetle's debit/credit documentation) aimed at engineers building168financial systems, not at accountants. Payment idempotency and webhook handling (idempotency keys on169outgoing calls, signature verification before trust, dedup by event id under a unique constraint,170re-fetching authoritative state rather than trusting the payload): published Stripe-style payment171integration practice, generalised beyond one named processor. The money-as-value-object point is not172new here — it cross-references `skills/design-patterns` §4.5, added 2026-08-11 from the real173the org catalogue's design-patterns plugin — this block is where its highest-stakes case gets spelled174out. Stamped 2026-08-11.175176Independent verification 2026-10-21: 22 checked, 19 matched, 1 corrected, 2 unverified