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

Checking out a cart

1 step added, 3 rerouted, description changed

  • Added
  • Rerouted, relabelled or moved
  • Removed

The shopper checks out an open cart. storefront-api takes the stock and creates the order in one D1 batch, then asks the payments Worker for a PaymentIntent and hands its client secret to the browser, which confirms the payment with the Payment Element. Stripe reports the result to the payments Worker, which marks the order paid through OrdersService.

Checking out a cart: 12 steps between 6 participants Step 1: shopper to storefront-api, POST /carts/:id/checkout, email and addressPOST /carts/:id/checkout, ema…Step 2: storefront-api to db, read the cart and check the stockread the cart and check the s…Step 3: storefront-api to db, one batch: insert the order, take the stock, close the cartone batch: insert the order, …Step 4: storefront-api to payments, PaymentsService.createIntent(order, total) (added)PaymentsService.createIntent(order, total)Before: storefront-api to stripeStep 5: payments to stripe, create a PaymentIntent for the order total (rerouted, was storefront-api → stripe)create a PaymentIntent for th…Step 6: storefront-api to db, save the PaymentIntent id on the ordersave the PaymentIntent id on …Step 7: storefront-api to shopper, the order and the client secretthe order and the client secr…Step 8: shopper to stripe, confirm the payment with the Payment Elementconfirm the payment with the Payment ElementBefore: stripe to stripe-webhookStep 9: stripe to payments, payment_intent.succeeded, signed (rerouted, was stripe → stripe-webhook)payment_intent.succeeded, sig…Before: stripe-webhook to storefront-apiStep 10: payments to storefront-api, OrdersService.markPaid(order, intent) (rerouted, was stripe-webhook → storefront-api)OrdersService.markPaid(order, intent)Step 11: storefront-api to db, mark the order paid if it is still pendingmark the order paid if it is …Step 12: shopper to storefront-api, GET /orders/:id until it is paidGET /orders/:id until it is p…shoppershopperActorstorefront-apistorefront-apiWorkerdbdbD1 databasepayments (added in this flow)paymentsWorker · addedstripestripeExternalstripe-webhook (removed in this flow)stripe-webhookWorker · removed

The flow checkout 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: shopper → storefront-api POST /carts/:id/checkout, email and address
  2. Step 2: storefront-api → db read the cart and check the stock
  3. Step 3: storefront-api → db one batch: insert the order, take the stock, close the cart
  4. Step 4, added: storefront-api → payments PaymentsService.createIntent(order, total) Added
  5. Step 5, rerouted: payments → stripe create a PaymentIntent for the order total Rerouted was storefront-api → stripe
  6. Step 6: storefront-api → db save the PaymentIntent id on the order
  7. Step 7: storefront-api → shopper the order and the client secret
  8. Step 8: shopper → stripe confirm the payment with the Payment Element
  9. Step 9, rerouted: stripe → payments payment_intent.succeeded, signed Rerouted was stripe → stripe-webhook
  10. Step 10, rerouted: payments → storefront-api OrdersService.markPaid(order, intent) Rerouted was stripe-webhook → storefront-api
  11. Step 11: storefront-api → db mark the order paid if it is still pending
  12. Step 12: shopper → storefront-api GET /orders/:id until it is paid

The flow's description changed too.

Knowledge base

Back to the conversation