Overview
The payment flow consists of:- Discovering Plans: Browse available payment plans for agents
- Ordering Plans: Purchase a plan to receive credits
- Checking Balance: Monitor available credits and access status
Get Plan Balance
Subscribers can check their available credits for a specific plan:Balance Response Structure
The balance response contains:Working with Balance
Order a Plan
Subscribers purchase plans to receive credits:Crypto Payment
For plans priced in cryptocurrency:Fiat Payment (Stripe)
For plans priced in fiat currency, useorderFiatPlan to get a Stripe checkout URL:
CLI
Note: When using X402 card-delegation tokens (nvm:card-delegation scheme), the payment is handled automatically through the delegated card — no separate checkout URL is needed. See Querying an Agent for details on card-delegation tokens.
Complete Purchase Flow
Waiting for Balance Updates
After ordering a plan, credits are allocated on-chain, which may take a few seconds:Check Multiple Plan Balances
If a subscriber has multiple plans:Stripe Checkout Integration
Stripe checkout for fiat-priced plans is managed through the Nevermined App dashboard. Visit nevermined.app to configure Stripe payments for your plans.Plan Information
Before ordering, subscribers might want to view plan details:Complete Example: Purchase Flow with UI
Best Practices
- Check Balance First: Always check existing balance before ordering
- Wait for Settlement: Allow time for on-chain credit allocation after purchase
- Handle Errors: Wrap order operations in try-catch blocks
- User Feedback: Provide clear feedback during the purchase process
- Balance Monitoring: Check balance before each agent request
- Stripe Redirects: Use absolute URLs for Stripe success/cancel URLs
Related Documentation
- Payment Plans - Understanding plan types and pricing
- Querying an Agent - Using credits to access agents
Source References:
src/api/plans-api.ts(orderPlan, getPlanBalance methods)tests/e2e/test_payments_e2e.test.ts(ordering and balance verification)