Contract 0d13bf394ddeeeb0b2059bccbf34e74be1aaf74a7af3ed7dcc5c01718850a398

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.11#34f7f53ae31e0fd02aab436a9872e79fa671ca02
rsver 1.93.0

Instances

  • CBP3DPJXCSRU6AURUYC2WF6SGNEAB5ECMPBQY33SLTZOBUZJBRWHAQGN

Interface

Emergency pause.

fn pause(env: soroban_sdk::Env) -> Result<(), FactoryError>

Resume after pause.

fn unpause(env: soroban_sdk::Env) -> Result<(), FactoryError>

Get a plan by its ID.

fn get_plan(
    env: soroban_sdk::Env,
    plan_id: soroban_sdk::String,
) -> Result

Initialize the Subscription Factory with an admin address.

fn initialize(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
) -> Result<(), FactoryError>

Create a new subscription plan.

Arguments

  • merchant — The merchant creating the plan
  • name — Human-readable plan name
  • description — Plan description
  • amount — Price per billing period
  • token — Token contract address
  • interval — Billing interval in seconds
  • max_payments — Maximum number of payments (0 = infinite)
  • metadata_uri — IPFS URI for additional metadata

Security

  • Requires merchant authentication
  • Validates all inputs
  • Generates unique plan ID
fn create_plan(
    env: soroban_sdk::Env,
    merchant: soroban_sdk::Address,
    name: soroban_sdk::String,
    description: soroban_sdk::String,
    amount: i128,
    token: soroban_sdk::Address,
    interval: u64,
    max_payments: u32,
    metadata_uri: soroban_sdk::String,
) -> Result

Get total number of plans.

fn total_plans(env: soroban_sdk::Env) -> u32

Update an existing plan. Only the plan owner (merchant) can update.

Security

  • Requires merchant auth
  • Only the original creator can update
  • Cannot change merchant or plan_id
fn update_plan(
    env: soroban_sdk::Env,
    merchant: soroban_sdk::Address,
    plan_id: soroban_sdk::String,
    name: soroban_sdk::String,
    description: soroban_sdk::String,
    amount: i128,
    interval: u64,
    max_payments: u32,
    metadata_uri: soroban_sdk::String,
) -> Result

Deactivate a plan — prevents new subscriptions but existing ones continue.

Security

  • Only the plan owner can deactivate
fn deactivate_plan(
    env: soroban_sdk::Env,
    merchant: soroban_sdk::Address,
    plan_id: soroban_sdk::String,
) -> Result<(), FactoryError>

Reactivate a previously deactivated plan.

fn reactivate_plan(
    env: soroban_sdk::Env,
    merchant: soroban_sdk::Address,
    plan_id: soroban_sdk::String,
) -> Result<(), FactoryError>

List all plans for a merchant.

fn list_merchant_plans(
    env: soroban_sdk::Env,
    merchant: soroban_sdk::Address,
) -> soroban_sdk::Vec

Decrement subscriber count (called by Payment Engine on cancellation).

fn decrement_subscribers(
    env: soroban_sdk::Env,
    plan_id: soroban_sdk::String,
) -> Result<(), FactoryError>

Increment subscriber count (called by Payment Engine on new subscription).

fn increment_subscribers(
    env: soroban_sdk::Env,
    plan_id: soroban_sdk::String,
) -> Result<(), FactoryError>

Imports

WebAssembly Text (WAT) ▶