Skip to content
Tutorials Center
My learning

Topics

Lesson 17 of 40 ยท Payments

Authorization, Capture, Refunds and Chargebacks

Learn the payment lifecycle: authorization holds, capture timing, partial capture, voids, refunds and chargebacks, plus how to model them in a ledger.

A card payment is not one action. It is a short story with several chapters: the bank promises to pay (authorization), the shop claims the money (capture), the shop may give some back (refund), and, rarely, the cardholder asks their bank to take it back by force (chargeback). Your code has to know which chapter it is in, because the same amount means different things in each.

This lesson explains each operation, the timing rules that matter in practice, and how to store payment activity so the numbers always add up. It builds on How Online Payments Work and feeds the order model from The Order Lifecycle.

Authorization: the hold

An authorization asks the issuer, "Will you pay this amount?" If it approves, the issuer reduces the cardholder's available balance or credit limit by that amount and gives you an authorization code. No money has moved yet. The shopper often sees a "pending" entry in their banking app.

Things to know:

  • An authorization expires. For many card types the window is about 5 to 7 days online, and it can be shorter or longer depending on the network, card and merchant category. Your provider documents its limit. After it expires, the hold drops and you cannot capture.
  • An authorization may be declined. Common reasons: insufficient funds, a card the issuer suspects is stolen, wrong CVC, expired card, or a failed 3-D Secure check. A decline is a normal result, not an exception; show a calm message and let the shopper try again.
  • You can authorize and capture in one step. Providers call this a sale or automatic capture.

Capture: claiming the money

Capture tells the provider to collect an authorized amount. It starts settlement, and the money reaches your account after the payout delay.

When should you capture?

Strategy When it fits Trade-off
Capture immediately Digital goods, services, anything delivered at once Simple. If you cannot deliver, you must refund.
Capture at shipment Physical goods, especially with stock risk Avoids refunds for orders you cancel, but the authorization must not expire before you ship.
Capture partially Split shipments or items out of stock Charge only for what you sent; the rest of the hold is released.

Some regions have rules about charging before dispatch. In several places, shops are expected to charge when goods ship. Check your provider and local consumer rules (GDPR, Consumer Law and Accessibility).

Partial capture is useful when only part of an order is available. Whether you can capture more than once against the same authorization depends on the provider and the card network, so read their rules. Many providers allow one capture per authorization and release the remaining hold.

Voids and cancellations

If you decide not to charge at all (the item is out of stock, the order was cancelled), void the authorization. A void cancels the hold before capture, so the shopper never loses available balance for long and you usually pay no fee. After capture you cannot void; you must refund.

stateDiagram-v2
    [*] --> authorized
    authorized --> captured: capture
    authorized --> voided: void
    authorized --> expired: hold expires
    captured --> partially_refunded: partial refund
    captured --> refunded: full refund
    partially_refunded --> refunded: remaining refund
    captured --> disputed: chargeback opened
    partially_refunded --> disputed: chargeback opened
    disputed --> captured: dispute won
    disputed --> lost: dispute lost

The lifecycle of a card payment. Void applies before capture, refunds after, and a dispute can start at any time after capture.

Refunds

A refund sends money back to the original payment method. Rules to remember:

  • You can refund up to the captured amount minus what was already refunded, never more. Enforce this on your side before calling the provider.
  • Partial refunds are normal (one item from an order, a shipping credit, a goodwill discount). You may do several, as long as the total stays within the captured amount.
  • Refunds are not instant. The shopper usually sees them within several business days, depending on their bank.
  • Providers may keep the original processing fee, or return only part of it. Do your accounting with both numbers.
  • Refund to the original method unless there is a good reason. Refunding to a different method is a money-laundering warning sign and often against provider rules. Store credit is a separate product decision (Fulfillment, Returns and Refunds).
  • A refund is a side effect that moves money, so make it idempotent so a retry cannot refund twice (Idempotency and Reliable Payments).

Chargebacks and disputes

A chargeback happens when a cardholder tells their bank, "I do not recognize or accept this charge." The issuer pulls the money back from the acquirer, usually adds a fee, and gives the merchant a short window (often days to a few weeks) to respond with evidence.

Typical reasons:

  • Fraud: the real cardholder did not make the purchase.
  • Item not received or not as described.
  • Duplicate charge or wrong amount.
  • Subscription canceled but still billed.
  • Friendly fraud: the cardholder made the purchase but disputes it anyway, sometimes by mistake or because they do not recognize the descriptor on their statement.

Good evidence tells a clear story:

  • order details, customer email and IP address, and the AVS and CVC results;
  • 3-D Secure result, if used (it can shift liability, see PCI DSS Scope and 3-D Secure);
  • proof of delivery with tracking, signature or delivery photo;
  • previous undisputed orders from the same customer and device;
  • your refund and cancellation policy and proof the customer saw it;
  • communication with the customer.

You cannot win by arguing; you win with records. This is another reason to keep the snapshots and history from the order lifecycle lesson.

Keep your dispute rate low. Networks monitor the ratio of chargebacks to transactions (often around 1%, with stricter limits in some programs), and merchants above the threshold risk fines or losing the ability to accept cards. See Fraud and Risk Management.

A friendly alternative to a dispute is a fast, easy refund. Make support easy to reach, and make your statement descriptor recognizable.

Modeling payments in your database

Do not keep a single paid flag plus an amount. Model payment activity as an append-only ledger of transactions against a payment:

  • payment: id, order id, currency, provider reference, current status.
  • payment_transaction: payment id, type (authorization, capture, void, refund, chargeback, chargeback_reversal), amount (integer minor units), provider reference, status, created time.

From the ledger you derive balances:

  • authorized amount = sum of successful authorizations,
  • captured = sum of captures,
  • refunded = sum of refunds,
  • net = captured minus refunded minus chargebacks lost.

The status is a summary of these numbers. The ledger is the truth, and it helps finance reconcile payouts line by line.

The Python example below implements a tiny ledger that enforces the rules from this lesson: capture only what is authorized, refund only what is captured, and nothing after a void.

Python A payment ledger with rules

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The ledger holds only facts that happened. Balances and status are computed from it. In a database you would also store provider references and unique constraints so a repeated webhook cannot insert the same transaction twice.

Handling disputes in the same ledger

A chargeback adds more rows rather than editing old ones. When the issuer withdraws the money, record a chargeback entry. If you win, the money returns and you record a chargeback_reversal. This second example shows how the net result differs for won and lost disputes:

Python Won and lost chargebacks

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The last line is the lesson: when a shopper complains, a quick voluntary refund often costs less than a dispute fee plus the risk to your dispute ratio. (Fee amounts shown are illustrative; check your own contract.)

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a void do?

    A void releases the hold before capture. After capture the only way to return money is a refund.
  2. 2. A payment of $85.00 was captured and $20.00 refunded. What is the maximum further refund?

    You can refund captured minus already refunded: 85 - 20 = 65.
  3. 3. Why is a payment best modeled as an append-only ledger of transactions?

    A ledger keeps every authorization, capture and refund, so totals can always be recomputed and audited.
  4. 4. What is the strongest kind of evidence in a dispute?

    Issuers decide from documents. Clear records of the order, delivery and authentication tell the story.

Summary

  • Authorization reserves funds; capture claims them; settlement moves them later.
  • Authorizations expire, so capture before the window closes or re-authorize.
  • Void before capture; refund after capture, never more than the captured amount minus earlier refunds.
  • Chargebacks pull money back and cost fees; win them with records and prevent them with clear descriptors and easy refunds.
  • Store payments as an append-only ledger and derive balances and status from it.

Next, keep card data out of your systems: PCI DSS Scope and 3-D Secure.