Payments
A charge can succeed at the processor and still be missing from your database, or the other way around. The row you have is not a history of which step committed.
Two specs in the Causet repo compile. They solve different problems.
| Spec | Path | What it does |
|---|---|---|
| Payment retrofit | examples/payment-retrofit | Records processor facts. Does not charge the card. |
| Payment orchestration | examples/payment-orchestration | Runs reserve → authorize → settle, and a retry that refuses a second settlement. |
causet build compile on 2026-11-20 succeeded for both. Retrofit: 1 stream, 3 intents, 6 rules. Orchestration: 2 streams, 12 intents, 33 rules, 1 saga. Neither spec was executed in this pass, so this page does not show a live timeline.
Without Causet
POST /api/payments
→ insert payment row
→ call processor
→ webhook arrives, maybe twice, maybe after the row was already updated
→ three tables disagree with the processor dashboardThe handler is the only place that knows the order of those steps, and only while the process is still alive.
How Causet fits
Your API still accepts the HTTP request and still talks to the processor if you are the one charging the card. Causet records the intent and the events your rules emit.
For a processor you do not want Causet to call, use the retrofit spec. A webhook is mapped to an observed intent. Causet stores the fact the processor reported.
observations:
payments_declined:
source_key: payments
external_type: PAYMENT_DECLINED
action: OBSERVE_PAYMENT_DECLINED
stream: payment
entity_id: event.payment_idOBSERVE_PAYMENT_DECLINED rejects when entity.status == "settled" with code ALREADY_SETTLED. OBSERVE_PAYMENT_AUTHORIZED rejects when the payment is already declined. charge.risk_flagged is mapped to PAYMENT_RISK_FLAGGED and has no observation binding, so it stays in the journal and does not become payment state.
Failure in the orchestration spec
RETRY_PAYMENT is a new intent. Its preflight rejects when the payment is already settled:
- name: reject_already_settled
when:
expr: "entity.status == \"settled\""
then:
- op: reject
code: ALREADY_SETTLED
message: "Payment already settled — idempotency protected"That reject is a rule outcome. It is not causet recovery replay. Replay recomputes recorded state and does not call the processor again. Submitting RETRY_PAYMENT or SUBMIT_PAYMENT again can.
The saga steps are idle → submitted → account_validated → funds_reserved → processor_called → authorized → ledger_updated → settled, with ambiguous and failed branches.
What you gain
You can point at the committed intent instead of reconstructing the charge from the processor dashboard and your tables. A settled payment has a rule that refuses another settlement for that state.
Limits
- Causet does not replace the processor, your API, or your database.
- The retrofit spec does not compute a risk score. It records one if the processor sent it, and an unbound event does not move payment state.
- Projection queries can lag the snapshot. See Read consistency.