ic-papi-api 0.1.1

A payment system for ICP canisters offering paid APIs.
Documentation
//! Payment API error types.
use candid::{CandidType, Deserialize, Principal};
pub use ic_cycles_ledger_client::Account;
use ic_cycles_ledger_client::{TransferFromError, WithdrawFromError};

use crate::caller::TokenAmount;

#[derive(Debug, CandidType, Deserialize, Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum PaymentError {
    UnsupportedPaymentType,
    LedgerUnreachable {
        ledger: Principal,
    },
    LedgerWithdrawFromError {
        ledger: Principal,
        error: WithdrawFromError,
    },
    LedgerTransferFromError {
        ledger: Principal,
        error: TransferFromError,
    },
    InsufficientFunds {
        needed: TokenAmount,
        available: TokenAmount,
    },
    InvalidPatron,
}