Skip to content
EN
Book a demo

HomeGuides

How to Store Credit Card Data Securely and Keep It Portable

The first answer to how to store credit card data securely is to store as little as you can, and never on your own servers if a vault can hold it. Keep tokens that stand in for cards, and keep only the digits you need to show a customer which card they saved.

On this page

The second half of the question is about the future. Card data stored with one provider can be hard to take back, so a safe setup also needs a written way out. This guide covers both halves, in the order a team works through them.

01Before you start

Storing cards touches security, finance and product, so name an owner for each row before you begin.

What you need Who owns it Where it comes from
The reason you keep cards, such as one-click, recurring billing or refunds Product owner Your product plan
A map of every system that sees a card number today Security lead A review of your checkout, logs, support tools and backups
Your PCI DSS scope and the questionnaire or assessment you complete Compliance lead Your acquirer and your assessor
A list of the providers whose tokens you hold Payments engineer Your vault and your provider portals
The legal basis and retention rules for customer data Legal lead Your privacy policy and local law

The map in row two usually surprises people. Card numbers turn up in support tickets and log files that nobody meant to include.

02How to store credit card data securely: step by step

  1. 01 Decide whether you need to store cards at all

    Write the reason down, in one sentence, for each use. A repeat customer who wants one-click checkout needs a stored card. A refund usually doesn't need one, because it refers back to the original payment. Each use you drop is a risk you no longer carry.

    You see the result as a short list of uses that justify storage, each with an owner. Everything not on it stops being collected.

  2. 02 Keep card entry off your own servers

    The cleanest way to store card details is for your systems never to see them. Use a hosted payment page, embedded fields served by your provider or a mobile SDK that sends the card straight to the vault. The method you choose sets how much PCI DSS applies to you.

    Check what you see after this step. Capture a test payment and search your own database, logs and request traces for the test card number. It should appear nowhere.

  3. 03 Never keep the security code

    The PCI DSS rules don't allow storing the card verification code after authorization, even when the rest is encrypted. The PCI Security Standards Council answers this in its FAQ, and your assessor confirms how it applies to your setup.

    Check your forms, your logs and your debugging tools for the code. A support screen that lets an agent read the code back to a customer, because it was kept in a note or a ticket field somewhere, is a defect and not a convenience.

  4. 04 Store tokens and display data, not numbers

    A token is a stand-in value that is useless outside the system that issued it. Store the token, the card brand, the last four digits and the expiry month and year. That is enough to show a customer "Visa ending 4242" and to charge it again through the vault.

    If you must keep the card number itself, the standard requires it to be rendered unreadable, and your scope grows sharply. Most teams that think they need the number discover they need the token.

  5. 05 Know what kind of token you hold

    Tokens differ in who can use them. An acquirer token usually works only with that acquirer, and may need the merchant account data it was created under. A customer token may come with the card number and payer data. A network token is issued by the card network and needs fresh cryptograms for each payment.

    Write the type next to each token family in your records. This single column answers most of the questions that come up during a provider change, such as which tokens can move and which have to be re-collected.

  6. 06 Map tokens to your own customer records

    Keep your own reference for each stored card, so that your customer record doesn't depend on a provider's identifier. Store the link between your customer ID and the token in your database, with the provider and the token type beside it.

    When you change providers, you update one column and don't need to search your application code for a provider value that was hard-wired earlier.

  7. 07 Control who can see and use stored cards

    Limit access by role, in your own systems and in the vault. A support agent may need to see the last four digits. A developer rarely needs to charge a stored card in production. Log every access and every use of a stored card, and review the log on a schedule.

    Where your provider offers it, use separate credentials for reading, for charging and for administration. A single master key is convenient, yet it's hard to defend in an audit when something goes wrong.

  8. 08 Write the exit before you need it

    Ask your vault provider, in writing, how the card data comes back to you if you leave. You want to know the format, how it is protected in transit, how it is verified against the PCI DSS and how long it takes. Ask whether you may test the process on a sample.

    Do this when you sign, not when you want to leave. A provider's answer on day one tells you whether the vault is portable or tied to that provider.

03Testing before real traffic

Before you store a real customer's card, run these checks with test cards.

  • A test card entered on your checkout never appears in your own database, logs or traces.
  • A saved card shows brand, last four digits and expiry, and nothing more.
  • A stored token can be charged for a one-off payment and for a repeat payment.
  • A user without the right role can't see or use a stored card.
  • A deleted customer's tokens are deleted or deactivated in the vault, as your policy says.
  • A sample export or migration of test tokens completes, and the count matches.

Keep the results with the date, because your assessor may ask how you verified them.

04Rolling back, and what goes wrong

Card numbers appear in logs. This happens often and by accident, usually through request logging or an error tracker. Turn off body logging on payment routes, search your log stores for card-number patterns and purge what you find, then fix the source.

A token won't charge after a move. The token may belong to a merchant account that no longer exists, or it may be a network token that needs a fresh cryptogram. Keep the old route alive during the move, and send failures back through it while you investigate.

The provider is slow to hand back data. If the exit was never written down, the request becomes a negotiation at the worst time. Put the process, the format and the timing in the contract at the start.

A team stores cards "temporarily". Temporary tables survive for years. Put an expiry date on any exception, and review it with the security owner.

05Where the platform does these steps

Cards live in an encrypted vault on the platform's side, so your servers hold only tokens. Those tokens drive recurring billing, with several retries and a schedule you set.

Moving cards in goes by token type, with two ways to map old tokens to new ones, and migrated cards can keep their billing schedules.

The data is yours throughout. On request, it returns to you by PGP or another encrypted route, checked against PCI DSS, so a portable vault is one you can leave.

06FAQ

How to store credit card details securely in a database?

Don't store the number there. Keep a token, the brand, the last four digits and the expiry, and let a vault hold the card. If you store the number yourself, the PCI DSS requirements apply to that database and to everything near it.

How to securely store customer credit card information for recurring payments?

Use tokens held by a vault, and charge the token for each renewal. Keep your own customer reference beside each token, and keep the schedule in your billing system. Ask the vault how failed renewals are retried.

What is the difference between a token and a network token?

A provider token works with the provider that issued it. A network token is issued through the card network, so it can keep working when the underlying card changes, and each payment needs a fresh cryptogram. Both replace the card number in your systems.

Can I move stored cards to another provider?

Often, yes, but the answer depends on the token type and on the vault's terms. Acquirer tokens need merchant account data, and some providers send customer tokens in bulk with PGP keys. Ask for the procedure in writing before you rely on it.

Next step

Plan where your card data can go

If you hold tokens with several providers, send us the list by type and we'll go through which can move, which need re-collecting and how the data comes back. Send us your token list.

Book a demo

Map your integrations onto one API

We look at the providers you run today and what moving them behind one API would take.