Buying a Plan
Buying Plans with Fiat via Stripe
When the Payment Plan requires a payment in fiat, the payment can be initiated with the libraries, but the final step needs to be done in the Nevermined App. The app will handle the payment in fiat (via Stripe Checkout) and will return the user to the application that initiated the purchase flow. For fiat payments, the process involves redirecting users to a Stripe Checkout session: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.
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
1
Discover Plans
Users browse available payment plans and select one that fits their needs
2
Initiate Purchase
Call
payments.plans.orderPlan()
or payments.plans.orderFiatPlan()
depending on payment method3
Complete 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.
4
Verify Purchase
Check balance to confirm the plan was successfully purchased and get the balance. Call
payments.plans.getPlanBalance()
.5
Access Services
Use the plan to access AI agents and services. Call
payments.agents.getAgentAccessToken()
.Error Handling
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