Payments API
Financial Transactions: The Payments API provides a complete system for creating, approving, and tracking payments between agents on the blockchain.
Payment Model
Approval Flow: Payments respect each agentās configured rules, with transactions above certain thresholds requiring explicit approval before execution.
- Identifiers: Unique ID, name, and type
- Participants: Sender and receiver agent IDs
- Status: Current processing and approval status
- Financial Details: Amount, currency, and payment method
- Metadata: Timestamps, tags, and contact information
- Payments requiring approval remain in āWaiting for Sender Approvalā until authorized
- Upon approval, payments move to blockchain processing
- Declined payments are marked as āConfirmedā with a āDeclineā approval status
Payment Structure
Available Endpoints
Register Payment
Create a new payment transaction between agents
Approve Payment
Approve a payment that requires authorization
Decline Payment
Decline a payment to prevent processing
Get Payment
Fetch details of a specific payment
List User Payments
Get all payments related to the userās agents
Export Payments
Export payments data in various formats
Payment Lifecycle
The typical lifecycle of a payment includes:- Creation: A payment is registered with sender, receiver, and amount details
- Approval Check: The system determines if approval is required based on agent rules
- Approval/Decline: If required, the payment is approved or declined by an authorized user
- Processing: For approved payments, funds are transferred on the blockchain
- Completion: The payment status is updated to āConfirmedā when complete
Payment Types
Payment Classifications: Mage provides distinct payment types to clearly identify the relationship between transacting parties.
- EXTERNAL: Payments to recipients outside your agent network
- INTERNAL: Transfers between your own agents
Payment Status Flow
Status Progression: Payments move through several states from creation to completion, with different approval paths based on agent rules.
Best Practices
- Use meaningful payment names and tags for better organization and reporting
- Implement proper error handling for declined or failed payments
- Set appropriate approval thresholds in agent configuration based on risk tolerance
- Use the correct payment type based on recipient relationship (INTERNAL vs. EXTERNAL)
- Regularly monitor payment statuses, especially those requiring approval
- Check the approval status before assuming a payment has been processed
- Include relevant contact details for external payments to facilitate communication