About Industries Solutions Case Studies Blog Contact Us
Home/ Blog/ FinTech
FinTech 16 min read · March 15, 2026

Building PCI-DSS Compliant Payment Systems: Architecture Decisions That Matter

CP
Chandra Prakash

Co-Founder & CTO, LegelpTech

Building PCI-DSS Compliant Payment Systems: Architecture Decisions That Matter

PCI-DSS compliance is not something you bolt on after building a payment system. It must be woven into the architecture from the first design session. Every year, businesses lose an average of $4.88 million per data breach (IBM, 2024), and payment card breaches carry some of the steepest regulatory penalties in the industry. This guide covers the critical architecture decisions that determine whether your payment system passes its first audit or requires months of costly remediation.

PCI-DSS (Payment Card Industry Data Security Standard) is a set of security standards established by the PCI Security Standards Council to protect cardholder data during and after financial transactions. Any organization that stores, processes, or transmits credit card information must comply with these standards or face fines, increased transaction fees, and potential loss of the ability to accept card payments.

Who This Guide Is For

  • CTOs and engineering leads designing or refactoring payment systems
  • FinTech founders building products that handle card transactions
  • DevOps and infrastructure engineers responsible for CDE environments
  • Compliance officers who need to understand technical controls
  • SaaS companies adding payment processing to existing platforms

Understanding PCI-DSS: The 12 Requirements

PCI-DSS v4.0 (effective March 2025) organizes security requirements into six goals and twelve requirements. Each requirement maps to specific technical controls you must implement in your architecture. Understanding these mappings is the first step toward building a compliant system rather than retrofitting one.

Req # Requirement Technical Control
1Install and maintain network security controlsFirewalls, WAF, network segmentation, micro-segmentation
2Apply secure configurations to all componentsCIS benchmarks, hardened OS images, config management (Ansible/Terraform)
3Protect stored account dataAES-256 encryption at rest, tokenization, data masking, key management via HSM/KMS
4Protect cardholder data with strong cryptography during transmissionTLS 1.2/1.3, certificate pinning, mutual TLS for internal services
5Protect all systems from malicious softwareEndpoint protection, container image scanning, runtime security (Falco, Aqua)
6Develop and maintain secure systems and softwareSAST/DAST in CI/CD, dependency scanning, secure code review, WAF rules
7Restrict access to system components by business needRBAC, least-privilege IAM policies, just-in-time access (HashiCorp Boundary)
8Identify users and authenticate accessMFA everywhere, SSO with SAML/OIDC, unique IDs, password vaults
9Restrict physical access to cardholder dataCloud provider SOC 2 attestation, physical security of on-prem HSMs
10Log and monitor all access to system componentsCentralized SIEM (Splunk, Elastic), immutable audit logs, real-time alerting
11Test security of systems and networks regularlyQuarterly ASV scans, annual penetration testing, vulnerability management
12Support information security with policies and programsSecurity policies, incident response plan, security awareness training

Architecture Patterns for Payment Processing

There are three foundational architecture patterns that every PCI-compliant payment system relies on: tokenization, encrypted vaults, and network segmentation. Getting these right determines the size of your compliance scope and the complexity of your annual audits.

Tokenization: The Foundation of Scope Reduction

Tokenization replaces sensitive card data (the Primary Account Number, or PAN) with a non-sensitive substitute called a token. The token has no exploitable value if breached. Your application logic, databases, analytics pipelines, and reporting systems all work exclusively with tokens instead of real card numbers.

Use a dedicated tokenization service such as HashiCorp Vault, AWS Payment Cryptography, or a purpose-built token vault. The service stores the bidirectional mapping between tokens and PANs in an isolated, encrypted database that sits inside the CDE (Cardholder Data Environment). Your application code outside the CDE should never see, handle, or log raw card data. This single decision reduces your CDE scope dramatically, often cutting the number of systems subject to audit by 70% or more.

Key takeaway: Tokenization is not just a security measure. It is a scope reduction strategy. Every system that never touches raw card data is a system you do not need to include in your PCI audit, saving thousands of dollars in assessment costs.

Encrypted Vaults and Key Management

When cardholder data must be stored (even temporarily), it must be encrypted with strong cryptography. Implement three layers of encryption:

  • Data in transit: TLS 1.3 for all external connections, mutual TLS (mTLS) for service-to-service communication within the CDE
  • Data at rest: AES-256-GCM with envelope encryption. The data encryption key (DEK) encrypts the data, and a key encryption key (KEK) encrypts the DEK
  • Application-level field encryption: PAN data is encrypted at the application layer before it reaches the database, providing defense-in-depth even if database-level encryption is bypassed

Manage encryption keys through AWS KMS, Google Cloud KMS, Azure Key Vault, or a dedicated HSM (Hardware Security Module). Never store encryption keys alongside encrypted data. Implement automatic key rotation on a 90-day cycle. Document your key management procedures thoroughly as auditors will scrutinize this area closely.

Network Segmentation: Isolating the CDE

Your Cardholder Data Environment must be isolated from the rest of your infrastructure. Implement microsegmentation so the token vault, payment processing service, and HSMs live in a dedicated VPC or subnet with strict ingress and egress rules. No developer workstation, monitoring tool, or non-payment service should have direct network access to the CDE.

Proper network segmentation alone eliminates 60% or more of PCI requirements from your broader infrastructure. Everything outside the CDE boundary is considered out of scope for PCI assessment, provided you can demonstrate effective segmentation controls.

Security Architecture: Network Zones and Data Flow

A well-designed PCI-compliant architecture uses layered network zones to control data flow and limit exposure. Here is how the zones are structured:

Zone 1: Public Zone (DMZ)

This is where your CDN, WAF (Web Application Firewall), and load balancers reside. No cardholder data is processed or stored here. The WAF inspects incoming traffic, blocks malicious requests, and forwards clean traffic to the application zone. Only HTTPS (port 443) is permitted inbound.

Zone 2: Application Zone

Your API gateway, authentication services, business logic, and non-payment microservices live here. This zone handles user sessions, order management, and all application logic that does not directly touch cardholder data. It communicates with the CDE zone only through well-defined APIs and only sends tokenized references.

Zone 3: CDE Zone (Cardholder Data Environment)

The most restricted zone. It contains only the payment microservice, tokenization vault, and HSM integration. Access is strictly controlled: only the API gateway can reach it, and only on specific ports and endpoints. All traffic is encrypted with mTLS. No direct internet access is permitted, and all outbound traffic to payment processors routes through a dedicated egress proxy with allowlisted destinations.

Zone 4: Management Zone

Logging, monitoring, SIEM, and administrative access tools live here. This zone collects audit logs from all other zones via one-way log shipping. Jump servers or bastion hosts for CDE administration are located here, with MFA and session recording enforced for every access.

Data Flow: End-to-End Payment Transaction

The typical data flow for a card payment follows this path: Customer browser loads hosted payment fields (iframe from Stripe/Adyen) and card data goes directly to the payment processor. The processor returns a token. Your frontend sends the token to your API gateway. The API gateway routes the token to the payment microservice in the CDE zone. The payment microservice calls the processor's charge API using the token. The processor returns a transaction result. Your application stores only the token and transaction metadata, never the raw card number.

Recommendation: Use Stripe or Adyen's hosted payment fields (iframes) for card data entry. This keeps raw card data from ever touching your servers, reducing your PCI scope from SAQ D to SAQ A, which cuts audit requirements by approximately 80%.

Self-Hosted vs. Payment Gateway vs. Hybrid: Choosing Your Approach

One of the most consequential architecture decisions is how much of the payment stack you own versus how much you delegate to a third-party provider. Each approach carries different compliance burdens, cost profiles, and levels of control.

Factor Self-Hosted Payment Gateway (Stripe, Adyen) Hybrid
PCI SAQ LevelSAQ D (most complex)SAQ A (simplest)SAQ A-EP or SAQ D
Audit Cost (Annual)$50,000 - $200,000+$5,000 - $20,000$20,000 - $80,000
Engineering Effort6-12 months build + ongoing2-4 weeks integration2-4 months build + ongoing
Data ControlFull controlLimited (provider holds data)Moderate
Transaction FeesLower (direct processor rates)Higher (2.9% + $0.30 typical)Moderate
Vendor Lock-in RiskNoneHighModerate
Best ForLarge enterprises, payment companiesStartups, SaaS, SMBsGrowing companies, marketplaces

For most companies, the payment gateway approach is the right starting point. You get PCI compliance at a fraction of the cost and complexity. As transaction volume grows past $10M annually, the economics may shift toward a hybrid approach where you own parts of the payment flow while still delegating card data handling to a compliant provider.

Warning: Self-hosting payment processing is almost never the right choice unless you are a payment company. The compliance burden of SAQ D includes 300+ requirements, mandatory quarterly ASV scans, annual penetration testing, and on-site assessments by a QSA. The cost and risk are justified only when payment processing is your core business.

Cost Breakdown by SAQ Level

Understanding the true cost of PCI compliance helps you make informed architecture decisions. Here is a realistic breakdown of annual compliance costs by SAQ (Self-Assessment Questionnaire) level:

SAQ Level Scope Requirements Estimated Annual Cost
SAQ AAll card data handled by third-party (hosted fields/redirect)~22 requirements$5,000 - $20,000
SAQ A-EPE-commerce with third-party processing but your website controls payment page~191 requirements$15,000 - $50,000
SAQ CPayment application connected to internet, no electronic cardholder data storage~160 requirements$10,000 - $40,000
SAQ D (Merchant)Full scope: you store, process, or transmit card data~300+ requirements$50,000 - $200,000+
SAQ D (Service Provider)Service providers handling card data on behalf of others~300+ requirements$100,000 - $500,000+

These costs include QSA or ISA assessment fees, ASV scanning, penetration testing, remediation engineering time, policy documentation, staff training, and tooling. They do not include the engineering cost of building and maintaining the compliant architecture itself, which can be two to five times the assessment cost in the first year.

Audit Logging and Monitoring

PCI-DSS Requirement 10 demands comprehensive audit trails. This is one of the areas where auditors spend the most time and where organizations most frequently fail. Your logging architecture must capture the following:

  • Every access to cardholder data (successful and failed)
  • Every authentication and authorization event
  • Every configuration change to systems in or touching the CDE
  • Every administrative action (user creation, privilege changes, policy modifications)
  • Every system event (startup, shutdown, error conditions)

Use immutable log storage with append-only semantics. Centralize logs in a SIEM platform (Splunk, Elastic Security, or Datadog Security Monitoring). Retain logs for a minimum of 12 months in an immediately accessible state, with archival storage for at least 3 years. Implement real-time alerting on suspicious patterns such as multiple failed authentication attempts, access from unusual geolocations, or bulk data export operations.

Common PCI Compliance Mistakes

After working on PCI-compliant systems across FinTech, e-commerce, and SaaS platforms, these are the mistakes we see most frequently. Each one either causes audit failures or creates security vulnerabilities that compliance was meant to prevent.

1. Logging Card Data in Application Logs

This is the most common and most dangerous mistake. Developers inadvertently log full request bodies that contain card numbers, or error handlers dump PAN data into stack traces. Implement PAN detection scanning in your log pipeline. Use tools like Amazon Macie or custom regex filters to alert on and redact any card data that appears in logs.

2. Flat Network Architecture

Running payment services in the same VPC or subnet as your general application infrastructure means your entire infrastructure is in PCI scope. Every server, every developer laptop that can reach the network, every monitoring tool becomes subject to PCI requirements. This mistake alone can increase compliance costs by five to ten times.

3. Shared Database for Payment and Application Data

Storing tokenized payment references alongside general application data in a single database instance puts that entire database server in scope. Use a dedicated, isolated database for payment data. Even if you only store tokens, co-locating them with non-payment data complicates your audit boundary.

4. Neglecting Key Rotation

Many teams implement encryption correctly at launch but fail to automate key rotation. PCI-DSS requires cryptographic key changes at least annually, and best practice is a 90-day rotation cycle. Use managed key services (AWS KMS, GCP Cloud KMS) that support automatic rotation, and test your rotation procedures regularly.

5. Treating Compliance as a Checkbox Exercise

The biggest mistake is architectural: treating PCI compliance as a documentation exercise rather than an engineering discipline. If your security controls exist only on paper and are not enforced by infrastructure-as-code, automated testing, and continuous monitoring, they will degrade over time and fail under scrutiny.

Warning: PCI-DSS v4.0 introduces "customized approach" validation, which means auditors can now evaluate whether your controls achieve the intended security outcome rather than just checking off a list. This makes superficial compliance even riskier than before.

Step-by-Step Implementation Guide

If you are building a PCI-compliant payment system from scratch or refactoring an existing system, follow this sequence. Each step builds on the previous one.

Step 1: Define Your CDE Boundary

Before writing any code, draw the boundary of your Cardholder Data Environment. Identify every system that will store, process, or transmit cardholder data. Identify every system that connects to those systems. Document network diagrams showing all data flows. This boundary determines your audit scope, and everything else in this guide is about making that boundary as small as possible.

Step 2: Choose Your Payment Architecture

Based on the comparison table above, decide whether to use a fully hosted gateway (SAQ A), a hybrid approach (SAQ A-EP), or self-host payment processing (SAQ D). For most organizations, start with SAQ A and graduate to more complex approaches only when business requirements demand it.

Step 3: Implement Network Segmentation

Create dedicated VPCs or subnets for CDE components. Configure security groups and NACLs with deny-by-default rules. Allow only the specific ports and protocols required for payment processing. Use Terraform or CloudFormation to define network rules as code so they are version-controlled and auditable.

Step 4: Build the Tokenization Layer

Deploy your tokenization service inside the CDE. Integrate hosted payment fields on your frontend so card data goes directly from the customer's browser to the payment processor. Configure your backend to receive only tokens. Validate that no raw card data appears in any request logs, application logs, or database tables outside the CDE.

Step 5: Configure Encryption and Key Management

Set up your KMS or HSM. Generate data encryption keys and key encryption keys. Enable TLS 1.3 on all endpoints. Configure mTLS between services within the CDE. Implement application-level encryption for any stored cardholder data. Set up automated key rotation. Document all key custodians and access procedures.

Step 6: Deploy Logging and Monitoring

Configure centralized logging with immutable storage. Set up your SIEM with alerting rules for security events. Implement PAN detection scanning across all log streams. Configure log retention policies (12 months online, 3 years archived). Test that all required events are being captured by reviewing logs against the PCI Requirement 10 checklist.

Step 7: Implement Access Controls

Enforce MFA for all access to CDE systems. Implement RBAC with least-privilege policies. Set up just-in-time access for administrative operations. Configure session timeouts (15 minutes of inactivity for CDE access). Deploy bastion hosts or VPN-only access for CDE administration. Record all administrative sessions.

Step 8: Integrate Security Testing into CI/CD

Add SAST (Static Application Security Testing) and DAST (Dynamic Application Security Testing) to your CI/CD pipeline. Scan container images for vulnerabilities. Run dependency checks against known CVEs. Gate deployments on security scan results. This ensures that compliance is maintained continuously rather than just at audit time.

Step 9: Conduct Pre-Assessment Validation

Before your formal QSA assessment, run an internal gap analysis against all applicable PCI-DSS requirements. Hire a QSA for a pre-assessment consultation. Fix any gaps identified. Run your first ASV (Approved Scanning Vendor) scan and remediate any findings. Conduct a penetration test and address vulnerabilities.

Step 10: Document and Maintain

Create and maintain the required policy documents: information security policy, incident response plan, change management procedures, and acceptable use policy. Set up quarterly reviews to ensure documentation reflects current architecture. Schedule recurring ASV scans, penetration tests, and access reviews.

Key takeaway: PCI compliance is not a project with an end date. It is an ongoing operational discipline. The architecture decisions you make at the start determine whether compliance is a sustainable part of your operations or a recurring crisis every audit cycle.

Architecture Blueprint: The Reference Implementation

The architecture we implement for PCI-DSS Level 1 clients at LegelpTech follows this proven pattern:

Customer Browser loads hosted payment fields (iframe) from Stripe or Adyen. Card data goes directly to the processor and never touches your servers. The processor returns a payment token.

Your Frontend sends the token along with the order details to your API Gateway.

API Gateway (in the Application Zone) handles authentication, rate limiting, and request validation. It routes payment requests to the Payment Microservice in the CDE.

Payment Microservice (in the CDE Zone) processes the payment using the token. It communicates with the Tokenization Vault for any stored token lookups and with the payment processor for charge/refund operations.

Tokenization Vault (in the CDE Zone) manages the secure storage and retrieval of token-to-PAN mappings, backed by HSM-managed encryption keys.

The CDE contains only the payment microservice, token vault, and HSM integration. Everything else, including user management, order management, reporting, and analytics, lives outside the CDE and works exclusively with tokens.

Frequently Asked Questions

How long does it take to achieve PCI-DSS compliance from scratch?

For a new system using hosted payment fields (SAQ A), you can achieve compliance in 4 to 8 weeks. For SAQ A-EP, plan for 3 to 6 months. For SAQ D with a full self-hosted payment system, expect 6 to 12 months of engineering and documentation work before your first successful assessment. These timelines assume a dedicated team and experienced guidance.

Can I use cloud services (AWS, GCP, Azure) for PCI-compliant systems?

Yes. All major cloud providers maintain their own PCI-DSS Level 1 certification and publish Attestations of Compliance (AOC). You inherit their physical security controls (Requirement 9) and parts of their infrastructure controls. However, you remain responsible for everything you build on top: application security, access controls, encryption configuration, logging, and network segmentation within your cloud environment.

What is the difference between PCI-DSS Level 1 and Level 4?

PCI-DSS merchant levels are based on annual transaction volume. Level 1 applies to merchants processing over 6 million transactions per year and requires an annual on-site assessment by a Qualified Security Assessor (QSA). Level 4 applies to merchants processing fewer than 20,000 e-commerce transactions and can self-assess using a SAQ. The security requirements are the same, but the validation method and rigor differ significantly.

Do I need PCI compliance if I use Stripe or PayPal?

Yes, but your scope is dramatically reduced. If you use hosted payment fields or redirect customers to Stripe or PayPal for card entry, you qualify for SAQ A, which has only about 22 requirements instead of 300+. You still need to complete and submit the SAQ, maintain secure configurations, and ensure your website itself is not compromised in ways that could intercept card data (such as JavaScript injection attacks).

How does PCI-DSS v4.0 differ from v3.2.1?

PCI-DSS v4.0, which became mandatory in March 2025, introduces several significant changes. It adds the "customized approach" as an alternative validation method, strengthens authentication requirements (MFA for all CDE access, not just remote), requires targeted risk analysis for each requirement, and adds new requirements around e-commerce security including client-side script management. Organizations should review the full v4.0 summary of changes published by the PCI SSC.

Recommendation: If you are building payment infrastructure or need to achieve PCI compliance, start with the smallest possible CDE scope. Use hosted payment fields, isolate your payment services behind network segmentation, and automate your compliance controls with infrastructure-as-code. The decisions you make in the first sprint of architecture design will determine your compliance costs for years to come.

CP
Chandra Prakash

Co-Founder & CTO, LegelpTech

Chandra leads LegelpTech's engineering organization and oversees the technical architecture of all client projects. With deep expertise in cloud infrastructure, API design, and automation systems, he brings hands-on technical leadership to every engagement.

Need Expert Help With Your Project?

Our team brings deep technical knowledge to every engagement. Let's discuss your requirements.

Talk to Our Team