Templates / Sagas & error handling / payment-saga
Checkout Payment Saga
Reserves stock before taking payment, so a paid order can always be shipped. Payment runs in its own sub-process — authorise, then capture — and a declined authorisation throws PAYMENT_DECLINED. The error boundary releases the reservation, which is the only thing to undo at that point, and tells the customer; a captured payment goes on to shipment.
Scenarios · 2
- Payment is authorised and captured, the order ships reserve-stock → authorise-payment → capture-payment → create-shipment → order-shipped
- A declined card releases the stock authorise-payment → payment-declined → on-payment-declined → release-stock → order-failed
Job types · 6
-
customer-notifyNotify customer: payment declined -
inventory-releaseRelease stock -
inventory-reserveReserve stock -
payment-authoriseAuthorise payment -
payment-captureCapture payment -
shipment-createCreate shipment
Files · 2
- payment-saga.bpmn Process model
- payment-saga.bpmn.tests.json Test scenarios (runScenario format)
Every scenario passes on @bpmnkit/engine's runScenario in the
package's tests. casen template use payment-saga [dir] writes the files above
into your project — see the templates guide for running
the scenarios and deploying.