square_api_client/models/
card.rs

1//! Model struct for the Card type
2
3use serde::{Deserialize, Serialize};
4
5use super::{
6    enums::{CardBrand, CardPrepaidType, CardType},
7    Address,
8};
9
10/// Represents the payment details of a card to be used for payments.
11///
12/// These details are determined by the payment token generated by Web Payments SDK.
13#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
14pub struct Card {
15    /// **Read only** Unique ID for this card. Generated by Square.
16    pub id: Option<String>,
17    /// **Read only** The card's brand.
18    pub card_brand: Option<CardBrand>,
19    /// **Read only** The last 4 digits of the card number.
20    pub last_4: Option<String>,
21    /// The expiration month of the associated card as an integer between 1 and 12.
22    pub exp_month: Option<i32>,
23    /// The four-digit year of the card's expiration date.
24    pub exp_year: Option<i32>,
25    /// The name of the cardholder.
26    pub cardholder_name: Option<String>,
27    /// The billing address for this card.
28    pub billing_address: Option<Address>,
29    /// **Read only** Intended as a Square-assigned identifier, based on the card number, to
30    /// identify the card across multiple locations within a single application.
31    pub fingerprint: Option<String>,
32    /// **Required** The ID of a customer created using the Customers API to be associated with the
33    /// card.
34    pub customer_id: Option<String>,
35    /// **Read only** The ID of the merchant associated with the card.
36    pub merchant_id: Option<String>,
37    /// An optional user-defined reference ID that associates this card with another entity in an
38    /// external system. For example, a customer ID from an external customer management system.
39    pub reference_id: Option<String>,
40    /// **Read only** Indicates whether or not a card can be used for payments.
41    pub enabled: Option<bool>,
42    /// **Read only** The type of the card. The Card object includes this field only in response to
43    /// Payments API calls.
44    pub card_type: Option<CardType>,
45    /// **Read only** Indicates whether the Card is prepaid or not. The Card object includes this
46    /// field only in response to Payments API calls.
47    pub prepaid_type: Option<CardPrepaidType>,
48    /// **Read only** The first six digits of the card number, known as the Bank Identification
49    /// Number (BIN). Only the Payments API returns this field.
50    pub bin: Option<String>,
51    /// Current version number of the card. Increments with each card update. Requests to update an
52    /// existing Card object will be rejected unless the version in the request matches the current
53    /// version for the Card.
54    pub version: Option<i32>,
55}