The 4 states
| State | Timing | Amounts reliable? | Use for accounting? |
|---|---|---|---|
authorized | Seconds after purchase | ❌ May change | Preview only |
deleted | Before clearing | N/A | Delete from your system |
cleared | 3-5 days after purchase | ✅ Final | YES |
invoiced | When issuer invoices | ✅ Final + invoice # | YES |
Recommended implementation
The golden rules
- Always handle
cleared— non-negotiable for accounting authorized+deleted+cleared= best UX (users see purchases instantly, deletions handled)authorizedalone = you’ll miss transactions that clear without prior auth (rare but possible)- Use
idas primary key — sameidacross all states for one transaction card_issuer_referencediffers per state — don’t use it as your primary key
Upsert logic detail
| Event | Transaction exists? | Action |
|---|---|---|
authorized | No | Create |
authorized | Yes | Update (amounts may change before clearing) |
cleared | No | Create (you missed authorized — still ok) |
cleared | Yes | Update with final amounts |
invoiced | No | Create |
invoiced | Yes | Update, set invoice_number |
deleted | Yes | Delete |
deleted | No | Ignore (nothing to delete) |
receiptable flag
true, a digital receipt may arrive later via receipt.fetched. If false, don’t wait for one.
Subscribe to receipt_fetched, transaction_true_vat, and transaction_line_items separately — they come as independent events after the transaction.
Card types
card_type | Meaning |
|---|---|
corporate | Company card, company pays |
private | Personal card |
corporate_with_private_invoice | Company card, employee reimbursed privately |
VAT caveat
vat_rate and vat_amount on the transaction payload come from the card network — often wrong for restaurants, hotels, etc.
For correct VAT, subscribe to transaction.true.vat — that comes from the actual merchant receipt.
