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

Expiring an unpaid order

Added by this pull request.

  • Added
  • Rerouted, relabelled or moved
  • Removed

Every five minutes the cron trigger on storefront-api looks for orders still waiting for payment after 30 minutes. It cancels each one's PaymentIntent through the payments Worker first, so a late payment cannot land on a cancelled order, then cancels the order and puts its stock back.

Expiring an unpaid order: 7 steps between 6 participants Step 1: cron to storefront-api, scheduled(), every five minutes (added)scheduled(), every five minut…Step 2: storefront-api to db, orders pending_payment for over 30 minutes, 50 at most (added)orders pending_payment for ov…Step 3: storefront-api to payments, PaymentsService.cancelIntent(intent) (added)PaymentsService.cancelIntent(intent)Step 4: payments to stripe, cancel the PaymentIntent (added)cancel the PaymentIntentStep 5: payments to storefront-api, true, or false if it already succeeded (added)true, or false if it already succeededStep 6: storefront-api to db, one batch: put the stock back, cancel the order (added)one batch: put the stock back…Step 7: storefront-api to order-events, send order.cancelled (added)send order.cancelledcron (added in this flow)cronActor · addedstorefront-api (added in this flow)storefront-apiWorker · addeddb (added in this flow)dbD1 database · addedpayments (added in this flow)paymentsWorker · addedstripe (added in this flow)stripeExternal · addedorder-events (added in this flow)order-eventsQueue · added

The flow order-expiry 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, added: cron → storefront-api scheduled(), every five minutes Added
  2. Step 2, added: storefront-api → db orders pending_payment for over 30 minutes, 50 at most Added
  3. Step 3, added: storefront-api → payments PaymentsService.cancelIntent(intent) Added
  4. Step 4, added: payments → stripe cancel the PaymentIntent Added
  5. Step 5, added: payments → storefront-api true, or false if it already succeeded Added
  6. Step 6, added: storefront-api → db one batch: put the stock back, cancel the order Added
  7. Step 7, added: storefront-api → order-events send order.cancelled Added

Knowledge base

Back to the conversation