Skip to main content
Loading navigation
Back to prompt library

Define Mastra AI Payment Routing Workflow

Linked challenge: Low-Latency Payment Routing and Fraud Risk Engine with Mastra AI

Prompt source

implementation14 lines3 sectionsNo variables0 checklist items
import { Workflow, Step } from '@mastra/core';
import { z } from 'zod';

const routeStep = new Step({
  id: 'evaluate-rails',
  inputSchema: z.object({ amount: z.number(), currency: z.string() }),
  outputSchema: z.object({ optimalRail: z.string(), fee: z.number() }),
  execute: async ({ context }) => {
    // Call BentoML risk service and evaluate optimal rail
    return { optimalRail: 'STRIPE_EU', fee: 0.85 };
  }
});

export const paymentWorkflow = new Workflow('payment-router')
  .step(routeStep)
  .commit();