With the Payments Library it’s easy for users and AI agents to buy Payment Plans. The user only needs to hold sufficient balance in the plan currency (set on plan creation). With Nevermined, Plan creators can set payments currency to any valid ERC-20 or native token. Payment Plans can also be purchased in fiat (via Stripe or Braintree). The fiat checkout flow requires a credit card and is fully integrated into the Nevermined Web App. The active payment provider is selected per plan via the seller’sDocumentation Index
Fetch the complete documentation index at: https://docs.nevermined.app/llms.txt
Use this file to discover all available pages before exploring further.
fiatPaymentProvider metadata at registration time. Nevermined likes to recommend stablecoin payments — that way the payment and fetching of credits associated with the Payment Plan can be done in a single step.
Buying a Plan
- TypeScript
- Python
Buying Plans with Fiat (Stripe or Braintree)
When the Payment Plan requires a payment in fiat, the payment is finalised in the Nevermined App. The app handles the checkout flow for the seller’s chosen provider (Stripe Checkout or Braintree Drop-in) and returns the user to the application that initiated the purchase flow. The SDK exposes a programmatic order method (orderFiatPlan) for Stripe-priced plans, which redirects the buyer to a Stripe Checkout session. Braintree-priced plans are checked out exclusively through the Nevermined App’s Drop-in flow — there is no SDK-level order method for Braintree today; link buyers to the plan’s purchase page on nevermined.app instead.
- TypeScript
- Python
Checking the Credit Balance of a Payment Plan
After a user purchases a plan, they can check their balance for that plan. The balance represents the number of credits the user has available to use within the plan.Time-based plans provide a balance of 1 credit for subscribers. When the plan expires, this balance will be zero.
- TypeScript
- Python
Understanding Plan Types and Balances
Credits-Based Plans
Users receive a specific number of credits upon purchase. Each API call consumes credits based on your pricing configuration.
Time-Based Plans
Users receive 1 credit that grants unlimited access for the specified duration. Balance becomes 0 when expired.
Payment Flow Examples
Complete Purchase Flow
Initiate Purchase
Call
payments.plans.orderPlan() or payments.plans.orderFiatPlan() depending on payment methodComplete Payment
For crypto: transaction is processed on-chain and happens in one transaction.
For fiat: user completes Stripe checkout, and the credits will be distributed automatically after the payment.
Verify Purchase
Check balance to confirm the plan was successfully purchased and get the balance. Call
payments.plans.getPlanBalance().Error Handling
- TypeScript
- Python
Best Practices for Plan Purchasing
User Experience
User Experience
- Always show clear pricing and what users get for their purchase
- Create different plans for crypto and fiat payments if you want to support both
- Show plan benefits and limitations clearly
Error Handling
Error Handling
- Handle network failures gracefully with retry mechanisms
- Provide clear error messages for common issues
- Allow users to check their balance before making additional purchases
- Implement transaction status checking for pending purchases
Security
Security
- Never store private keys or sensitive wallet information
- Validate plan purchases on the backend before granting access
- Implement rate limiting to prevent abuse
- Log purchase events for audit trails
Next Steps
After users purchase plans, they can:Query AI Agents
Learn how to access AI services with purchased plans
Handle Requests
Learn how to process requests and manage responses