That answers the question many developers type, which is how to store credit card information in database form. You don't. You store a reference and let a specialist system hold the card.
Before you start
Storing cards touches security, billing and your provider contracts, so settle a few things first.
- The reason you need stored cards, such as one-click checkout or subscriptions
- Where card numbers enter your system today, including support tools and logs
- The providers that will use the stored card
- Who in your team may see anything related to a card
- Your acquirer's view on what you may store
If the reason is a single repeat purchase, a token at one provider may be enough. If you route across providers, read on.
Step by step: how to store credit card data securely
1. Decide whether you need to store the card at all
Store a card only when a later charge needs it, as in subscriptions, installments or a customer's saved payment method. A one-off purchase doesn't need a stored card, and every stored card is a risk you carry.
Write down the exact later charge each stored card serves. A card without a purpose gets deleted.
2. Keep the number off your own servers
Capture the card where your provider or vault controls the field, such as a hosted page or an embedded field, so the number goes straight to them. Check that the provider receives the card number directly, then store the token it returns and only the display details you need. This is also how to reduce PCI scope using payment tokens, since fewer of your systems touch card data.
Check your logs and error reports too. Card numbers have a habit of appearing in places nobody planned.
3. Never store the security code
PCI SSC FAQ 1533 says merchants must never retain sensitive authentication data after authorization, even when encrypted. That covers the card verification code and the PIN. Later charges on a stored card don't need the code.
If your form or database has a field for it that survives past the first payment, remove it.
4. Store a token, and choose which kind
How to tokenize payments is a short answer: replace the card number with a token that has no use outside your setup.
A token from one PSP may be limited to that PSP, though the provider may be able to export card data for a migration. A vault of your own can support several routes. For migrated network tokens, confirm support with the token requestor and check which providers can use them.
Pick the token type by asking where the next charge will go, and ask the same of every provider you might add next year. If the answer is "any provider on my routes", ask whether a PSP-issued token can leave that PSP before you rely on it.
5. Show only what a person needs
When a customer or an agent must recognize a card, display the last four digits and the brand. PCI SSC FAQ 1146 separates masking of displayed card numbers from truncation of stored ones, so apply the PCI DSS masking rules to every screen and printout, and your acquirer may ask for less.
Limit who can open a card record. Roles that permit one action per user are better than a shared admin login.
6. Set the retry schedule for stored cards
A stored card on a subscription fails sometimes for reasons that pass, such as a temporary decline. Decide how many times to retry, how far apart, and when to stop and ask the customer to update the card.
Keep the schedule flexible by plan or customer group, since a monthly plan and an annual one fail differently. Log each retry with its reason, so support can tell a customer why a charge was tried three times.
7. Plan how the cards leave
Write the exit before the entry. Who owns the card data, in what format it can be handed back, and how fast. If your vault is tied to one provider, the exit may mean asking every customer to re-enter a card.
An encrypted hand-back on request, such as a PGP-encrypted file, is a sensible thing to require in the contract.
What breaks and how to catch it
Problems with stored cards show up months after the setup, usually as failed renewals. The table lists the early signs.
| Problem | Symptom | Fix |
|---|---|---|
| Card numbers in logs or tickets | A log review finds what looks like a full card number | Mask at the source and purge old records |
| Token tied to one PSP | Renewals fail after a provider switch | Use a vault token or migrate with the provider's help |
| Security code kept | A stored card verification code remains after authorization | Purge retained codes and prevent storage after authorization |
| Retries too aggressive | Many declines on one card in a day | Space attempts and stop after the limit |
| No exit route | Moving providers needs customers to re-enter cards | Require encrypted hand-back in the contract |
| Too many users with card access | Support staff can open full records | Reduce roles to the actions each person needs |
Check logs and storage for the patterns in the first three rows during integration testing, then set a review schedule based on your PCI DSS obligations and your risk assessment.
Where the platform does these steps
Our card vault stores card data in an end-to-end encrypted system and gives you tokens for recurring billing with multiple retries and a flexible schedule. Cards from another platform can be migrated in by token type, and card data stays yours and is handed back by PGP or another encrypted method when you ask. Details of the vault are on the card vault page.