Contract 5ec0aa5d710f80b9d77ad2da4b79f1babc34d6bc1912ce5043a9edb71c7e725a

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.10#9a1b75b509a5053b676b09fdbd224fe8c5f2fcd5
rsver 1.90.0

Instances

  • CCL6SIILAWKOMCR2FGTTDKIGJNDU3KY5LZCRMNG4JPLYDQSCKVTLGSEP

Interface

Initial call by customer. Bundles approval + first payment + subscription creation. duration is in seconds (e.g. 86400 = 1 day, 3600 = 1 hour for custom periods).

fn start(
    env: soroban_sdk::Env,
    customer: soroban_sdk::Address,
    merchant: soroban_sdk::Address,
    token: soroban_sdk::Address,
    product_id: soroban_sdk::String,
    amount: i128,
    duration: u64,
    caller: soroban_sdk::Address,
)

Called by backend/cron when the billing period ends. amount is computed off-chain from current fiat/crypto rates each cycle. Panics on insufficient funds — period_end is NOT advanced on failure.

fn charge(
    env: soroban_sdk::Env,
    customer: soroban_sdk::Address,
    product_id: soroban_sdk::String,
    amount: i128,
)
fn pause(
    env: soroban_sdk::Env,
    customer: soroban_sdk::Address,
    product_id: soroban_sdk::String,
    caller: soroban_sdk::Address,
)

Resume a paused subscription. If the paused period already expired, resets period_end from now so the customer gets a full cycle without immediately triggering charge.

fn resume(
    env: soroban_sdk::Env,
    customer: soroban_sdk::Address,
    product_id: soroban_sdk::String,
    caller: soroban_sdk::Address,
)
fn cancel(
    env: soroban_sdk::Env,
    customer: soroban_sdk::Address,
    product_id: soroban_sdk::String,
    caller: soroban_sdk::Address,
)

Admin / backend override. Validates status and guards against zero duration.

fn update(
    env: soroban_sdk::Env,
    customer: soroban_sdk::Address,
    product_id: soroban_sdk::String,
    status: soroban_sdk::String,
    period_duration: u64,
    period_end: u64,
    caller: soroban_sdk::Address,
)
fn get_subscription(
    env: soroban_sdk::Env,
    customer: soroban_sdk::Address,
    product_id: soroban_sdk::String,
) -> Subscription

Imports

WebAssembly Text (WAT) ▶