Persistence as a port, plus the in-memory adapter the template runs on.
Two operations carry the invariants; everything else is storage.
record-payment! is idempotent per (invoice, reference): a rail that reports
the same transaction forever must move the books exactly once.
claim-paid! is a compare-and-set on the invoice's status. Only the caller
that performs the pending -> paid transition is told it did, and that caller
is the one — the only one — that may hand anything over.
Persistence as a port, plus the in-memory adapter the template runs on. Two operations carry the invariants; everything else is storage. `record-payment!` is idempotent per (invoice, reference): a rail that reports the same transaction forever must move the books exactly once. `claim-paid!` is a compare-and-set on the invoice's status. Only the caller that performs the pending -> paid transition is told it did, and that caller is the one — the only one — that may hand anything over.
(unapplied-payments this limit)Money that was seen but could not be applied, newest first.
Money that was seen but could not be applied, newest first.
(open-invoices this)Every invoice that can still take money.
Every invoice that can still take money.
(payments-for this invoice-id)Payments recorded against invoice-id.
Payments recorded against `invoice-id`.
(customer-by-ref this customer-ref)Customer the host application knows by customer-ref, or nil.
Customer the host application knows by `customer-ref`, or nil.
(invoice-by-id this invoice-id)Invoice, or nil.
Invoice, or nil.
(record-payment! this payment)Record one observed movement of money. Returns the stored Payment, or nil when this exact (invoice, reference) was already recorded.
Record one observed movement of money. Returns the stored Payment, or nil when this exact (invoice, reference) was already recorded.
(release-claim! this invoice-id)Undo a claim whose fulfilment failed, so a later sweep retries it.
Undo a claim whose fulfilment failed, so a later sweep retries it.
(customer-by-id this customer-id)Customer, or nil.
Customer, or nil.
(set-invoice-status! this invoice-id status)Move the invoice to status unconditionally. Returns the invoice.
Move the invoice to `status` unconditionally. Returns the invoice.
(invoices-for-customer this customer-id)Every invoice of customer-id, newest first.
Every invoice of `customer-id`, newest first.
(record-fulfilment! this fulfilment)Record that the host application was told to hand something over.
Record that the host application was told to hand something over.
(live-invoice-for this criteria)The newest still-open invoice matching {:customer-id :item-id :provider}, or nil.
The newest still-open invoice matching {:customer-id :item-id :provider},
or nil.(upsert-customer! this identity)Customer for identity {:customer/ref :customer/email}, created if new.
Customer for `identity` {:customer/ref :customer/email}, created if new.
(attach-external-ref! this invoice-id external-ref)Record the rail's own identifier on the invoice. Returns the invoice.
Record the rail's own identifier on the invoice. Returns the invoice.
(fulfilments-for this customer-id)Everything customer-id has been granted.
Everything `customer-id` has been granted.
(insert-invoice! this invoice)Store invoice verbatim. Returns it.
Store `invoice` verbatim. Returns it.
(claim-paid! this invoice-id)Transition invoice-id from pending/underpaid to paid, once.
Returns the invoice when THIS call performed the transition, nil when it was already paid or does not exist. The gate that makes a redelivered settlement notice harmless.
Transition `invoice-id` from pending/underpaid to paid, once. Returns the invoice when THIS call performed the transition, nil when it was already paid or does not exist. The gate that makes a redelivered settlement notice harmless.
(memory-store)(memory-store {:keys [now-fn] :or {now-fn (fn* [] (Date.))}})IOrderStore over an atom. The template's default, and what the tests run on.
Every write is a swap!, so the compare-and-set claim-paid! depends on is
the atom's own, not a lock this namespace has to keep.
IOrderStore over an atom. The template's default, and what the tests run on. Every write is a `swap!`, so the compare-and-set `claim-paid!` depends on is the atom's own, not a lock this namespace has to keep.
Invoice statuses that can still take money and settle normally.
Invoice statuses that can still take money and settle normally.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |