Fintech & Payments
Accepting Card Payments Safely: PCI DSS Basics for Small Development Teams
Handling card data yourself is a compliance minefield. Learn how hosted checkout and tokenisation keep you out of most of it, and what Kenyan businesses should check.
By Philip Mutuku · Published · Updated · 5 min read
The simplest way to be secure with card numbers is never to see them. Yet many small teams still build their own card form, post the details to their own server, and unknowingly walk into a heavy compliance burden and a catastrophic liability if that server is breached.
What PCI DSS is
The Payment Card Industry Data Security Standard (PCI DSS) is a set of security requirements maintained by the PCI Security Standards Council for any organisation that stores, processes or transmits cardholder data.[1] It is a contractual requirement from the card brands and your acquirer, not a law, but non-compliance can mean fines, higher fees, or losing the ability to take cards.
The key insight for developers: the more card data touches your systems, the larger your compliance scope. Reduce the scope, and you reduce the work, the risk and the cost.
Three ways to integrate, and what each means
| Model | How it works | Card data touches your server? | Compliance burden |
|---|---|---|---|
| Redirect / hosted payment page | Customer is sent to the provider’s page to pay, then returned | No | Lowest |
| Embedded hosted fields / iframe | Provider’s secure fields render inside your page; you get a token | No (typed directly into provider’s fields) | Low |
| Direct API (your own form posts card numbers to your server) | You collect and forward card data | Yes | Highest: full assessment and strict controls |
How tokenisation keeps you out of scope
- The customer types card details into the provider’s field, which runs in the provider’s secure context.
- The provider returns a token, a random reference that is useless outside your account.
- Your server sends the token plus the amount to the provider to create the charge.
- The provider tells you the result by webhook, and you update the order.
// Server: we only ever receive a token, never a card number.
router.post('/checkout', authenticateToken, async (req, res) => {
const { orderId, paymentToken } = req.body;
const order = await orders.findOwned(orderId, req.user.id); // check ownership
if (!order || order.status !== 'unpaid') return res.status(409).json({ message: 'Invalid order' });
// Amount comes from OUR database, never from the client.
const charge = await provider.charges.create(
{ amount: order.amountMinor, currency: order.currency, source: paymentToken },
{ idempotencyKey: 'order-' + order.id } // safe to retry
);
await orders.update(order.id, { status: 'pending', chargeId: charge.id });
res.json({ status: 'pending' }); // final state arrives via webhook
});
Rules for developers
- Never log, store or email card numbers or security codes. Check your logs and error trackers: request bodies are a classic accidental leak.
- Never trust the amount sent by the browser. Compute prices on the server.
- Verify webhooks. Check the provider’s signature and de-duplicate events; the redirect back to your site proves nothing.
- Make charges idempotent so a retry cannot double-charge a customer.[4]
- Serve everything over HTTPS and keep your own dependencies patched.
- Keep payment keys secret, with separate test and live keys, and rotate them if exposed.
Which self-assessment applies to you?
Merchants complete a Self-Assessment Questionnaire (SAQ) matching how they handle card data. The more of the process you hand to a certified provider, the shorter and simpler yours is. Exact eligibility rules come from the PCI Security Standards Council and your acquiring bank, so confirm with them, but the general pattern is consistent.
| How you take cards | Typical SAQ | Effort |
|---|---|---|
| Redirect or hosted payment page | SAQ A | Lowest |
| Provider-hosted fields embedded in your page | SAQ A or A-EP depending on setup | Low to moderate |
| Your servers receive card data | SAQ D | Highest |
Mistakes that put you back in scope
- Logging card numbers. Request logs, error trackers and analytics can accidentally capture card fields. Review what you send to third parties.
- Handling “just for support”. Customers emailing card numbers or sending screenshots creates stored card data. Give support a policy and a secure alternative.
- Storing the CVV. It must never be stored after authorisation, even encrypted.
- Third-party scripts on payment pages. Any script on the page can potentially read the form. Keep these to the minimum and review them regularly.
- Ignoring your provider’s responsibilities. Compliance is shared. Read what the provider covers and what remains yours.
A simple compliance routine
- Map exactly where card data could enter, flow or be stored in your business.
- Choose an integration that keeps card data off your servers.
- Keep systems patched and restrict access to payment-related settings.
- Use strong authentication on provider dashboards and enable alerts.
- Complete the correct SAQ each year and submit it as your bank requires.
- Write a short incident plan: who to call, and how to contact the provider and bank.
Testing payments without touching real cards
Use the sandbox and test card numbers your provider supplies, and never test with real customer cards. Cover the unhappy paths as well as the successful one: declined cards, insufficient funds, expired cards, 3-D Secure challenges, network timeouts and duplicate submissions. Confirm that your system records the final state correctly and tells the customer clearly what happened.
Use webhooks to learn the true payment outcome instead of trusting the browser redirect, which a user can close or tamper with. Verify the webhook signature, make processing idempotent, and reconcile your records against the provider’s reports regularly, so finance and engineering agree on what was paid.
Frequently asked questions
Does M-Pesa fall under PCI DSS?
M-Pesa is a mobile money service, not a card scheme, so PCI DSS applies to card data you handle, not to M-Pesa transactions. You still need strong security and data protection for the payment information you hold.
Is HTTPS enough to be compliant?
No. HTTPS protects data in transit, but the standard also covers access control, logging, vulnerability management and more. Using a hosted payment page is the simplest way to reduce what you must prove.
Kenya-specific checks
Working with a licensed payment provider means they carry much of the regulatory load. If your business model involves holding or moving customers’ money, for example marketplaces, wallets or pooled collections, regulation of payment service providers under Kenya’s National Payment System framework may apply to you, and the Central Bank of Kenya oversees it.[3] Take legal advice before launching anything that resembles a wallet or a settlement service.
- Choose a provider that supports the methods your customers use: M-Pesa, cards, and bank transfers.
- Ask for their PCI compliance evidence and for clear documentation on settlement times and dispute handling.
- Plan reconciliation from day one: match provider statements to your orders daily.
- Decide your refund and chargeback process before the first dispute arrives.
Payments are a place to be conservative. Reduce your scope, lean on specialists for the sensitive parts, and spend your engineering effort on the experience around the payment instead.
References & further reading
- PCI Security Standards Council, “PCI DSS”: standards, documents and Self-Assessment Questionnaires. https://www.pcisecuritystandards.org/standards/pci-dss/
- PCI Security Standards Council, “Getting Started with PCI Data Security Standard”. https://www.pcisecuritystandards.org/document_library/
- Central Bank of Kenya, National Payment System: legislation and oversight of payment service providers. https://www.centralbank.go.ke/national-payments-system/
- Stripe, “Idempotent requests” (safe retries for payment operations). https://docs.stripe.com/api/idempotent_requests