Skip to content
Tutorials Center
My learning

Topics

Lesson 33 of 38 ยท Compliance and Patterns

PCI DSS and Staying Out of Scope

Understand what PCI DSS requires, how Stripe Checkout, Elements and tokenization keep card data off your servers, which self-assessment questionnaire applies, and common mistakes that widen scope.

Anyone who stores, processes or transmits card data must follow PCI DSS, the Payment Card Industry Data Security Standard. It is a contract requirement set by the card brands, not a law, but ignoring it can mean fines and losing the ability to accept cards. The good news: with a modern Stripe integration you can keep card numbers away from your servers entirely, which shrinks your obligations dramatically.

This lesson is general education, not legal or compliance advice. Check Stripe's PCI documentation and talk to a qualified assessor for your situation.

The key idea: card data never touches you

The primary account number (PAN), expiry and CVC are the sensitive data. If they never pass through your servers, your servers are largely out of PCI scope. Stripe achieves this with tokenization: the card form is served from Stripe's domain, and your code only receives an opaque reference.

flowchart LR
  B["Browser"] -->|"card number"| S["Stripe (iframe)"]
  S -->|"token or PaymentMethod id"| B
  B -->|"pm_..., no card data"| M["Your server"]
  M -->|"charge using id"| S

Card data goes browser to Stripe. Your server sees only ids.

Integration styles compared

Integration Where card data is typed Typical SAQ
Stripe Checkout (hosted page) On a Stripe page SAQ A
Payment Element or Card Element (Stripe.js iframes) In Stripe-hosted iframes inside your page SAQ A (often A-EP in older setups)
Your own HTML inputs posted to your server On your page and your server SAQ D, the heaviest
Raw card numbers sent to Stripe's API from your server Your server handles them SAQ D, and Stripe may block it

An SAQ (Self-Assessment Questionnaire) is the form you complete annually to attest compliance. SAQ A is the shortest: it applies when all card handling is outsourced. Stripe provides help completing it through the Dashboard. Requirements keep evolving (PCI DSS v4 added rules about scripts on payment pages), so read the current guidance.

What you still must do

Out of scope for card data does not mean out of responsibility:

  • Serve every page over HTTPS (TLS) and use HSTS.
  • Keep your site free from malicious scripts: a hijacked page could replace the payment form. Limit third-party scripts and use a Content Security Policy.
  • Protect API keys: secret keys on the server only, restricted keys, rotation after leaks.
  • Use strong passwords and MFA for staff Dashboard access; limit who can refund or view customers.
  • Keep your software and dependencies updated.

Never log or store card data

The most common mistake is accidental capture: logging request bodies, saving form posts in analytics, or screenshots in support tickets. This scanner flags card-like numbers before they reach a log.

Node.js Redact card numbers from logs

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

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Notice that the order number is untouched, because it fails the Luhn check. A real data-loss-prevention tool does much more, but the principle is to fail safe.

Safe things to store

Node.js What may a payments table hold?

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

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Storing brand, last4 and the expiry (for display) is fine. The CVC must never be stored after authorization, even encrypted, according to the standard. Saved cards live in Stripe as PaymentMethods attached to a Customer; you keep only the id.

When in doubt, send the data to Stripe and keep only the identifier. The less you hold, the less you must protect and the less an attacker can steal.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How does Stripe Checkout reduce your PCI scope?

    Because the card form is hosted by Stripe, your systems do not process the sensitive data.
  2. 2. Which SAQ is the lightest and applies when card handling is fully outsourced?

    SAQ A is the shortest questionnaire for fully outsourced card entry.
  3. 3. Which value may you store after authorization?

    Last4 and brand are safe for display. The CVC must never be stored after authorization.
  4. 4. Which is still your responsibility even with Checkout?

    Scope shrinks, but website security, key protection and access control remain yours.

Summary

  • PCI DSS applies to anyone handling card data; tokenization keeps data off your servers.
  • Checkout and Stripe-hosted Elements typically qualify for the lightest questionnaire, SAQ A.
  • Use HTTPS, guard scripts and secret keys, and control staff access.
  • Never log or store PANs or CVCs; keep Stripe ids, brand and last4.

Next: Strong Customer Authentication and 3D Secure