Payment API security is often overlooked because payment failures are commonly associated with card networks or payment gateways. In reality, many vulnerabilities occur before a request ever reaches the card network, particularly in the APIs used by applications to create orders, confirm payments, and issue refunds.
That is why having a practical payment API security checklist is more effective than relying on a loosely defined instruction to “be careful.” To explain the risks, let's consider a fictional online shop, KiranaKart, and a fictional payment gateway, NimbusPay. Neither represents an actual company. This is a practical illustration of where payment API security can fail and which controls can help prevent those failures.
The fictional flow
The customer taps on the ‘Pay’ button in the KiranaKart app. App calls KiranaKart's backend. Creating an order in the backend invokes API calls to NimbusPay. The customer pays. NimbusPay returns a webhook and backend marks the order as paid.
Four hand-offs. One each is a location where anyone may lie, replay, guess or flood. The following checklist shows the order in which a request moves.

1. API keys are like money
Treat API keys as money. The most common error is the least interesting: a secret key being placed at a location where it shouldn't be. Gateway documentation is straight to the point. For instance, on the best practice page, Razorpay advises developers not to give out their API key secret to anyone or on any public platform.
For KiranaKart, it means a couple of rules:
The secret key is saved only on the backend, NOT in the mobile app, NOT in the web bundle or NOT in a public repository.
Keys are not hard-coded, but taken from a secret manager or environment variables.
Make separate test and live keys and provide a key for each service, so as not to compromise everything with the loss of one key.
Rotate on schedule and at any developer's leave.
All commits should be scanned for any strings that resemble keys.
If your app contains a secret key, you are safe to assume that somebody has already read it. Unpacking mobile apps can take mere minutes.
2. Authorization: authenticated is not allowed would be an error message.
You can log into a website to verify your identity. It does not mean that the order that you are inquiring about is yours.
Now suppose the endpoint of the service at KiranaKart is GET /orders/1042. When the signed in customer changes the number to 1043, he/she sees another receipt. This pattern is known as Broken Object Level Authorization, and is at the top of the OWASP API Security Top 10 (2023 edition). At number two is Broken Authentication.
The remedy is easy to say and hard to remember.
Always verify that the user who is signed in is the owner of the object and not only that the token is valid.
Inspect a procedure for sensitive functions. Only the web application owner can reach POST /refunds, this should never be reached by a normal customer.
Never trust an amount, currency or user ID that comes from the client. Look the price up on the server.
Make sure that webhooks are verified before marking anything as paid. Someone can send a message to a public URL that claims the payment was successful. Anyone is able to send a fake "payment successful" message to a public URL.
3. Rate limits: prevent flood and slow-burn abuse.
Uptime is not the only thing about rate limits. They prevent attackers from guessing order IDs, attempting stolen card numbers as you checkout or pounding a coupon endpoint.
Two of the API categories of interest in 2023 are Unrestricted Resource Consumption (API4) and Unrestricted Access to Sensitive Business Flows (API6), both of which are in OWASP's 2023 list. The other one which everyone ignores is the second one. It includes legitimate-looking activity carried out on a level beyond what the business planned, for example, thousands of small transactions to test cards.
Ideal gateways, also restrict you. For instance, Stripe's documentation specifies that there are default limits on number of requests per second per account, returning a 429 status if you exceed, and advises exponential backoff. Your own API should be the same to your own users.
Kiranakart imposes restrictions per user, per device, per IP and stricter restrictions on the sensitive flows - payment creation, refunds, redemption and password reset. Customer pays once or twice every minute. 50 attempts per minute is not a customer.
Consider one related control that protects your customers but not you: Idempotency keys when creating payments. If the gateway times out, it detects the repeat and does not double bill. Look at your provider's docs as scope and retention varies.
4. Logging: Record what you need at 2 am.
It was included in its own section in the OWASP API list in 2019, and incorporated into other sections in 2023. Don't interpret that as "logging ceased to be an issue". Can't research what's not recorded.
Write these down for each call for payment:
Timestamp, user ID, device/ip, endpoint and result
The object touched (order ID, refund ID)
Authorisation failures, signature-check failures
Changes to keys, roles and webhook settings
However, do not log these:
All card numbers, CVVs, secret keys or full tokens
Log to a location outside of the applications ability to modify, and save the logs for the length of time they are required for audit and dispute. Inquire from your compliance lead what that period is.
What RBI says and what it means for you!
For those who do business in India, RBI is a part of this discussion. The Master Direction on Digital Payment Security Controls issued on 18 February 2021 lays down minimum security standard requirements for banks, SFBs, payment banks and issuers of credit cards through NBFCs. It includes governance, application security life cycle, authentication, fraud risk management and reconciliation and more. It also requires that each digital payment product specify its entire life cycle, validations leading up to settlement, and what happens with exceptions.
The non-bank payment system operators' are regulated by a separate set of Master Directions on Cyber Resilience and Digital Payment Security Controls issued in 2024.
The regulated entities, not all of the merchants, are bound by those documents. However, if you sell via a bank or a payment operator, you can anticipate that their duties will be communicated to you via contracts and on-boarding measures. This article isn't legal advice and is only intended to confirm what applies to you with your gateway orlegal adviser.
At Thread Security, we find it useful to read these directions as a checklist of questions: Who can call this? How do we know? What do we record? Who gets told? That's the same checklist you'll find in a good threat model.
A payment API security checklist to follow this week
Secret keys are server-side only, in a secrets manager, rotated on a schedule.
For access control to any object, as well as login, you will see that ownership is checked.
The amounts and prices are configured on the server.
Webhook signatures are checked prior to changes in the state.
A rate limit is available per user, device, and IP address and is even more restrictive on sensitive flows.
Idempotency keys are used on payment creation.
Logs contain no secrets or data on the cards, they contain who, what, when and result.
There are 6 alerts, each of which has an owner for the following signals
An up-to-date inventory lists every API version and endpoint, including old ones. Forgotten endpoints are a category all on their own (API9) in the OWASP list.
Someone tests it. At least once per year, (and after major releases) run a review of the OWASP API Security Top 10.
The skills that are part of the checklist
This does not involve any magic. It needs folks who can read an API spec, think like an attacker for an hour, and then write the tedious control that prevents them. To develop that skill set, you
need training that goes past theory, and incorporates hands-on experience with API testing. For cyber security courses in Jalandhar, or online, have you ever tried attacking a deliberately vulnerable API, and then fixing it? That is a learning exercise that no slide deck can teach as much.
The one takeaway
A payment API is as secure as the least secure of its implicit assumptions: that the key is safe,
that the end user owns the order, that traffic is normal, that somebody is watching. Change each assumption to a control and test the control to see if it still works.
If you do, then payment API security is not an issue anymore, but a regular routine.
Looking to develop and secure payment APIs in practice? Explore Thread Security's
programs.
Explore cyber security courses in Jalandhar: https://www.threadsecurity.in/courses
Visit Thread Security: https://www.threadsecurity.in
Akshay Kumar
VERIFIEDAcademic Coordinator · Thread Security
Faculty mentor & research guide at Thread Security Education.



