Rebasely Beta: data may be purged

examples/storefront Public

Move payments into its own Worker #2

Changed files

30 files changed345 additions238 deletionssince main at 94db762

Fulfilling a paid order

2 steps rerouted, description changed

  • Added
  • Rerouted, relabelled or moved
  • Removed

From Stripe's payment_intent.succeeded to a shipment at the warehouse. The payments Worker's webhook marks the order paid through OrdersService, which announces it on order-events. fulfilment picks the event up, reads the order, creates the shipment with the order id as idempotency key, and records it.

Fulfilling a paid order: 12 steps between 8 participants Before: stripe to stripe-webhookStep 1: stripe to payments, payment_intent.succeeded, signed (rerouted, was stripe → stripe-webhook)payment_intent.succeeded, sig…Before: stripe-webhook to storefront-apiStep 2: payments to storefront-api, OrdersService.markPaid(order, intent) (rerouted, was stripe-webhook → storefront-api)OrdersService.markPaid(order, intent)Step 3: storefront-api to db, mark the order paidmark the order paidStep 4: storefront-api to order-events, send order.paidsend order.paidStep 5: order-events to fulfilment, a batch of up to 10 eventsa batch of up to 10 eventsStep 6: fulfilment to storefront-api, OrdersService.forFulfilment(order)OrdersService.forFulfilment(order)Step 7: storefront-api to db, read the order and its linesread the order and its linesStep 8: fulfilment to warehouse, POST /v1/shipments, Idempotency-Key order-<id>POST /v1/shipments, Idempoten…Step 9: warehouse to fulfilment, the shipment idthe shipment idStep 10: fulfilment to storefront-api, OrdersService.recordShipment(order, shipment)OrdersService.recordShipment(order, shipment)Step 11: storefront-api to db, mark the order fulfilledmark the order fulfilledStep 12: fulfilment to order-events, ack, or retry with backoffack, or retry with backoffstripestripeExternalpayments (added in this flow)paymentsWorker · addedstripe-webhook (removed in this flow)stripe-webhookWorker · removedstorefront-apistorefront-apiWorkerdbdbD1 databaseorder-eventsorder-eventsQueuefulfilmentfulfilmentWorkerwarehousewarehouseActor

The flow order-fulfilment at the head of this pull request, numbered in its order, with the steps it adds, reroutes, relabels, moves and removes. A removed step has no number.

Steps

  1. Step 1, rerouted: stripe → payments payment_intent.succeeded, signed Rerouted was stripe → stripe-webhook
  2. Step 2, rerouted: payments → storefront-api OrdersService.markPaid(order, intent) Rerouted was stripe-webhook → storefront-api
  3. Step 3: storefront-api → db mark the order paid
  4. Step 4: storefront-api → order-events send order.paid
  5. Step 5: order-events → fulfilment a batch of up to 10 events
  6. Step 6: fulfilment → storefront-api OrdersService.forFulfilment(order)
  7. Step 7: storefront-api → db read the order and its lines
  8. Step 8: fulfilment → warehouse POST /v1/shipments, Idempotency-Key order-<id>
  9. Step 9: warehouse → fulfilment the shipment id
  10. Step 10: fulfilment → storefront-api OrdersService.recordShipment(order, shipment)
  11. Step 11: storefront-api → db mark the order fulfilled
  12. Step 12: fulfilment → order-events ack, or retry with backoff

The flow's description changed too.

Knowledge base

Back to the conversation