Domain tracks · L2The payment lifecycle

The payment lifecycle

What really happens after the customer taps "Pay", and the states your code must track until the money is in your bank.

L2 SeniorDomain tracks19 min read
Fact-checked by AI against cited sources · Human review pendingLast reviewed 21 Oct 2026 · How we check content
Section 1 of 8

What broke

A made-up story to show a common failure. Not about a real company.

This is a made-up example, but each rule in it comes from processor docs.

Meera's team runs an online furniture shop in India. To avoid refunds for items that are out of stock, the shop takes card payments in two steps. At checkout it only places a hold on the card. When a sofa ships, a job captures the money.

In one busy month, some sofas shipped late, 9 or 10 days after checkout. The capture job logged "error" for those orders, and nobody read the log. The sofas went out anyway.

Their processor's rule was simple. For many online card payments, a hold lasts about 7 days. If you do not capture before it expires, the funds are released and the payment becomes canceled. 3 The shop gave away the sofas for free.

Nobody saw it for weeks. The order table said "paid" because the hold had worked. The team found it only at month end. The money in the bank was lower than the sum of "paid" orders, and finance asked why.

Three bugs, one root cause. The team treated a payment as one event, "paid". It is really a series of states over many days, and each state can fail.

Section 2 of 8

The idea in simple words

A card payment has several parties.

  • Customer: the person who pays with a card.
  • Merchant: your business.
  • Payment processor or gateway: a company such as Stripe or Adyen that your code talks to.
  • Acquiring bank: processes card payments for merchants. It sends the authorization request to the customer's bank through the card networks. 2
  • Card network: the network of a card brand, such as Visa or Mastercard. 1
  • Issuing bank: the bank that gave the customer the card. 1

The payment then moves through states. Your code must track each one.

  1. Authorization: the issuing bank checks that funds are there and holds the amount. 1
  2. Capture: the money moves from the issuing bank toward you. 1
  3. Settlement: the customer's bank transfers the funds to the processor. Adyen marks a payment Settled at this point. 5
  4. Payout: the processor sends money from your available balance to your bank account. 6

The key idea. "Paid" is not one moment. A payment is a state machine that runs for days. Store each state, learn about changes from verified webhooks, and check the final money against the processor's report.

Section 3 of 8

How it works

Step through one ₹1,000 card payment.

One card payment: authorize, capture, settle, pay out, with a webhook at each step Your shop Processor Banks authorizeto issuerhold ₹1,000webhookauthorized captureorder shipswebhooksucceeded settledays laterwebhookavailable payoutto your bankwebhookpayout paid✓ match it to the report SeniorPath
  1. The customer pays ₹1,000. Your shop asks the processor to authorize. The issuing bank checks the card and holds ₹1,000. Later a webhook tells your shop the money is held, not yet taken.
  2. The order ships, so your shop captures the payment. Capture must happen before the hold expires. A webhook says the payment succeeded. Your shop still has no money in its bank.
  3. Days later the banks settle. The money reaches the processor, and your balance becomes available. On Stripe, a balance.available event can tell you this. How many days depends on the country and the processor.
  4. The processor sends a payout to your bank account. A webhook says the payout is expected to arrive, and it can still fail later. Your team matches each payout to the processor's report.
Step 1 of 4

Authorize, then capture

You can capture right away. You can also authorize and capture in two steps, with the capture later. Hotels, for example, often authorize the full amount before a guest arrives and capture at checkout. 3

With Stripe, you set capture_method=manual. After authorization, the payment's status becomes requires_capture. 3 You can capture less than you held, and Stripe releases the rest automatically. 3

The hold does not last forever. Stripe says an online card authorization is usually valid for 7 days. For Visa payments that you start without the customer, the table says 5 days, and the exact window is 4 days and 18 hours. 3 Other payment methods have their own windows. 3 If the hold expires before capture, the funds are released and the payment is canceled. 3 On Stripe, the charge's capture_before field shows when the hold expires. 3 Build an alert for holds that are about to expire.

If you no longer want the money, cancel before capture. At Stripe, canceling costs nothing, while a refund after success might cost a fee. 7

3-D Secure

Sometimes the issuing bank wants proof that the real cardholder is paying. With 3-D Secure (3DS), the bank may ask for a password, a one-time code sent to the phone, or a biometric check. 10 Rules in the EEA, the UK, India, Japan and Australia may require it for card payments. 10 On Stripe, the payment waits in the requires_action status until the customer finishes this step. 4

Settlement takes days

Capture is not cash. The money still has to travel between banks. Stripe gives settlement timing per country as "T+X" days. "T" is when the payment was confirmed or captured. 6

Stripe's table has an "initial settlement timing" column, which applies to your first payout. There it lists 2 business days for the United States. For India, it lists 2 business days for domestic charges and 5 for international ones. 6 Later payouts follow a default timing, which can differ. 6 Your processor and contract may differ too, so read your own terms.

Then a payout sends the money to your bank. Stripe's payout.paid event means the payout is expected to arrive. If it then fails, a payout.failed event comes later. 12

Refunds and chargebacks

A refund is started by you. At Stripe, you can refund part or all of a payment, but never more than the original charge. 7 It is not instant. Stripe says the customer sees the credit about 5 to 10 business days later, depending on the bank. 7 A refund can also fail, for example on a closed bank account. 7

A chargeback, also called a dispute, is started by the cardholder with their issuer. The network reverses the payment at once. Stripe then takes the amount and a dispute fee from your balance. 8 On Stripe, you usually have 7 to 21 days to respond, depending on the card network. If you miss the deadline, you lose. 9 If you counter the dispute, the cardholder's bank decides the outcome. Stripe says this can take up to 3 months. 9

So money you counted can leave your account weeks after a "successful" sale. Your ledger needs entries for refunds, disputes and fees, not only sales.

Webhooks: verify, then dedupe

Many results arrive later, for example when a bank confirms a payment or a customer disputes a charge. The processor tells you with a webhook. 11 Treat each one with care.

  • Verify the signature. Without it, an attacker could send a fake "payment succeeded" event and get free goods. 11 Stripe signs each event with HMAC-SHA256 in the Stripe-Signature header. Verify it on the raw request body. 11
  • Reject old events. The signed timestamp stops replay attacks. Stripe's libraries allow 5 minutes by default. 11
  • Dedupe. The same event can arrive more than once. Save the event IDs you have processed and skip repeats. 11 This is the same idea as in Idempotency, retries and timeouts.
  • Do not trust order. Events can arrive out of order. If one is missing, fetch the object from the API. 11
  • Answer fast. Return 2xx before slow work, and process from a queue. Stripe retries failed deliveries for up to three days in live mode. 11

Reconcile with the settlement report

Webhooks can be late or lost, and your code has bugs. So once a day, compare your records with the processor's. For automatic payouts, Stripe's payout reconciliation report lists every payment, refund, dispute and fee inside each payout. 13 Match each line to your ledger and explain every difference. Meera's team would have seen the missing money in the first daily check.

PCI DSS scope

PCI DSS is the security standard for anyone who stores, processes or transmits card data. 15 If your servers handle raw card numbers, you may face more than 300 security controls. 14

Most teams avoid that. They use hosted fields or a hosted checkout page, so the card number goes straight from the browser to the processor. It never passes through your servers. 14 You may still store the card brand, the last four digits and the expiry date. 14 Your scope shrinks, but you still must attest to PCI compliance every year. 14

Section 4 of 8

Trade-offs

OptionCustomer seesRiskUse it when
Capture at onceOne charge.Refunds for items you cannot deliver. Refunds can cost fees. 7Digital goods and in-stock items that ship the same day.
Authorize now, capture laterA hold, then a charge. Some statements do not show the difference. 3The hold expires before capture, and the payment is canceled. 3Stock checks, hotels, rentals, or a final amount that may drop.
Trust webhooks onlyNothing.Missed or late events leave orders in the wrong state.Never alone.
Webhooks plus daily reconciliationNothing.More work for your team.Always, for real money.
Your own card formYour design.Raw card data on your servers, and a much larger PCI scope. 14Rarely. Only with a strong reason and a security team.
Hosted fields or checkoutThe processor's fields in your page.Less control over the look.The default for most teams.

Simple rule: store every payment state, verify and dedupe every webhook, and reconcile every payout.

Section 5 of 8

At work: how a senior uses this

  • Draw the payment state machine for your product, with every state and every exit, before you write code.
  • Ask: "What happens if this webhook never arrives? If it arrives twice? If it arrives before the one before it?"
  • Store the processor's payment ID and status next to your order. Never mark an order "paid" from the browser's redirect alone.
  • Alert on holds close to expiry, captures that fail, refunds that fail and new disputes.
  • Run reconciliation daily, and give someone the job of explaining each difference.
  • Keep card numbers out of your systems, including logs and support tools. Use the processor's hosted fields.
Section 6 of 8

With AI

What to ask the agent

"Draw the state machine of a payment in our code: every status, every event that changes it, and every place we write it. Mark any state with no exit."

"Review our webhook handler. Does it verify the signature on the raw body, reject old timestamps, dedupe by event ID and return 2xx before slow work? Show the line for each."

"Write a daily job that matches each payout line in the processor's report to our ledger. List rows found on only one side."

What to check yourself

  • The handler uses the processor's official library to verify signatures. AI agents sometimes parse the JSON first, which breaks the raw-body check.
  • The dedupe check and the business update happen in one database transaction.
  • No settlement days, hold windows or fees are hard-coded from memory. They must match your processor's docs and contract.
  • Amounts are integers in minor units, as in Money and double-entry ledgers.
  • Test cards and test webhooks run in CI for capture failure, refund failure and a dispute.
  • No card number or CVC appears in logs, prompts or test data.
Section 7 of 8

Check yourself

1. Your shop authorizes a card payment at checkout and captures it when the item ships. What does authorization do?

Show answer

It holds the amount on the customer's card, so you can capture it later. The bank checks for funds and holds the amount. The money moves only when you capture, and reaches your bank later, as a payout.

2. An item ships 10 days after a Visa online checkout, where the customer paid themselves. You authorized at checkout. What is the risk?

Show answer

The hold may have expired, so the capture fails and the payment is canceled. For a Visa online payment that the customer starts, Stripe lists a 7-day hold. After that the funds are released and the payment becomes canceled.

3. Your webhook handler gets the same payment_intent.succeeded event twice. What should it do?

Show answer

Save processed event IDs and skip an event it has already handled. Stripe says endpoints may receive the same event more than once, and recommends logging processed event IDs.

4. Why do many shops use hosted payment fields, like Stripe Elements, instead of their own card form?

Show answer

Card data goes straight to the processor, so it does not pass through the shop's servers. This reduces PCI DSS work. Stripe says handling raw card data can mean more than 300 PCI DSS controls. Low-risk integrations send card data straight to Stripe.

5. What is the difference between a refund and a chargeback?

Show answer

You start a refund. A chargeback starts when the cardholder disputes the payment with their card issuer. A dispute starts with the cardholder and their issuer. At Stripe, the payment amount and a dispute fee leave your balance before the bank decides who is right.

Your progress is saved only in this browser. Export it to keep it safe.

Was this clear?
Report a mistake (opens GitHub in a new tab)
Section 8 of 8

Go deeper

Show 15 sources and related lessons
  1. Stripe documentation, How cards work (opens in a new tab)
    The steps of an online card payment, and plain definitions of card issuer and card network.
  2. Adyen Knowledge Hub, What's an acquiring bank and why you need one (opens in a new tab)
    What an acquirer does and how it sends authorization requests through the card schemes.
  3. Stripe documentation, Place a hold on a payment method (opens in a new tab)
    Separate authorization and capture, partial capture, and how long a hold stays valid for each card brand.
  4. Stripe documentation, How Payment Intents and Setup Intents work (opens in a new tab)
    The status of a payment, from requires_payment_method to succeeded or canceled.
  5. Adyen documentation, Payments lifecycle (opens in a new tab)
    Another processor's statuses, from Received and Authorised to SentForSettle, Settled and Refunded.
  6. Stripe documentation, Payouts (opens in a new tab)
    Settlement timing as T+X days per country, and payout schedules.
  7. Stripe documentation, Refund and cancel payments (opens in a new tab)
    Cancel versus refund, partial refunds, refund timing and failed refunds.
  8. Stripe documentation, Disputes (opens in a new tab)
    What a chargeback is and how the money is pulled back from you.
  9. Stripe documentation, Respond to disputes (opens in a new tab)
    Response deadlines, evidence, and who decides the outcome.
  10. Stripe documentation, 3D Secure authentication (opens in a new tab)
    What 3D Secure is and where regulation may require it.
  11. Stripe documentation, Receive Stripe events in your webhook endpoint (opens in a new tab)
    Signature checks, replay protection, duplicates, ordering and retries.
  12. Stripe API reference, Types of events (opens in a new tab)
    What each event means, such as payment_intent.succeeded and payout.paid.
  13. Stripe documentation, Payout reconciliation report (opens in a new tab)
    How to match each payout in your bank with the payments, refunds, disputes and fees inside it.
  14. Stripe documentation, Integration security guide (opens in a new tab)
    PCI DSS in practice, and how hosted payment fields keep card data off your servers.
  15. PCI Security Standards Council, PCI DSS (opens in a new tab)
    The official home of the card data security standard and who it applies to.

Case studies: Airbnb: Avoiding double payments with an idempotency library · Shopify: Ten habits for building payment systems that hold up · Stripe: Idempotency keys make API retries safe

Related: Money and double-entry ledgers · Idempotency, retries and timeouts · Webhooks and async APIs · Reconciliation · PCI-DSS and tokenisation (coming soon) · Payment rails: UPI and card networks (coming soon) · Fraud and risk systems (coming soon)

Term

See full entry

Jump to a section

  1. 1What broke
  2. 2The idea in simple words
  3. 3How it works
  4. 4Trade-offs
  5. 5At work
  6. 6With AI
  7. 7Check yourself
  8. 8Go deeper