One-time initialization to set admin, treasury, and auth account.
fn initialize(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
treasury: soroban_sdk::Address,
auth: soroban_sdk::Address,
)
Subscribe user to the plan plan_id by paying the plan price in XLM to the treasury.
If user already has an active subscription to the same plan, extend the expiration date.
fn subscribe(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
plan_id: u32,
price: i128,
)
Check if a given user currently has an active (unexpired) subscription.
fn is_sub_active(env: soroban_sdk::Env, user: soroban_sdk::Address) -> bool
Retrieve the subscription details of a user, if any.
fn get_subscription(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
) -> Option
Create a new subscription plan (admin only).
fn create_plan(env: soroban_sdk::Env, plan_id: u32, price: i128, duration: u64)
Update an existing subscription plan's price and/or duration (admin only).
fn update_plan(env: soroban_sdk::Env, plan_id: u32, new_price: i128, new_duration: u64)
Get details of a subscription plan by ID (anyone can call).
fn get_plan(env: soroban_sdk::Env, plan_id: u32) -> Option
Delete a subscription plan (admin only).
fn delete_plan(env: soroban_sdk::Env, plan_id: u32)
Update the treasury account address (admin only).
fn update_treasury(env: soroban_sdk::Env, new_treasury: soroban_sdk::Address)