EMV transaction flow — Mermaid sources

Colours match the DOCX diagrams. Each classDef block is self-contained, so any diagram below can be copied on its own.


Stage 1 — Session setup

flowchart TD
    A["Card activation<br>ATR and PPS, or field detect"]
    B["Application selection<br>PPSE / PSE, candidate list, AID"]
    C["Get processing options<br>PDOL in; AIP and AFL out"]
    D["Read record loop<br>CDOL1, CDOL2, CVM list, certificates"]

    A --> B --> C --> D

    classDef purple fill:#EEEDFE,stroke:#534AB7,color:#3C3489
    class A,B,C,D purple

Stage 2 — Offline processing and terminal action analysis

Each of the first four steps only writes bits into the TVR. Terminal action analysis is the single decision point, and it produces a request.

flowchart TD
    ODA["Offline data authentication<br>CDA or DDA; sets TVR bits"]
    PR["Processing restrictions<br>AUC, version, dates → TVR"]
    CVM["Cardholder verification<br>CVM list loop → CVM results"]
    TRM["Terminal risk management<br>Floor limit, velocity → TVR"]
    TAA["Terminal action analysis<br>TVR against TAC and IAC"]

    RTC["Request TC<br>No action code match"]
    RARQC["Request ARQC<br>Online match"]
    RAAC["Request AAC<br>Denial match"]

    ODA --> PR --> CVM --> TRM --> TAA
    TAA --> RTC
    TAA --> RARQC
    TAA --> RAAC

    classDef purple fill:#EEEDFE,stroke:#534AB7,color:#3C3489
    classDef amber  fill:#FAEEDA,stroke:#BA7517,color:#633806
    classDef gray   fill:#F1EFE8,stroke:#5F5E5A,color:#444441
    class ODA,PR,CVM,TRM purple
    class TAA amber
    class RTC,RARQC,RAAC gray

Stage 3 — First GENERATE AC

The card may only downgrade the requested cryptogram, never raise it.

flowchart TD
    GEN1["First generate AC<br>CDOL1: amount, TVR, unpredictable number"]
    CRM["Card risk management<br>Card may only downgrade, never raise"]

    TC["TC returned<br>Approve offline"]
    ARQC["ARQC returned<br>Go online"]
    AAC["AAC returned<br>Decline"]

    GEN1 --> CRM
    CRM --> TC
    CRM --> ARQC
    CRM --> AAC

    classDef blue   fill:#E6F1FB,stroke:#185FA5,color:#0C447C
    classDef purple fill:#EEEDFE,stroke:#534AB7,color:#3C3489
    classDef green  fill:#EAF3DE,stroke:#639922,color:#27500A
    classDef amber  fill:#FAEEDA,stroke:#BA7517,color:#633806
    classDef red    fill:#FCEBEB,stroke:#A32D2D,color:#791F1F
    class GEN1 blue
    class CRM purple
    class TC green
    class ARQC amber
    class AAC red

Stage 4 — Online authorisation and second GENERATE AC

Only the ARQC branch reaches this stage. Note the unable-to-go-online path, which bypasses issuer scripting but still settles via the second GENERATE AC.

flowchart TD
    ONLINE["Online authorisation<br>ARQC and IAD sent in field 55"]
    ISSUER["Issuer processing<br>Checks ARQC, returns ARPC"]
    OFFLINE["Unable to go online<br>Default action codes apply"]
    S71["Issuer scripts, template 71<br>Run before the second generate AC"]
    GEN2["Second generate AC<br>CDOL2 plus issuer authentication data"]
    S72["Issuer scripts, template 72<br>Run after the second generate AC"]

    TC2["TC returned<br>Approved"]
    AAC2["AAC returned<br>Declined"]

    ONLINE --> ISSUER
    ONLINE --> OFFLINE
    ISSUER --> S71 --> GEN2
    OFFLINE --> GEN2
    GEN2 --> TC2
    GEN2 --> AAC2
    TC2 --> S72
    AAC2 --> S72

    classDef amber  fill:#FAEEDA,stroke:#BA7517,color:#633806
    classDef blue   fill:#E6F1FB,stroke:#185FA5,color:#0C447C
    classDef purple fill:#EEEDFE,stroke:#534AB7,color:#3C3489
    classDef green  fill:#EAF3DE,stroke:#639922,color:#27500A
    classDef red    fill:#FCEBEB,stroke:#A32D2D,color:#791F1F
    classDef gray   fill:#F1EFE8,stroke:#5F5E5A,color:#444441
    class ONLINE amber
    class ISSUER,GEN2 blue
    class OFFLINE gray
    class S71,S72 purple
    class TC2 green
    class AAC2 red

Combined flow

All four stages in one diagram, as a direct replacement for the original.

flowchart TD
    subgraph SETUP["Session setup"]
        direction TB
        ACT["Card activation<br>ATR and PPS, or field detect"]
        SEL["Application selection<br>PPSE / PSE, candidate list, AID"]
        GPO["Get processing options<br>PDOL in; AIP and AFL out"]
        RR["Read record loop<br>CDOL1, CDOL2, CVM list, certificates"]
        ACT --> SEL --> GPO --> RR
    end

    subgraph OFF["Offline processing"]
        direction TB
        ODA["Offline data authentication<br>CDA or DDA; sets TVR bits"]
        PR["Processing restrictions<br>AUC, version, dates → TVR"]
        CVM["Cardholder verification<br>CVM list loop → CVM results"]
        TRM["Terminal risk management<br>Floor limit, velocity → TVR"]
        TAA["Terminal action analysis<br>TVR against TAC and IAC"]
        ODA --> PR --> CVM --> TRM --> TAA
    end

    subgraph CARD["Card decision"]
        direction TB
        GEN1["First generate AC<br>CDOL1 data"]
        CRM["Card risk management<br>Card may only downgrade"]
        GEN1 --> CRM
    end

    subgraph ONL["Online and completion"]
        direction TB
        ONLINE["Online authorisation<br>ARQC and IAD in field 55"]
        ISSUER["Issuer processing<br>Checks ARQC, returns ARPC"]
        NOGO["Unable to go online<br>Default action codes apply"]
        S71["Issuer scripts, template 71"]
        GEN2["Second generate AC<br>CDOL2 plus issuer auth data"]
        ONLINE --> ISSUER --> S71 --> GEN2
        ONLINE --> NOGO --> GEN2
    end

    APPROVE["Approved<br>Final TC"]
    DECLINE["Declined<br>Final AAC"]

    RR --> ODA
    TAA -->|"Request TC, ARQC or AAC"| GEN1
    CRM -->|TC| APPROVE
    CRM -->|AAC| DECLINE
    CRM -->|ARQC| ONLINE
    GEN2 -->|TC| APPROVE
    GEN2 -->|AAC| DECLINE

    classDef purple fill:#EEEDFE,stroke:#534AB7,color:#3C3489
    classDef amber  fill:#FAEEDA,stroke:#BA7517,color:#633806
    classDef blue   fill:#E6F1FB,stroke:#185FA5,color:#0C447C
    classDef green  fill:#EAF3DE,stroke:#639922,color:#27500A
    classDef red    fill:#FCEBEB,stroke:#A32D2D,color:#791F1F
    classDef gray   fill:#F1EFE8,stroke:#5F5E5A,color:#444441
    class ACT,SEL,GPO,RR,ODA,PR,CVM,TRM,S71 purple
    class TAA,ONLINE amber
    class GEN1,GEN2,ISSUER blue
    class CRM purple
    class NOGO gray
    class APPROVE green
    class DECLINE red