QA Interview Hub · Knowledge base · Quizzes · Українська

QA Fundamentals › Fintech specifics

What states does a payment have and what do you test in them?

A payment moves through Created, Pending, Authorized, Captured and Settled, while the branches Declined, Voided and Refunded end it differently. Authorized only holds the amount, Captured charges it. A timeout is not a decline: the state stays Pending until the outcome is established by reference or webhook. Tests cover allowed and forbidden transitions, the balance at each step, duplicate and out-of-order webhooks, and the cap on partial refunds.

QA Fundamentals · Fintech specifics

The provider did not answer within 30 seconds. Did the payment go through or not?

A user presses "Pay", the screen spins, the provider is silent. The system decides the payment failed and offers to try again. The user presses it, but the first request had reached the bank and the money was already held. Now the bank has two charges while the system has one failed payment. This lesson is about which states a payment goes through, why there are several and what to test in each, so that such gaps do not appear.

How it works and why. A card payment is not one action but a chain between several parties: our system, the payment provider, the card network and the card's issuing bank. Every step is separate, asynchronous and can end differently, which is why a payment has states. A typical path:

  • Created: the payment is created in our system, nothing has been sent.
  • Pending: the request went to the provider, no answer yet.
  • Authorized: the bank confirmed the money is there and held the amount on the card. This is not a charge yet.
  • Captured: we confirmed the charge, the held amount becomes a spend.
  • Settled: the money really reached the recipient, usually later, in a batch.

Branches: Declined (a refusal by the bank or provider), Voided (cancelling an authorization before the charge), Refunded (a return after the charge, full or partial). Names differ between providers while the principle stays: every state says what has already happened to the money and what has not. The split into authorization and capture exists because otherwise you cannot back out of an order when the goods are out of stock: a hold can be released without a charge.

Payment states and the main transitions

CreatedPendingAuthorizedCapturedDeclinedVoidedSettledRefundedDeclined: the bank or provider refused.Voided: cancelled before the charge.Refunded: a return, full or partial.
Figure 1. The main path on top, branches downwards. There is no way back from Settled to Captured: a refund is a separate payment in the opposite direction.

The user's balance also changes step by step. An example for a balance of 1,000 and a payment of 100 (simplified, real banks show it differently):

StateAvailableHeldWhat the user sees
Created, Pending1,0000"Processing"
Authorized900100The amount is reserved
Captured9000Charged 100
Voided or Declined1,0000The money is back in place
Refunded1,0000Returned

There are two invariants to check at every step: available plus held plus charged keep the total unchanged, and after a cancellation or refusal the held amount really gets released. A typical bug caught this way: after Declined part of the amount stays held.

Example: a timeout and an unknown result. The most dangerous state is not Declined but the one where there is no answer. The initial version treats a timeout as a refusal. The right one treats it as unknown and finds out the fact:

POST /payments {"reference":"ord-1042","amount":10000,"currency":"UAH"}
  → timeout 30 s, no response

Before: the system sets Failed, the user presses "Pay" again
        → a new payment ord-1042-2, two charges of 100.00 at the bank
After:  state Pending (the result is unknown), no repeated charge
        GET /payments?reference=ord-1042 → {"status":"authorized"}
        → Authorized, then the usual path to Captured

What is checked here. A timeout does not set Failed but leaves Pending. A repeated attempt by the user does not create a second payment with the same intent (idempotency, more in the lesson about idempotency). The status is found by a request to the provider by reference, or by a webhook, and the state moves by fact. For QA this is a separate case: emulate a slow response or a dropped connection (in the provider mock, with throttling or a delay), then check the state, the balance and the number of payments.

The second kind of checks is forbidden transitions and the order of events. Provider webhooks can arrive twice, late and out of order: "captured" before "authorized". The system must reject a move backwards (the state does not roll back) and not charge a second time. A minimal set of negative cases: Declined → Captured, Voided → Captured, Captured → Authorized, a repeated webhook of the same state, a refund larger than the charge, a refund of a payment that is still Authorized. For partial refunds, the sum of all refunds does not exceed the charge: 30 + 80 from a payment of 100 gives a refusal for the second.

Limits and alternatives. Real providers add states: waiting for 3-D Secure (the user has not confirmed yet), Expired (the authorization was not captured in time and lapsed after a period set by the issuer and the provider), Disputed (a chargeback, when the cardholder disputes the charge). These are separate flows with their own rules, which stay in the provider's documentation, so the first QA step on a new project is to draw the state diagram from the docs and compare it with the code. Payment states can be tested as state transition testing (a transition table) or end to end, but forbidden transitions are checked only at the API or service level, because the interface simply does not offer them. Some systems keep several status fields (payment status, settlement status, refund status), and then their combinations are tested, not one field.

Common mistakes.

  • Testing only "successful" and "declined": most bugs live in timeouts, repeats and event order.
  • Checking the status in the UI and not looking at the balance: the UI says "Paid" while the hold has not been released.
  • Assuming a payment always leaves Pending on its own and not checking what happens if the result never comes: a payment needs a lifetime and a way to a final state.
  • Checking transitions only through the interface: invalid calls are possible only in the API, which is where to try them.
  • Not checking notifications: the user receives "Payment confirmed" before the actual Captured, or nothing after Declined.

Check yourself

The provider sent a "captured" webhook twice for one payment, and the database has two charge records. What is wrong and how do you check it with a test?

Answer

Webhook handling is not idempotent: the event should be keyed by event or payment id and a repeat ignored. The test: send the same webhook twice and check that there is one charge, the balance changed once and there is one notification.

A payment of 100 is Authorized. The user cancels the order, and then a request to refund 100 appears. Which state is right for the cancellation and why not Refund?

Answer

The right one is Void (cancelling the authorization): the money has not been charged, so releasing the hold is enough. Refund applies to money already charged and is a separate movement back, sometimes with a fee or a delay. The test checks that after Void the available balance returned and that Refund for such a payment is rejected.

In an interview. Junior: A payment goes through states from creation via authorization and capture to settlement, with branches for decline, cancellation and refund. I check that all allowed transitions work and the forbidden ones are rejected, that the balance is right at every stage and that the user gets correct messages. Middle/Senior: I give the most attention to uncertainty: a timeout does not mean a refusal, so the state must stay Pending until the fact is established by reference or a webhook. Webhooks can repeat and arrive out of order, so I check idempotent handling and the ban on rolling a state back. Partial refunds must not exceed the charge. I also reconcile the payment with the provider, because our state can drift from the bank's.

More articles in this chapter