Create and manage payment plans with the Python SDK
plans
result = payments.plans.create_plan( agent_id=agent_id, name='Pro Plan', description='100 queries', price_config=price_config, credits_config=credits_config, access_limit='credits' ) plan_id = result['planId']
from payments_py.plans import get_erc20_price_config, get_fixed_credits_config result = payments.plans.create_plan( agent_id='did:nv:agent-123', name='Pro Plan', description='100 queries for $10', price_config=get_erc20_price_config(10_000_000, usdc_address, builder_address), credits_config=get_fixed_credits_config(100, 1), access_limit='credits' )
result = payments.plans.order_plan(plan_id) tx_hash = result['transactionHash']
result = payments.plans.order_fiat_plan(plan_id) checkout_url = result['url'] # Redirect user to Stripe
balance = payments.plans.get_plan_balance(plan_id) credits_remaining = balance['credits']
result = payments.plans.register_credits_trial_plan( agent_id=agent_id, name='Free Trial', description='10 free queries', credits=10, credits_per_request=1 )
result = payments.plans.register_time_trial_plan( agent_id=agent_id, name='7-Day Trial', description='Full access for 7 days', duration=7 * 24 * 60 * 60 # seconds )
from payments_py.plans import get_erc20_price_config config = get_erc20_price_config( 10_000_000, # amount (with decimals) '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', # token address '0xYour...Address' # receiver address )
from payments_py.plans import get_native_price_config config = get_native_price_config( 1_000_000_000_000_000, # 0.001 ETH '0xYour...Address' )
from payments_py.plans import get_fixed_credits_config config = get_fixed_credits_config( 100, # total credits 1 # credits per request )
from payments_py.plans import get_dynamic_credits_config config = get_dynamic_credits_config( 1, # minimum per request 10 # maximum per request )
from payments_py.plans import get_time_based_config config = get_time_based_config( 30 * 24 * 60 * 60 # 30 days in seconds )
# Create plan parameters { 'agent_id': str, 'name': str, 'description': str, # Optional 'price_config': dict, 'credits_config': dict, # Optional 'time_config': dict, # Optional 'access_limit': str # 'credits' or 'time' } # Order result { 'transactionHash': str, 'agreementId': str, 'success': bool } # Balance { 'credits': int, 'expiresAt': str, # Optional, ISO timestamp 'isActive': bool }