For a developer, the useful first question is where payment data travels. A checkout can avoid storing a PAN in its main database yet still copy it into a proxy log, a failed-job payload or a support export. This guide maps those boundaries and supplies executable examples for two deliberately small outputs: receipt metadata and a payment-result event.
Draw the data flow before choosing a questionnaire
For a hosted collection design, record this path in your integration documentation:
- Buyer → provider-controlled input: record which origin serves the fields and which scripts can affect the surrounding page.
- Provider → application server: identify the reference and metadata actually returned; inspect error responses too.
- Server → database and jobs: list each retained field, retention purpose, reader and deletion path.
- Server/browser → monitoring and support: include access logs, request tracing, session replay and exports.
A redirect, embedded form and merchant-hosted card form are different designs. An iframe is not automatically SAQ A-EP. PCI SSC’s SAQ A script guidance describes embedded forms that can meet SAQ A criteria and requires the applicable protections. Confirm eligibility with the entity accepting your assessment and your provider’s implementation instructions; this table cannot assign it.
| Observation | Next evidence to collect |
|---|---|
| Your server receives the full PAN | Data-flow inventory, storage/transmission controls and assessment scope |
| Provider fields collect the card directly | Integration instructions, provider responsibilities and all eligibility conditions |
| Only references reach your database | Token properties, permissions, connectivity and systems affecting payment security |
| Payment details appear in logs | Collection source, downstream copies, retention and remediation evidence |
Correct the storage assumptions
Security codes: merchants must not retain them after authorization, including encrypted copies. A request to remember the card does not change that rule. See PCI SSC’s card-on-file explanation.
PAN display versus storage: displaying only a suffix does not prove the stored value is unreadable. PCI SSC treats masking and storage protection separately, and its eight-digit BIN guidance explains why a universal first-six/last-four rule is misleading. The PAN structure guide demonstrates that boundary with synthetic data.
Hashing: an ordinary salted digest is not the keyed hash now required for a PAN hashing process used to render data unreadable. PCI SSC’s keyed-hashing FAQ explains the 31 March 2025 effective date and treatment of previously hashed data. Do not infer compliance from a column named pan_hash.
Other fields: a name, expiry or last-four value does not have the same classification as full PAN or sensitive authentication data. Context, combination with PAN, privacy obligations and actual business need still matter. Do not retain fields simply because a response happens to contain them.
Build the receipt record from an allowlist
This example assumes a trusted provider response has already been translated into local brand and last4 fields. It stores only those two values. It does not accept a full PAN and attempt to disguise it:
export function receiptMetadata(input, profile) {
if (!input || typeof input.brand !== 'string' ||
!Object.hasOwn(profile.networks, input.brand) ||
typeof input.last4 !== 'string' || input.last4.length !== 4 ||
/[^0-9]/.test(input.last4)) {
throw new TypeError('Expected provider-supplied brand and four ASCII digits');
}
// This teaching schema intentionally omits PAN, expiry, tokens and CVV.
return { brand: input.brand, last4: input.last4 };
}The tests inject extra PAN, CVV and nested payment fields and assert the exact output object. They also reject numeric, overlong and malformed suffixes. The same project tests a typed event schema that omits raw requests and error bodies.
| Case | Input / condition | Expected result |
|---|---|---|
| receipt-allowlist | Provider metadata with extra PAN/CVV fields | {"brand":"visa","last4":"1111"} |
| receipt-leading-zero | Four digits remain a string | {"brand":"amex","last4":"0005"} |
| event-allowlist | Request and error objects are omitted | {"event":"payment_result","network":"visa","outcome":"accepted"} |
These checks establish the behavior of two functions. Extend the assertions to the actual objects passed to your database, logger, queue and export code. Framework middleware can capture a request before either function runs, so inspect those paths too.
Keep ordinary QA separate from live card data
Use synthetic fixtures for isolated local tests and provider-issued fixtures for a provider sandbox. Do not copy live PAN into an ordinary development database. PCI DSS 4.0.1 requirement 6.5.5 permits a pre-production environment handling live PAN only within the CDE and with all applicable protections; “test” is not a scope exemption. Refer to the current standard in the PCI SSC document library for assessment and applicability details.
For this project, use the number generator or bulk fixture workflow with no outbound payment calls. Use the provider test-card reference when testing an actual sandbox. The Stripe testing guide covers that provider-specific boundary. Generated values are not evidence that a real identifier is unassigned.
Execute and keep the evidence scoped
Download the receipt and logging test project , extract all files, and use Node.js 22 or later:
node --test guide-examples.test.mjs
node guide-demo.mjs pci
Keep the test result with the reviewed schema and the application changes that use it. A passing suite is evidence for those transformations, not a PCI assessment. Revisit the data-flow inventory whenever a new SDK, analytics service, export or error handler touches checkout.
The linked PCI SSC FAQ guidance were last checked against provider documentation on . Providers do change what they publish — the official link beside each claim is authoritative.