Order Processing
View as MarkdownCharge a buyer, wait for the seller to approve the shipment, then ship. If shipping keeps failing, refund the buyer.
SDKs: Python · Go · TypeScript · Java · Rust
Shows: Reminder, Execute Failure Recovery, and Wait for Step Completion.
Flow design
- Charge charges the buyer and sets the order-status Attribute to
charged. - Ship waits for the seller's approval on the seller-ok Channel or for a 24-hour Timer. When the Timer fires first, Ship sends a reminder and waits again. After approval, it ships the item, sets order-status to
shipped, and completes the Flow with the outputshipped:<order ID>. - Refund runs when Ship's retries run out. It refunds the buyer, sets order-status to
refunded, and completes the Flow withrefunded:<order ID>. In the graph, ⚠ on a Step marks a failure route; select the Step to see where it goes.
The approve RPC publishes the approval to seller-ok. The describe RPC returns order-status.
Core implementation
The charge, shipment, and refund calls carry an idempotency key built from the order ID, which is also the Flow ID: charge-<order ID>, ship-<order ID>, and refund-<order ID>. A Step that is cut off can run again with the same key, so the payment and shipping services can drop the repeat. See Idempotency keys. A real reminder email needs a key too, because a Step that was cut off can run again. The example passes none.
Each Step's Execute has a 3-second retry budget to keep the demo short; the code comments suggest one hour in production. Ship's failure route moves to Refund, which has its own short retry.
The Flow receives its services in its constructor (What a Flow contains). order-status is indexed, so you can search Flows by status. The dex:group and dex:explanation comments label the Steps in the graph above.
order_status = Attribute(
"order-status",
str,
AttributeIndex(IndexType.KEYWORD, "keyword1"),
)
seller_ok = Channel[str]("seller-ok", str)
# dex:group group-id:payment group-label:"Payment"
# dex:explanation text:"Charge the customer for the order."
class Charge(Step[OrderRequest]):
def __init__(self, service: MyDependencyService) -> None:
self.service = service
def get_step_options(self) -> StepOptions:
def execute(self, context: Context, input: OrderRequest) -> StepDecision:
self.service.charge_user(
input.email,
input.customer_id,
input.amount,
idempotency_key=f"charge-{input.order_id}",
)
order_status.set(context, "charged")
return go_to(Ship, input)
# dex:group group-id:shipping group-label:"Shipping"
# dex:explanation text:"Wait for seller approval, remind after 24 hours, then ship the order."
class Ship(Step[OrderRequest]):
def __init__(self, service: MyDependencyService) -> None:
self.service = service
def get_step_options(self) -> StepOptions:
def wait_for(self, context: Context, input: OrderRequest) -> Wait:
return Wait.any_of(
seller_ok.for_one(),
Timer.by_duration(timedelta(hours=24)),
)
def execute(self, context: Context, input: OrderRequest) -> StepDecision:
if context.has_timer_fired():
self.service.send_email(
input.email,
"Reminder: approve shipment",
"Please approve or provide a tracking number.",
)
return go_to(Ship, input)
self.service.ship_item(
input.order_id,
input.test_fail_at_shipping,
idempotency_key=f"ship-{input.order_id}",
)
order_status.set(context, "shipped")
return graceful_complete(f"shipped:{input.order_id}")
# dex:group group-id:refund group-label:"Refund"
# dex:explanation text:"Refund the order when shipping keeps failing."
class Refund(Step[OrderRequest]):
def __init__(self, service: MyDependencyService) -> None:
self.service = service
def execute(self, context: Context, input: OrderRequest) -> StepDecision:
self.service.update_external_system(
f"refund {input.order_id}", idempotency_key=f"refund-{input.order_id}"
)
order_status.set(context, "refunded")
return graceful_complete(f"refunded:{input.order_id}")
class OrderProcessingFlow(Flow[OrderRequest]):
def __init__(self, service: MyDependencyService) -> None:
self.service = service
self.refund = Refund(service)
self.ship = Ship(service)
self.charge = Charge(service)
def get_steps(self) -> StepList[OrderRequest]:
return StepList.start_step(self.charge).other_steps(self.ship, self.refund)
def get_persistence_schema(self) -> PersistenceSchema:
return PersistenceSchema.of(order_status, seller_ok)
@rpc
def approve(self, context: Context, _note: str) -> RPCResult[str]:
seller_ok.publish(context, "approved")
return RPCResult("ok")
@rpc
def describe(self, context: Context) -> RPCResult[str]:
return RPCResult(order_status.get(context))
Example: examples/python/dex_examples/products/order-processing/order_processing_flow.py
type OrderProcessingFlow struct {
dex.FlowDefaults
service service.MyService
}
func NewOrderProcessingFlow(applicationService service.MyService) *OrderProcessingFlow {
return &OrderProcessingFlow{service: applicationService}
}
func (flow *OrderProcessingFlow) GetSteps() []dex.StepDef {
return []dex.StepDef{
dex.DefineStartStep(chargeStep{service: flow.service}),
dex.DefineStep(shipStep{service: flow.service}),
dex.DefineStep(refundStep{service: flow.service}),
}
}
func (flow *OrderProcessingFlow) GetRPCs() []dex.RPCDef {
return []dex.RPCDef{
dex.DefineRPC(flow.Approve, nil),
dex.DefineRPC(flow.Describe, nil),
}
}
func (*OrderProcessingFlow) GetPersistenceSchema() dex.PersistenceSchema {
return dex.PersistenceSchema{
Attributes: []dex.AttributeDef{OrderStatus},
Channels: []dex.ChannelDef{SellerOK},
}
}
type chargeStep struct {
dex.StepDefaultsNoWaitFor[OrderRequest]
service service.MyService
}
func (chargeStep) GetStepType() string {
return ChargeStepType
}
func (chargeStep) GetStepOptions() *dex.StepOptions {
}
func (step chargeStep) Execute(
ctx dex.Context,
order OrderRequest,
) (*dex.StepDecision, error) {
step.service.ChargeUserWithIdempotencyKey(order.Email, order.CustomerID, order.Amount, "charge-"+order.OrderID)
if err := OrderStatus.Set(ctx, "charged"); err != nil {
return nil, err
}
return dex.GoTo(shipStep{}, order), nil
}
type shipStep struct {
dex.DefaultStepType
service service.MyService
}
func (shipStep) GetStepType() string {
return ShipStepType
}
func (step shipStep) GetStepOptions() *dex.StepOptions {
}
func (shipStep) WaitFor(
dex.Context,
OrderRequest,
) (*dex.Wait, error) {
return dex.AnyOf(
SellerOK.ForOne(),
dex.Timer(24*time.Hour),
), nil
}
func (step shipStep) Execute(
ctx dex.Context,
order OrderRequest,
) (*dex.StepDecision, error) {
if ctx.HasTimerFired() {
step.service.SendEmail(
order.Email,
"Reminder: approve shipment",
"Please approve or provide a tracking number.",
)
return dex.GoTo(shipStep{}, order), nil
}
if err := step.service.ShipItemWithIdempotencyKey(order.OrderID, order.TestFailAtShipping, "ship-"+order.OrderID); err != nil {
return nil, err
}
if err := OrderStatus.Set(ctx, "shipped"); err != nil {
return nil, err
}
return dex.GracefulComplete("shipped:" + order.OrderID), nil
}
type refundStep struct {
dex.StepDefaultsNoWaitFor[OrderRequest]
service service.MyService
}
func (refundStep) GetStepType() string {
return RefundStepType
}
func (step refundStep) Execute(
ctx dex.Context,
order OrderRequest,
) (*dex.StepDecision, error) {
step.service.UpdateExternalSystemWithIdempotencyKey("refund "+order.OrderID, "refund-"+order.OrderID)
if err := OrderStatus.Set(ctx, "refunded"); err != nil {
return nil, err
}
return dex.GracefulComplete("refunded:" + order.OrderID), nil
}
var (
_ dex.Flow = (*OrderProcessingFlow)(nil)
_ dex.RPC[string, string] = (*OrderProcessingFlow)(nil).Approve
_ dex.RPC[dex.None, string] = (*OrderProcessingFlow)(nil).Describe
)
public class OrderProcessingFlow implements Flow<OrderRequest> {
public static final Attribute<String> orderStatus = Attribute.define(
"order-status",
String.class,
new AttributeIndex(AttributeIndex.Type.KEYWORD, "keyword1"));
public static final Channel<String> sellerOk = Channel.define("seller-ok", String.class);
private final MyDependencyService service;
private final Charge charge;
private final Ship ship;
private final Refund refund;
public OrderProcessingFlow(final MyDependencyService service) {
this.service = service;
this.refund = new Refund(service);
this.ship = new Ship(service);
this.charge = new Charge(service);
}
@Override
public StepList<OrderRequest> getSteps() {
return StepList.startStep(charge).otherSteps(ship, refund);
}
@Override
public PersistenceSchema getPersistenceSchema() {
return PersistenceSchema.of(orderStatus, sellerOk);
}
@RPC
public RPCResult<String> approve(final Context context, final String note) {
sellerOk.publish(context, "approved");
return RPCResult.of("ok");
}
@RPC
public RPCResult<String> describe(final Context context) {
return RPCResult.of(orderStatus.get(context));
}
static final class Charge implements Step<OrderRequest> {
private final MyDependencyService service;
Charge(final MyDependencyService service) {
this.service = service;
}
@Override
public String getStepType() {
return "Charge";
}
@Override
public Class<OrderRequest> getInputType() {
return OrderRequest.class;
}
@Override
public StepOptions getStepOptions() {
}
@Override
public StepDecision execute(final Context context, final OrderRequest order) {
service.chargeUser(order.email, order.customerId, order.amount, "charge-" + order.orderId);
orderStatus.set(context, "charged");
return StepDecision.goTo(Ship.class, order);
}
}
static final class Ship implements Step<OrderRequest> {
private final MyDependencyService service;
Ship(final MyDependencyService service) {
this.service = service;
}
@Override
public String getStepType() {
return "Ship";
}
@Override
public Class<OrderRequest> getInputType() {
return OrderRequest.class;
}
@Override
public StepOptions getStepOptions() {
}
@Override
public Wait waitFor(final Context context, final OrderRequest order) {
return Wait.anyOf(
sellerOk.forOne(),
Timer.byDuration(Duration.ofHours(24)));
}
@Override
public StepDecision execute(final Context context, final OrderRequest order) {
if (context.hasTimerFired()) {
service.sendEmail(
order.email,
"Reminder: approve shipment",
"Please approve or provide a tracking number.");
return StepDecision.goTo(Ship.class, order);
}
service.shipItem(order.orderId, order.testFailAtShipping, "ship-" + order.orderId);
orderStatus.set(context, "shipped");
return StepDecision.gracefulComplete("shipped:" + order.orderId);
}
}
static final class Refund implements Step<OrderRequest> {
private final MyDependencyService service;
Refund(final MyDependencyService service) {
this.service = service;
}
@Override
public String getStepType() {
return "Refund";
}
@Override
public Class<OrderRequest> getInputType() {
return OrderRequest.class;
}
@Override
public StepDecision execute(final Context context, final OrderRequest order) {
service.updateExternalSystem("refund " + order.orderId, "refund-" + order.orderId);
orderStatus.set(context, "refunded");
return StepDecision.gracefulComplete("refunded:" + order.orderId);
}
}
}
Example: examples/java/src/main/java/io/superdurable/dex/products/orderprocessing/OrderProcessingFlow.java
const orderStatus = new Attribute("order-status", stringCodec, {
type: IndexType.KEYWORD,
indexKey: "keyword1",
});
const sellerOk = new Channel("seller-ok", stringCodec);
export class OrderProcessingFlow implements Flow<OrderRequest> {
public readonly charge: Charge;
public readonly ship: Ship;
public readonly refund: Refund;
public constructor(public readonly service: MyDependencyService) {
this.refund = new Refund(service);
this.ship = new Ship(service);
this.charge = new Charge(service);
}
public getFlowType(): string {
return "OrderProcessingFlow";
}
public getSteps() {
return StepList.startStep(this.charge).otherSteps(this.ship, this.refund);
}
public getPersistenceSchema(): PersistenceSchema {
return {
attributes: [orderStatus],
channels: [sellerOk],
};
}
@rpc({ inputCodec: stringCodec, outputCodec: stringCodec })
public approve(context: Context, _note: string): RPCResult<string> {
sellerOk.publish(context, "approved");
return { output: "ok" };
}
@rpc({ outputCodec: stringCodec })
public describe(context: Context): RPCResult<string> {
return { output: orderStatus.get(context) };
}
}
class Charge implements Step<OrderRequest> {
public readonly inputCodec = orderRequestCodec;
public constructor(private readonly service: MyDependencyService) {}
public getStepType(): string {
return "Charge";
}
public getStepOptions() {
}
public execute(context: Context, input: OrderRequest): StepDecision {
this.service.chargeUser(input.email, input.customerId, input.amount, `charge-${input.orderId}`);
orderStatus.set(context, "charged");
return goTo(Ship, input);
}
}
class Ship implements Step<OrderRequest> {
public readonly inputCodec = orderRequestCodec;
public constructor(private readonly service: MyDependencyService) {}
public getStepType(): string {
return "Ship";
}
public getStepOptions() {
}
public waitFor(_context: Context, _input: OrderRequest): Wait {
return Wait.anyOf(sellerOk.forOne(), Timer.byDuration(DAY_MS));
}
public execute(context: Context, input: OrderRequest): StepDecision {
if (context.hasTimerFired()) {
this.service.sendEmail(
input.email,
"Reminder: approve shipment",
"Please approve or provide a tracking number.",
);
return goTo(Ship, input);
}
this.service.shipItem(input.orderId, input.testFailAtShipping, `ship-${input.orderId}`);
orderStatus.set(context, "shipped");
return gracefulComplete(`shipped:${input.orderId}`);
}
}
class Refund implements Step<OrderRequest> {
public readonly inputCodec = orderRequestCodec;
public constructor(private readonly service: MyDependencyService) {}
public getStepType(): string {
return "Refund";
}
public execute(context: Context, input: OrderRequest): StepDecision {
this.service.updateExternalSystem(`refund ${input.orderId}`, `refund-${input.orderId}`);
orderStatus.set(context, "refunded");
return gracefulComplete(`refunded:${input.orderId}`);
}
}
Example: examples/typescript/src/products/order-processing/order-processing-flow.ts
#[derive(Clone)]
pub struct OrderProcessingFlow {
charge: Charge,
ship: Ship,
refund: Refund,
}
impl OrderProcessingFlow {
pub fn new(service: MyDependencyService) -> Self {
Self {
charge: Charge {
service: service.clone(),
},
ship: Ship {
service: service.clone(),
},
refund: Refund { service },
}
}
fn approve(&self, context: &mut Context, _note: String) -> HandlerResult<RpcResult<String>> {
SELLER_OK.publish(context, "approved".to_string())?;
Ok(RpcResult::new("ok".to_string()))
}
fn describe(&self, context: &mut Context) -> HandlerResult<RpcResult<String>> {
Ok(RpcResult::new(ORDER_STATUS.get_required(context)?))
}
}
impl Default for OrderProcessingFlow {
fn default() -> Self {
Self::new(MyDependencyService::default())
}
}
impl Flow for OrderProcessingFlow {
type StartInput = OrderRequest;
fn flow_type(&self) -> &'static str {
"OrderProcessingFlow"
}
fn steps(&self) -> StepList<'_, Self::StartInput> {
StepList::start(&self.charge)
.and(&self.ship)
.and(&self.refund)
}
fn persistence(&self) -> PersistenceSchema {
PersistenceSchema::new()
.attribute(&ORDER_STATUS)
.channel(&SELLER_OK)
}
fn rpcs(&self) -> RpcList<Self> {
RpcList::new()
.function(APPROVE_ORDER, Self::approve)
.function_without_input(DESCRIBE_ORDER, Self::describe)
}
}
#[derive(Clone, Default)]
pub struct Charge {
service: MyDependencyService,
}
impl Step for Charge {
type Input = OrderRequest;
fn step_type(&self) -> &'static str {
"ChargeStep"
}
fn options(&self) -> StepOptions<Self::Input> {
}
fn execute(&self, context: &mut Context, input: Self::Input) -> HandlerResult<StepDecision> {
self.service.charge_user_with_idempotency_key(
&input.email,
&input.customer_id,
input.amount,
&format!("charge-{}", input.order_id),
);
context.record_event("charge", input.order_id.clone())?;
ORDER_STATUS.set(context, "charged".to_string())?;
Ok(StepDecision::go_to(&Ship::default(), input))
}
}
#[derive(Clone, Default)]
pub struct Ship {
service: MyDependencyService,
}
impl Step for Ship {
type Input = OrderRequest;
fn step_type(&self) -> &'static str {
"ShipStep"
}
fn options(&self) -> StepOptions<Self::Input> {
}
fn wait_for(&self, _context: &mut Context, _input: Self::Input) -> HandlerResult<Wait> {
Ok(Wait::any_of([
SELLER_OK.for_one(),
Timer::by_duration(Duration::from_secs(24 * 60 * 60)),
]))
}
fn execute(&self, context: &mut Context, input: Self::Input) -> HandlerResult<StepDecision> {
if context.has_any_timer_fired() {
self.service.send_email(
&input.email,
"Reminder: approve shipment",
"Please approve or provide a tracking number.",
);
context.record_event("shipment-reminder", input.order_id.clone())?;
return Ok(StepDecision::go_to(&Ship::default(), input));
}
self.service.ship_item_with_idempotency_key(
&input.order_id,
input.test_fail_at_shipping,
&format!("ship-{}", input.order_id),
)?;
context.record_event("ship", input.order_id.clone())?;
ORDER_STATUS.set(context, "shipped".to_string())?;
Ok(StepDecision::graceful_complete(format!(
"shipped:{}",
input.order_id
)))
}
}
#[derive(Clone, Default)]
pub struct Refund {
service: MyDependencyService,
}
impl Step for Refund {
type Input = OrderRequest;
fn step_type(&self) -> &'static str {
"RefundStep"
}
fn options(&self) -> StepOptions<Self::Input> {
}
fn execute(&self, context: &mut Context, input: Self::Input) -> HandlerResult<StepDecision> {
self.service.update_external_system_with_idempotency_key(
&format!("refund {}", input.order_id),
&format!("refund-{}", input.order_id),
);
context.record_event("refund", input.order_id.clone())?;
ORDER_STATUS.set(context, "refunded".to_string())?;
Ok(StepDecision::graceful_complete(format!(
"refunded:{}",
input.order_id
)))
}
}
static ORDER_STATUS: LazyLock<Attribute<String>> = LazyLock::new(|| {
Attribute::new("order-status").indexed(AttributeIndex::keyword().with_key("keyword1"))
});
static SELLER_OK: LazyLock<Channel<String>> = LazyLock::new(|| Channel::new("seller-ok"));
Example: examples/rust/src/products/order_processing/flow.rs
The HTTP handlers
The examples application runs the Worker and these handlers in one process. start starts the Flow and returns once Charge completes, using the Client's wait-for-Step-completion API. approve and describe call the RPCs of the same names.
@blueprint.get("/start")
async def start() -> Response:
flow_id = new_flow_id("order-processing")
request = OrderRequest(
flow_id,
"buyer@example.com",
"customer-1",
42,
optional_query("testFailAtShipping", "") == "true",
)
run_id = await app_state.client.start_flow(
app_state.order_processing,
flow_id,
request,
start_options(),
)
await app_state.client.wait_for_step_completion(
flow_id,
CHARGE_STEP,
WaitForStepCompletionOptions(),
)
return started_flow(flow_id, run_id)
@blueprint.get("/approve")
async def approve() -> Response:
output = await app_state.client.invoke_rpc(
app_state.order_processing.approve,
_required_flow_id(),
optional_query("notes", ""),
)
return jsonify(output)
@blueprint.get("/describe")
async def describe() -> Response:
flow_id = _required_flow_id()
status = await app_state.client.invoke_rpc(
app_state.order_processing.describe,
flow_id,
)
return jsonify({"flowID": flow_id, "status": status})
return blueprint
def _required_flow_id() -> str:
"""Reads the Flow ID from flowId, or from its alias workflowId."""
return optional_query("workflowId", "") or required_query("flowId")
Example: examples/python/dex_examples/products/order-processing/controller.py
func RegisterRoutes(router gin.IRouter, client *sdk.Client, flow *OrderProcessingFlow) {
controller := &controller{client: client, flow: flow}
group := router.Group("/products/order-processing")
group.GET("/start", controller.start)
group.GET("/approve", controller.approve)
group.GET("/describe", controller.describe)
}
func (controller *controller) start(request *gin.Context) {
flowID := httputil.NewFlowID("order-processing")
input := OrderRequest{
OrderID: flowID,
Email: "buyer@example.com",
CustomerID: "customer-1",
Amount: 42,
TestFailAtShipping: request.Query("testFailAtShipping") == "true",
}
runID, err := controller.client.StartFlow(
request.Request.Context(),
controller.flow,
flowID,
input,
sdk.StartFlowOptions{},
)
if err != nil {
httputil.Respond(request, nil, err)
return
}
waitContext, cancelWait := context.WithTimeout(request.Request.Context(), 5*time.Minute)
defer cancelWait()
Example: examples/go/products/order-processing/controller.go
@RestController
@RequestMapping("/products/order-processing")
public class OrderProcessingController {
private final Client client;
private final OrderProcessingFlow flow;
public OrderProcessingController(
final Client client,
final OrderProcessingFlow flow) {
this.client = client;
this.flow = flow;
}
@GetMapping("/start")
public ResponseEntity<Map<String, String>> start(
@RequestParam(defaultValue = "false") final boolean testFailAtShipping) {
final String flowId = "order-processing-" + System.nanoTime();
final OrderRequest request = new OrderRequest(
flowId,
"buyer@example.com",
"customer-1",
42,
testFailAtShipping);
final String runId = client.startFlow(flow, flowId, request, ExampleFlows.startOptions());
client.waitForStepCompletion(
flowId,
StepExecutionId.of("Charge"),
WaitForStepCompletionOptions.newBuilder().build());
final Map<String, String> response = new LinkedHashMap<String, String>();
response.put("flowID", flowId);
export function createOrderProcessingRouter(
client: Client,
flow: OrderProcessingFlow,
): Router {
const router = Router();
router.get("/start", async (request, response) => {
const flowId = `order-processing-${process.hrtime.bigint()}`;
const input: OrderRequest = {
orderId: flowId,
email: "buyer@example.com",
customerId: "customer-1",
amount: 42,
testFailAtShipping: String(request.query.testFailAtShipping ?? "") === "true",
};
const runId = await client.startFlow(flow, flowId, input, startOptions());
await client.waitForStepCompletion(
flowId,
StepExecutionId.of("Charge"),
{},
);
response.json({ flowID: flowId, runID: runId });
});
router.get("/approve", async (request, response) => {
const flowId = flowIdFromQuery(request.query);
const notes = String(request.query.notes ?? "");
const output = await client.invokeRPC(flow.approve, flowId, notes);
response.json(output);
});
router.get("/describe", async (request, response) => {
const flowId = flowIdFromQuery(request.query);
const status = await client.invokeRPC(flow.describe, flowId);
response.json({ flowID: flowId, status });
});
return router;
}
/** Reads the Flow ID from flowId, or from its alias workflowId. */
function flowIdFromQuery(query: Record<string, unknown>): string {
return String(query.workflowId ?? query.flowId ?? "");
}
Example: examples/typescript/src/products/order-processing/controller.ts
pub fn mount(client: SharedClient, flow: OrderProcessingFlow) -> Router {
Router::new()
.route("/products/order-processing/start", get(start))
.route("/products/order-processing/approve", get(approve))
.route("/products/order-processing/describe", get(describe))
.with_state(OrderProcessingState { client, flow })
}
async fn start(
State(state): State<OrderProcessingState>,
Query(query): Query<StartQuery>,
) -> impl IntoResponse {
let OrderProcessingState { client, flow } = state;
match run_blocking(move || {
let flow_id = new_flow_id("order-processing");
let input = OrderRequest {
order_id: flow_id.clone(),
email: "buyer@example.com".into(),
customer_id: "customer-1".into(),
amount: 42,
test_fail_at_shipping: query.test_fail_at_shipping,
};
let run_id = client.start_flow(&flow, &flow_id, input)?;
client.wait_for_step_completion(
&flow_id,
StepExecutionId::of(&Charge::default()),
WaitForStepCompletionOptions::new(),
)?;
Ok(StartResponse { flow_id, run_id })
}) {
Example: examples/rust/src/products/order_processing/controller.rs
Run it
Start the examples of one language as in Run an example from the playground. Then start an order:
curl -s 'http://127.0.0.1:8080/products/order-processing/start'
Copy flowID from the response. In Dex Web, at the address dexcli dev prints, such as http://127.0.0.1:8802, the Flow waits in Ship. Approve the shipment, replacing FLOW_ID:
curl -s "http://127.0.0.1:8080/products/order-processing/approve?flowId=FLOW_ID"
The call publishes the approval to seller-ok. Ship then ships the item and the Flow completes; watch it in Dex Web. You can make the same calls from the examples playground: choose Order processing.
Try the refund path
Start an order whose shipping always fails:
curl -s 'http://127.0.0.1:8080/products/order-processing/start?testFailAtShipping=true'
Copy the new flowID and approve it as before. Ship then fails until its 3-second retry budget runs out, and Refund runs. Wait in Dex Web until Refund completes, or repeat this call until the status is refunded:
curl -s "http://127.0.0.1:8080/products/order-processing/describe?flowId=FLOW_ID"
In Dex Web, Events → Graph shows Charge, Ship, and then Refund.
See the run in Dex Web
Open an approved run and select Events. Timeline shows the charge, approval, and shipment in order; select an event to read its input and output. Graph shows how the Steps connect.
Next
- Subscription and Billing Lifecycle: the next example.
- Concepts: the Flow, Step, Channel, and Timer this example uses.
- Application: add a Worker and a Client to your own service.
- Examples: more examples.

