Rebasely Beta: data may be purged

examples/storefront Public

Draw the order expiry flow and update the local setup for payments

1 check passed
The cancel path now crosses two Workers, so it gets a flow of its own. The README and the local development guide run the payments Worker in place of the webhook Worker, with its secrets in workers/payments/.dev.vars.
e83464e02f4d8ffa8c827730c056d0d73a35e7da
Parent 80dbc76 Browse filesHistory

Changed files

3 files changed20 additions6 deletionsagainst 80dbc76

  1. Added.rebasely/architecture/flows/order-expiry.yaml+14−0
  2. Changed.rebasely/kb/guides/local-dev.md+4−4
  3. ChangedREADME.md+2−2
Added.rebasely/architecture/flows/order-expiry.yaml+14−0
@@ -0,0 +1,14 @@
+title: Expiring an unpaid order
+description: >-
+ 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.
+actors: [cron]
+steps:
+ - { from: cron, to: storefront-api, label: "scheduled(), every five minutes" }
+ - { from: storefront-api, to: db, label: "orders pending_payment for over 30 minutes, 50 at most" }
+ - { from: storefront-api, to: payments, label: PaymentsService.cancelIntent(intent) }
+ - { from: payments, to: stripe, label: cancel the PaymentIntent }
+ - { from: payments, to: storefront-api, label: "true, or false if it already succeeded" }
+ - { from: storefront-api, to: db, label: "one batch: put the stock back, cancel the order" }
+ - { from: storefront-api, to: order-events, label: send order.cancelled }
View file
Changed.rebasely/kb/guides/local-dev.md+4−4
@@ -6,7 +6,7 @@
- wrangler.jsonc
- workers/*/wrangler.jsonc
- scripts/seed.sql
-reviewed: 2026-10-12
+reviewed: 2026-10-15
---
# Running the shop locally
@@ -22,7 +22,7 @@
npm run dev # storefront-api on localhost:8787
```
-`curl localhost:8787/products` lists all six; the candle is out of stock, so adding it to a cart fails. Add `STRIPE_SECRET_KEY` (a test mode secret key) to `.dev.vars` to try checkout.
+`curl localhost:8787/products` lists all six; the candle is out of stock, so adding it to a cart fails. Checkout needs the payments Worker running too, with a Stripe test mode secret key.
Image URLs point at `IMAGES_URL` from `wrangler.jsonc`. Locally the upload works but the URL does not resolve, because the custom domain serves the production bucket ([[product-images]]). Set `IMAGES_URL` in `.dev.vars` to another origin if you want working links.
@@ -31,11 +31,11 @@
Each has its own config, so run it in a second terminal from the repository root:
```bash
-npx wrangler dev -c workers/stripe-webhook/wrangler.jsonc --port 8788
+npx wrangler dev -c workers/payments/wrangler.jsonc --port 8788
npx wrangler dev -c workers/fulfilment/wrangler.jsonc --port 8789
```
-wrangler connects the `ORDERS` service bindings to the storefront-api you started first, and the `order-events` queue between storefront-api and fulfilment. See [[payment-webhook]] for forwarding Stripe's test events and [[fulfilment]] for the warehouse settings.
+Each Worker reads its secrets from a `.dev.vars` next to its config: `STRIPE_SECRET_KEY` and `STRIPE_WEBHOOK_SECRET` for payments, `WAREHOUSE_URL` and `WAREHOUSE_TOKEN` for fulfilment. wrangler connects the service bindings between the running Workers (`PAYMENTS` one way, `ORDERS` the other), and the `order-events` queue between storefront-api and fulfilment. See [[payment-webhook]] for forwarding Stripe's test events and [[fulfilment]] for the warehouse settings.
## Cron
View file
ChangedREADME.md+2−2
@@ -5,7 +5,7 @@
There are three Workers:
- `storefront-api` (`src/`) is the public API and the only Worker that writes to the database.
-- `storefront-stripe-webhook` (`workers/stripe-webhook/`) receives Stripe's events and settles orders through storefront-api's `OrdersService` entrypoint.
+- `storefront-payments` (`workers/payments/`) holds the Stripe keys. storefront-api calls its `PaymentsService` entrypoint to create and cancel PaymentIntents, and it receives Stripe's webhooks and settles orders through storefront-api's `OrdersService` entrypoint.
- `storefront-fulfilment` (`workers/fulfilment/`) consumes the `order-events` queue and sends paid orders to the warehouse.
The order fulfilment flow on the Architecture tab follows a payment through all three.
@@ -29,7 +29,7 @@
npm run dev
```
-Product images are served from the bucket's custom domain, `IMAGES_URL` in `wrangler.jsonc`. Checkout needs Stripe: add `STRIPE_SECRET_KEY` to `.dev.vars` with a secret key from your Stripe account's test mode.
+Product images are served from the bucket's custom domain, `IMAGES_URL` in `wrangler.jsonc`. Checkout needs the payments Worker running next to it with a Stripe test mode key; the local development guide has the commands.
The guide in `.rebasely/kb/guides/local-dev.md` covers the other two Workers and the cron trigger. To add a product and look at the catalog:
View file

Checks

1 check passed
StatusCheckReported byDescriptionDetails
Successduragit/ci/testRebasely ActionssucceededRun

Runs

StatusWorkflowEventStarted
SuccessciPush