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:| Value | Source | Used By |
|---|---|---|
checkout_session | createCheckoutSession response | createPayment |
payment_id | createPayment response | capturePayment, refundPayment, cancelPayment, getPayment |
customer_id | createCustomer response | createCheckoutSession (optional) |
recipient_id | createRecipient response | createPayout |
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
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.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).Code Example
Workflow 2: Authorize and Capture Flow
For merchants who need to authorize first, then capture after fulfillment.Sequence Diagram
Decision Points
| Condition | Action |
|---|---|
Payment status = AUTHORIZED | Proceed to capture or cancel decision |
Payment status = DECLINED | Do not retry capture; investigate decline reason |
| Capture amount < authorized amount | Partial capture is supported |
| Authorization expired (typically 7 days) | Cannot capture; must create new payment |
Code Example
Workflow 3: Refund with Retry Flow
Process refunds with built-in retry logic for transient failures.Sequence Diagram
Step-by-Step Instructions
Verify payment status
Call
getPayment to confirm the payment is in SUCCEEDED status. Refunds cannot be issued for PENDING, DECLINED, or CANCELLED payments.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.Code Example
Workflow 4: Subscription Creation Flow
Create a customer, vault their payment method, and process recurring payments.Sequence Diagram
Step-by-Step Instructions
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.Code Example
Workflow 5: BaaS Entity Onboarding Flow
Onboard a recipient and process their first payout.Sequence Diagram
Step-by-Step Instructions
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.Code Example
Error Boundaries Summary
Every workflow step has defined error boundaries. Here is the consolidated recovery matrix:| Step | Retryable Errors | Non-Retryable Errors | Recovery Action |
|---|---|---|---|
| Create session | 500, 503, 429 | 400, 401 | Fix payload or credentials |
| Create payment | 500, 503, 429 | 400, 403 | Validate fields, check enablement |
| Capture payment | 500, 503 | 400 (wrong status) | Verify payment is AUTHORIZED |
| Refund payment | 500, 503 | 400 (exceeds balance) | Check remaining refundable amount |
| Create recipient | 500, 503 | 400 | Validate document and bank details |
| Create payout | 500, 503 | 400, 403 | Verify recipient exists and is active |