ic_papi_api/
vendor.rs

1//! Types used primartily by the vendor of the payment API.
2use candid::{CandidType, Deserialize, Principal};
3pub use ic_cycles_ledger_client::Account;
4
5use crate::caller::TokenAmount;
6
7/// Billing options that may be offered to a customer.
8#[derive(Debug, CandidType, Deserialize, Copy, Clone, Eq, PartialEq)]
9#[non_exhaustive]
10pub enum PaymentOption {
11    /// The caller is paying with cycles attached to the call.
12    ///
13    /// Note: This is available to inter-canister aclls only; not to ingress messages.
14    ///
15    /// Note: The API does not require additional arguments to support this payment type.
16    AttachedCycles { fee: Option<TokenAmount> },
17    /// The caller is paying with cycles from their main account on the cycles ledger.
18    CallerPaysIcrc2Cycles { fee: Option<TokenAmount> },
19    /// A patron is paying, on behalf of the caller, from their main account on the cycles ledger.
20    PatronPaysIcrc2Cycles { fee: Option<TokenAmount> },
21}
22
23/// User's payment details for an ICRC2 payment.
24#[derive(Debug, CandidType, Deserialize, Clone, Eq, PartialEq)]
25pub struct Icrc2Payer {
26    /// The customer's principal and (optionally) subaccount.
27    ///
28    /// By default, the caller's main account is used.
29    pub account: Option<Account>,
30    /// The spender, if different from the payer.
31    pub spender_subaccount: Option<serde_bytes::ByteBuf>,
32    /// The ledger canister ID.
33    ///
34    /// Note: This is included in order to improve error messages if the caller tries to use the wrong ledger.
35    pub ledger_canister_id: Option<Principal>,
36    /// Corresponds to the `created_at_time` field in ICRC2.
37    pub created_at_time: Option<TokenAmount>,
38}