Reference Guide. These orchestration patterns work with any MCP-compatible AI tool or custom agent implementation. No Yuno-specific SDK required.
Overview
This guide documents multi-step orchestration workflows for AI agents integrating with Yuno’s payment APIs. Each workflow includes a dependency graph, step-by-step instructions, error boundaries, and code examples.These workflows assume the agent has access to Yuno MCP tools or direct API access. See MCP Tool Reference for tool specifications and Error Recovery for failure handling patterns.
Tool Dependency Graph
Before executing any workflow, agents must understand which API calls depend on prior calls.
Legend:
- Solid arrows: strict dependency (must complete before next step)
- Dashed arrows: optional dependency (improves flow but not required)
State Management Between Calls
Agents must persist the following values across multi-step workflows:Workflow 1: Standard Checkout Flow
The most common integration pattern: create a session, collect payment, and confirm via webhook.Sequence Diagram
Step-by-Step Instructions
1
Create checkout session
Call
createCheckoutSession with amount, country, and merchant order ID.Required fields: amount.currency, amount.value, country, merchant_order_idError boundary: If this fails with 400, validate the payload schema. If 401, check API credentials.2
Create payment
Extract
checkout_session from Step 1 response. Call createPayment with payment method details.Required fields: checkout_session, payment_method.type, amount, countryError boundary: If 400 with “customer.document required”, add customer document fields for the payment method (e.g., CPF for PIX in Brazil).3
Handle webhook or poll
Wait for
payment.succeeded or payment.failed webhook. If no webhook within 30 seconds, poll getPayment with the payment ID.Error boundary: If payment stays in PENDING for more than 5 minutes, check provider status.Code Example
Workflow 2: Authorize and Capture Flow
For merchants who need to authorize first, then capture after fulfillment.Sequence Diagram
Decision Points
Code Example
Workflow 3: Refund with Retry Flow
Process refunds with built-in retry logic for transient failures.Sequence Diagram
Step-by-Step Instructions
1
Verify payment status
Call
getPayment to confirm the payment is in SUCCEEDED status. Refunds cannot be issued for PENDING, DECLINED, or CANCELLED payments.2
Submit refund
Call
refundPayment with optional amount (omit for full refund) and reason.Error boundary: 400 errors are not retryable (e.g., refund exceeds balance). 500/503 errors should be retried with exponential backoff.3
Confirm refund
Poll
getPayment to verify the status changed to REFUNDED or PARTIALLY_REFUNDED. Listen for refund.succeeded or refund.failed webhooks.Code Example
Workflow 4: Subscription Creation Flow
Create a customer, vault their payment method, and process recurring payments.Sequence Diagram
Step-by-Step Instructions
1
Create customer
Call
createCustomer with email, name, and document. Store the returned customer_id.2
Initial payment with token vaulting
Create a checkout session with the
customer_id. Process the first payment using a card token. The response includes a vaulted_token for future charges.3
Recurring payments
For each billing cycle, create a new checkout session and payment using the
vaulted_token instead of a new card token. This enables charges without re-collecting card details.Code Example
Workflow 5: BaaS Entity Onboarding Flow
Onboard a recipient and process their first payout.Sequence Diagram
Step-by-Step Instructions
1
Create recipient
Call
createRecipient with the seller’s details: name, document, bank account, and country. The merchant_recipient_id should be your internal identifier for deduplication.2
Create payout
Call
createPayout with the recipient_id from Step 1, amount, country, and purpose.3
Verify payout
Poll
getPayout or listen for payout webhooks to confirm the funds were transferred.Code Example
Error Boundaries Summary
Every workflow step has defined error boundaries. Here is the consolidated recovery matrix:
For detailed error recovery patterns, see Agent Error Recovery.