Skip to content
Tutorials Center
My learning

Topics

Lesson 18 of 40 ยท Payments

PCI DSS Scope and 3-D Secure

Keep card data out of your systems. Learn PCI DSS scope, tokenization, hosted fields, SAQ types, SCA under PSD2, the 3-D Secure flow and liability shift.

Two ideas shape how modern shops handle cards. The first is PCI DSS, the security standard for anyone who stores, processes or transmits card data. The second is 3-D Secure, the extra check that proves the person paying really owns the card. One protects the card data; the other protects against its misuse.

This lesson is a conceptual guide for developers. It does not replace your provider's documentation or a qualified security assessor, and details change as standards are updated, so always confirm the current requirements for your own case. It continues from How Online Payments Work and Authorization, Capture, Refunds and Chargebacks.

What PCI DSS is

The Payment Card Industry Data Security Standard is a set of security requirements created by the major card brands. It is a contractual obligation rather than a law: your acquirer or PSP agreement requires you to comply, and non-compliance can mean fines, higher fees or losing the ability to accept cards after a breach.

The standard covers things such as network security, protecting stored data, encryption in transit, access control, monitoring, vulnerability management and security policies. The amount of work depends on one question: how much of your system touches card data? That is your scope.

The sensitive data falls into two groups:

  • Cardholder data: the card number (PAN), cardholder name, expiry date and service code.
  • Sensitive authentication data: the CVC/CVV, full magnetic-stripe data and PINs. This may never be stored after authorization, even if encrypted.

The golden rule: do not touch card data

Every server, database, log file, backup and employee laptop that sees raw card numbers is in scope. The cheapest way to comply is to design so that raw card data never reaches your systems. Practical consequences:

  • Do not log request bodies at checkout without redaction. Logs are a classic accidental store of card numbers.
  • Do not email card numbers, put them in support tickets or paste them in chat.
  • Do not store the CVC, ever.
  • Do not keep a "card number" text field anywhere in your database.

Tokenization and hosted fields

Tokenization replaces a card number with a random string, a token, that is meaningless to anyone who steals it. The PSP keeps the real card in its secure vault. You keep the token and use it to create payments.

Hosted fields (or embedded components) make this practical on your own page. The payment inputs are rendered inside iframes served by the provider, so keystrokes go straight to the provider. Your JavaScript never sees the number; it only receives a token or a payment-method id.

sequenceDiagram
    participant B as Shopper browser
    participant F as Provider iframe (card fields)
    participant S as Your server
    participant P as PSP vault
    B->>F: Types card number
    F->>P: Sends card data directly
    P-->>F: Token (pm_123)
    F-->>B: Token only
    B->>S: Pay with token pm_123, order 1001
    S->>P: Create payment using token
    P-->>S: Result

The card number travels only between the shopper and the PSP. Your server handles a token.

Tokens are also what make saved cards and one-click reordering possible: you store the token (or a customer id and payment-method id) and the PSP charges the card on request. A token is usually valid only with your merchant account, so a stolen token is not a stolen card.

The stand-in below shows the idea with a tiny in-memory vault. The vault is the PSP; the shop only ever holds the token. It is a teaching model and nothing like real card security:

JS Tokenization stand-in

Press Run (or Ctrl + Enter) to see the console output here.

No output.

SAQ types and levels, conceptually

Merchants prove compliance with a Self-Assessment Questionnaire (SAQ); larger merchants may need an on-site assessment instead. The questionnaire you fill out depends on how you accept payments:

How you take cards Typical SAQ idea Effort
Fully hosted payment page or redirect to the PSP The smallest questionnaire Lowest
Embedded fields served by the PSP in iframes Slightly larger, because your page could be tampered with to alter the form Low to moderate
Your own form that posts card data to your server or directly to the PSP with your scripts Large questionnaire High
Card data stored or processed on your own systems Largest scope, with network scans and extensive controls Very high

Merchant levels (commonly 1 to 4) are based on annual transaction volume per card brand. The higher the volume, the more formal the validation. Exact thresholds and requirements differ per brand and version of the standard, so ask your acquirer or PSP which level and SAQ apply to you.

Even with a hosted approach, you still own your page. Recent versions of the standard pay attention to scripts on payment pages: you should know every script that runs there, justify it, and protect it with tools such as Content Security Policy and subresource integrity. This is one more reason to keep third-party widgets off the payment step (Checkout Flow and Conversion).

SCA, PSD2 and 3-D Secure

In the European Economic Area and the UK, regulations require Strong Customer Authentication (SCA) for most online card payments. SCA means the payer proves their identity using at least two of three kinds of evidence:

  • Knowledge: something they know (a password or PIN),
  • Possession: something they have (a phone or a hardware token),
  • Inherence: something they are (a fingerprint or face scan).

The card industry's technology for this is 3-D Secure (3DS), now in version 2 (commonly called 3DS2 or EMV 3DS). It lets the issuer authenticate the shopper during the payment.

The 3DS flow

  1. Your payment request, via the PSP, includes rich data about the shopper and the order (email, billing address, device information, amount) so the issuer can assess risk.
  2. The issuer's access control server decides:
    • Frictionless flow: the data looks low-risk, so the issuer approves authentication silently and the shopper sees nothing.
    • Challenge flow: the issuer needs proof, so the shopper is asked to approve in their banking app, enter a one-time code or use biometrics.
  3. The result (authenticated, attempted, failed, unavailable) travels back with a cryptographic proof.
  4. The authorization continues, carrying that proof, and the issuer decides whether to approve the payment.

Your integration normally just calls the PSP's confirm method, which opens the challenge in a modal or an iframe when required, and returns the final status. You must handle the additional-action-required state: the order cannot be marked paid until authentication succeeds, and the shopper might abandon the challenge (The Order Lifecycle).

flowchart TD
    A["Payment request with order and device data"] --> B{"Issuer risk check"}
    B -- "Low risk" --> C["Frictionless: authenticated silently"]
    B -- "Needs proof" --> D["Challenge: app approval or code"]
    D -- "Passed" --> E["Authenticated"]
    D -- "Failed or abandoned" --> F["Payment fails, retry offered"]
    C --> G["Authorization with proof"]
    E --> G

3-D Secure 2 either approves silently or challenges the shopper. Only an authenticated payment goes on to authorization with proof attached.

Liability shift

A major benefit of 3DS is the liability shift. If a payment was authenticated with 3DS and the real cardholder later says, "That was fraud," the liability for that fraud dispute generally moves from the merchant to the issuer. Disputes for other reasons (the item never arrived, for example) are not covered. Rules differ by network, card type and outcome (a fully authenticated payment is treated differently from an "attempted" one), so confirm the current terms with your provider.

3DS is therefore both a legal requirement (under SCA) and a fraud-protection tool. Its cost is friction: challenges can lower conversion, which is why exemptions exist.

Exemptions

SCA allows certain payments to skip a challenge:

  • Low-value payments under a small threshold, subject to cumulative limits.
  • Low-risk transactions where the acquirer or issuer's fraud rate is below defined thresholds (transaction risk analysis).
  • Trusted beneficiaries, where the shopper has whitelisted the merchant with their bank.
  • Recurring payments of a fixed amount after the first authenticated one.
  • Merchant-initiated transactions, such as charging a subscription renewal under an earlier agreement.
  • Corporate cards in secure payment processes.

Two cautions. First, you request an exemption but the issuer decides, and it can still demand a challenge, so your code must support challenges in every case. Second, an exempted payment may not get the liability shift. Your PSP often decides when to ask for an exemption automatically.

The stand-in below mimics a decision a PSP might make. It is a teaching sketch with invented thresholds, not the real rules:

JS A simplified SCA decision

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Remember that an exemption lowers friction but can also give up the liability shift, so the real trade-off is conversion against fraud risk.

A practical checklist

  • Use hosted fields or a hosted page. Never build your own raw card form.
  • Serve the whole site over HTTPS and send a strict Content Security Policy on payment pages.
  • Redact logs, error reports and analytics payloads; search for card-number patterns in your logs and fix any hit.
  • Keep third-party scripts off the payment step and inventory the ones that remain.
  • Store tokens, not numbers, and never store the CVC.
  • Support 3DS challenges and the additional-action state in your order flow.
  • Complete the SAQ your provider assigns, and renew it on schedule.
  • Keep payment code and credentials separate: API keys in environment secrets, restricted keys where available (Securing an Online Shop).

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which data may never be stored after authorization, even encrypted?

    Sensitive authentication data such as the CVC must not be kept once the payment is authorized. Last four digits, brand and tokens are safe to store.
  2. 2. How do hosted fields reduce your PCI scope?

    The inputs live in the provider's iframes, so your systems only handle tokens.
  3. 3. In 3-D Secure 2, what is a frictionless flow?

    When the risk data looks safe, the issuer approves authentication without showing the shopper a challenge.
  4. 4. What does the liability shift usually mean after a successful 3DS authentication?

    For fraud-coded disputes, responsibility generally moves to the issuer. Disputes about delivery or product quality are still the merchant's problem.
  5. 5. Your code requests an SCA exemption. What must it still be ready to handle?

    Exemptions are requests. The issuer may override them and ask the shopper to authenticate.

Summary

  • PCI DSS is a contractual standard; your scope is whatever touches card data, so avoid touching it.
  • Use tokenization and hosted fields; store tokens and never the CVC.
  • The SAQ you fill out depends on your integration style; hosted approaches need the least.
  • SCA requires two-factor proof for most European card payments, delivered through 3-D Secure.
  • 3DS2 is frictionless or challenged; authenticated payments typically shift fraud liability to the issuer.
  • Exemptions reduce friction, may reduce protection and must always be backed by challenge support.

Next, learn how the PSP tells you what happened: Webhooks and Signature Verification.