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.

sagaerror boundarypaymentse-commerce
Open in editor Download .bpmn
casen template use payment-saga
Take payment yes no Reservestock Releasestock Notifycustomer:paymentdeclined Createshipment Authorisepayment Capturepayment Checkout completed Payment declined Order failed Order shipped Authorised?

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-notify Notify customer: payment declined
  • inventory-release Release stock
  • inventory-reserve Reserve stock
  • payment-authorise Authorise payment
  • payment-capture Capture payment
  • shipment-create Create shipment

Files · 2

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.