Emergency pause — halts all operations. Requires admin authentication.
fn pause(env: soroban_sdk::Env) -> Result<(), AuthError>
Revoke authorization for a merchant. Instant and permanent.
user — The subscriber revoking permissionmerchant — The merchant losing permissiontoken — Token contract addressfn revoke(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
merchant: soroban_sdk::Address,
token: soroban_sdk::Address,
) -> Result<(), AuthError>
Resume operations after emergency pause. Requires admin authentication.
fn unpause(env: soroban_sdk::Env) -> Result<(), AuthError>
Grant authorization for a merchant to pull funds.
user — The subscriber granting permissionmerchant — The merchant receiving permissiontoken — Token contract address (e.g., USDC)max_per_payment — Maximum per individual paymenttotal_allowed — Total lifetime allowanceexpiry — Expiration timestamp (0 = no expiry)require_auth)fn authorize(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
merchant: soroban_sdk::Address,
token: soroban_sdk::Address,
max_per_payment: i128,
total_allowed: i128,
expiry: u64,
) -> Result
Initialize the contract with admin and payment engine addresses. Can only be called once.
admin — Admin address (multi-sig recommended)payment_engine — Address of the Payment Engine contractfn initialize(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
payment_engine: soroban_sdk::Address,
) -> Result<(), AuthError>
Record a successful payment against an authorization. RESTRICTED: Only callable by the Payment Engine contract.
user — Subscriber addressmerchant — Merchant addresstoken — Token contract addressamount — Payment amount executedchecked_add for overflow protectionfn record_payment(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
merchant: soroban_sdk::Address,
token: soroban_sdk::Address,
amount: i128,
) -> Result<(), AuthError>
Get authorization details for a user-merchant-token tuple.
fn get_authorization(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
merchant: soroban_sdk::Address,
token: soroban_sdk::Address,
) -> Result
Check if an authorization is valid for a given payment amount. Called by the Payment Engine before executing a payment.
user — Subscriber addressmerchant — Merchant addresstoken — Token contract addressamount — Payment amount to validatetrue if the payment is authorized, error otherwise
fn check_authorization(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
merchant: soroban_sdk::Address,
token: soroban_sdk::Address,
amount: i128,
) -> Result
Update the Payment Engine address. Requires admin authentication.
fn update_payment_engine(
env: soroban_sdk::Env,
new_payment_engine: soroban_sdk::Address,
) -> Result<(), AuthError>
Get all authorizations for a user (returns list of (merchant, token) tuples).
fn get_user_authorizations(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
) -> soroban_sdk::Vec<(soroban_sdk::Address, soroban_sdk::Address)>
Get all authorizations for a merchant (returns list of (user, token) tuples).
fn get_merchant_authorizations(
env: soroban_sdk::Env,
merchant: soroban_sdk::Address,
) -> soroban_sdk::Vec<(soroban_sdk::Address, soroban_sdk::Address)>