Skip to main content

kasapay_core/
instrument.rs

1//! One saved instrument a provider holds, as
2//! [`Provider::instruments`](crate::Provider::instruments) lists it.
3
4use crate::id::InstrumentId;
5use crate::raw::Raw;
6
7/// One instrument a provider holds against a customer.
8///
9/// # Not always a card
10///
11/// Mollie's saved instrument is a mandate against a bank account, not a card
12/// at all, so nothing here assumes one — no brand, no expiry, no last four.
13/// What every provider can answer is an identity, something to show a payer
14/// choosing between saved instruments, and its own untouched response; that
15/// is what this carries. The richer, provider-specific type — iyzico's
16/// `classic::StoredCard`, Stripe's `saved::StoredCard`, Mollie's `Mandate` —
17/// stays on each adapter's own listing method, where it already was, for
18/// whatever more than that a caller working against one provider wants.
19///
20/// Every field is public and the struct is open, for the same reason
21/// [`Charge`](crate::Charge) is: an adapter in someone else's repository has
22/// to be able to build one.
23#[derive(Debug, Clone)]
24pub struct Instrument {
25    /// What a payment names this instrument by.
26    ///
27    /// Half a name at iyzico and PayTR, exactly as [`InstrumentId`]'s own
28    /// documentation says: the `customer` that
29    /// [`Provider::instruments`](crate::Provider::instruments) was asked with
30    /// is the other half, and an adapter's own charging call takes both
31    /// because [`Provider::charge`](crate::Provider::charge) cannot.
32    pub id: InstrumentId,
33    /// Something to show a person choosing between saved instruments — "Visa
34    /// ending 4242", the alias a cardholder gave a card, a mandate's payment
35    /// method.
36    ///
37    /// `None` where the provider answered nothing usable for it, rather than
38    /// a label assembled out of parts that might be missing.
39    pub label: Option<Box<str>>,
40    /// The provider's own answer for this instrument, untouched.
41    pub raw: Raw,
42}