Payments Authentication Explained: What API Keys, JWT and Encryption Actually Solve
When building a payment integration, you’ll encounter API keys & API users, JWT, or encryption. They are often explained in isolation, but in practice they solve different problems along the same payment flow.
This article focuses on what matters: when and why each is used.
1. Start with the real problems
Every payment setup needs to answer three questions:
Who is calling? → Is this request really coming from the merchant?
What are they allowed to do? → Can they refund, or only create payments?
Is the data safe? → Are card details protected from exposure?
No single method solves all three.
2. Backend → Payment Provider: establishing trust
Merchant Backend → Payment Provider (API Key)
An API key answers a simple question:
“Is this request coming from a trusted system?”
Used in server-to-server communication Stored securely on the backend Simple and reliable
Adding API/web services (WS) Users
Instead of one shared credential, you introduce structure:
System / Team → WS User (permissions) → API Key → API Call
This improves control and auditability.
3. The breaking point: the browser
Browser → Backend → Payment Provider
The browser is not trusted:
Users can modify requests Code can be inspected Secrets cannot be stored safely
This is why secret API keys cannot be used in the frontend (not to be confused with public keys, which can be used from the frontend (ie when creating Payment Intents with Stripe).
4. Protecting card data: encryption (JWE)
Browser → (encrypted card data) → Backend → Payment Provider
Card data is encrypted before leaving the browser Backend never sees raw card data Only the payment provider can decrypt it
Without encryption:
Backend handles card data Higher compliance burden
With encryption:
Reduced PCI scope Safer architecture
5. When identity needs to travel: JWT
Service A → (JWT) → Service B → Payment Provider
JWT solves:
“How can one system prove its identity to another?”
Passes identity between systems Carries permissions Works for platforms and partners
Typical use cases:
Third-party integrations Microservices
6. Putting it together
Browser
↓ (encrypted data)
Backend
↓ (API key + WS user)
Payment Provider
Optional:
Partner / Service
↓ (JWT)
Backend
7. Summary
API Key → identifies trusted backend WS User → structures permissions JWE → protects sensitive data JWT → shares identity across systems
Final thought
Payment integrations are not about choosing one method.
They are about applying the right mechanism at the right point:
Trust the backend Do not trust the browser Protect sensitive data early Pass identity where needed