squareup 2.13.0

Rust SDK for the Square Developer API
Documentation
//! Model struct for Payment type

use super::{
    Address, ApplicationDetails, BankAccountPaymentDetails, BuyNowPayLaterDetails,
    CardPaymentDetails, CashPaymentDetails, DateTime, DeviceDetails, DigitalWalletDetails,
    ExternalPaymentDetails, Money, ProcessingFee, RiskEvaluation, SquareAccountDetails,
    enums::{PaymentCapability, PaymentDelayAction, PaymentSourceType, PaymentStatus},
};
use crate::models::offline_payment_details::OfflinePaymentDetails;
use serde::{Deserialize, Serialize};

/// Represents a payment processed by the Square API.
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct Payment {
    /// **Read only** A unique ID for the payment.
    pub id: Option<String>,
    /// **Read only** The timestamp of when the payment was created.
    pub created_at: Option<DateTime>,
    /// **Read only** The timestamp of when the payment was last updated.
    pub updated_at: Option<DateTime>,
    /// The amount processed for this payment, not including `tip_money`.
    ///
    /// The amount is specified in the smallest denomination of the applicable currency (for
    /// example, US dollar amounts are specified in cents). For more information, see [Working with
    /// Monetary
    /// Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts).
    pub amount_money: Option<Money>,
    /// The amount designated as a tip.
    ///
    /// This amount is specified in the smallest denomination of the applicable currency (for
    /// example, US dollar amounts are specified in cents). For more information, see [Working with
    /// Monetary
    /// Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts).
    pub tip_money: Option<Money>,
    /// **Read only** The total amount for the payment, including `amount_money` and `tip_money`.
    /// This amount is specified in the smallest denomination of the applicable currency (for
    /// example, US dollar amounts are specified in cents). For more information, see [Working with
    /// Monetary
    /// Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts).
    pub total_money: Option<Money>,
    /// The amount the developer is taking as a fee for facilitating the payment on behalf of the
    /// seller. This amount is specified in the smallest denomination of the applicable currency
    /// (for example, US dollar amounts are specified in cents). For more information, see [Take
    /// Payments and Collect
    /// Fees](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees).
    ///
    /// The amount cannot be more than 90% of the `total_money` value.
    ///
    /// To set this field, `PaymentsWriteAdditionalRecipients` OAuth permission is required. For
    /// more information, see
    /// [Permissions](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees#permissions).
    pub app_fee_money: Option<Money>,
    /// The initial amount of money approved for this payment.
    pub approved_money: Option<Money>,
    /// **Read only** The processing fees and fee adjustments assessed by Square for this payment.
    pub processing_fee: Option<Vec<ProcessingFee>>,
    /// **Read only** The total amount of the payment refunded to date.
    ///
    /// This amount is specified in the smallest denomination of the applicable currency (for
    /// example, US dollar amounts are specified in cents).
    pub refunded_money: Option<Money>,
    /// **Read only** The payment's current status.
    pub status: Option<PaymentStatus>,
    /// **Read only** The duration of time after the payment's creation when Square automatically
    /// applies the `delay_action` to the payment. This automatic `delay_action` applies only to
    /// payments that do not reach a terminal state (COMPLETED, CANCELED, or FAILED) before the
    /// `delay_duration` time period.
    ///
    /// This field is specified as a time duration, in RFC 3339 format.
    ///
    /// Notes: This feature is only supported for card payments.
    ///
    /// Default:
    /// * Card-present payments: "PT36H" (36 hours) from the creation time.
    /// * Card-not-present payments: "P7D" (7 days) from the creation time.
    ///
    /// Example for 2 days, 12 hours, 30 minutes, and 15 seconds: P2DT12H30M15S
    pub delay_duration: Option<String>,
    /// **Read only** The action to be applied to the payment when the `delay_duration` has elapsed.
    /// This field is read-only.
    pub delay_action: Option<PaymentDelayAction>,
    /// **Read only** The read-only timestamp of when the `delay_action` is automatically applied.
    ///
    /// Note that this field is calculated by summing the payment's `delay_duration` and
    /// `created_at` fields. The `created_at` field is generated by Square and might not exactly
    /// match the time on your local machine.
    pub delayed_until: Option<DateTime>,
    /// **Read only** The source type for this payment.
    ///
    /// For information about these payment source types, see [Take
    /// Payments](https://developer.squareup.com/docs/payments-api/take-payments).
    pub source_type: Option<PaymentSourceType>,
    /// **Read only** Details about a card payment. These details are only populated if the
    /// `source_type` is `CARD`.
    pub card_details: Option<CardPaymentDetails>,
    /// Details about a cash payment. These details are only populated if the `source_type` is
    /// `CASH`.
    pub cash_details: Option<CashPaymentDetails>,
    /// **Read only** Details about a bank account payment. These details are only populated if the
    /// `source_type` is `BANK_ACCOUNT`.
    pub bank_account_details: Option<BankAccountPaymentDetails>,
    /// **Read only** Details about an external payment. The details are only populated if the
    /// `source_type` is `EXTERNAL`.
    pub external_details: Option<ExternalPaymentDetails>,
    /// **Read only** Details about an wallet payment. The details are only populated if the
    /// `source_type` is `WALLET`.
    pub wallet_details: Option<DigitalWalletDetails>,
    /// **Read only** Details about a Buy Now Pay Later payment. The details are only populated if
    /// the `source_type` is `BuyNowPayLater`. For more information, see [Afterpay
    /// Payments](https://developer.squareup.com/docs/payments-api/take-payments/afterpay-payments).
    pub buy_now_pay_later_details: Option<BuyNowPayLaterDetails>,
    /// **Read only** Details about a Square Account payment. The details are only populated if the
    /// source_type is SquareAccount.
    pub square_account_details: Option<SquareAccountDetails>,
    /// **Read only** The ID of the location associated with the payment.
    pub location_id: Option<String>,
    /// **Read only** The ID of the [Order] associated with the payment.
    pub order_id: Option<String>,
    /// **Read only** An optional ID that associates the payment with an entity in another system.
    pub reference_id: Option<String>,
    /// **Read only** The [Customer] ID of the customer associated with the payment.
    pub customer_id: Option<String>,
    /// **Read only Deprecated:** Use `Payment.team_member_id` instead.
    ///
    /// An optional ID of the employee associated with taking the payment.
    #[deprecated]
    pub employee_id: Option<String>,
    /// **Read only** An optional ID of the [TeamMember] associated with taking the payment.
    pub team_member_id: Option<String>,
    /// **Read only** A list of `refund_ids` identifying refunds for the payment.
    pub refund_ids: Option<Vec<String>>,
    /// **Read only** Provides information about the risk associated with the payment, as determined
    /// by Square. This field is present for payments to sellers that have opted in to receive risk
    /// evaluations.
    pub risk_evaluation: Option<RiskEvaluation>,
    /// **Read only** An optional ID for a Terminal checkout that is associated with the payment.
    pub terminal_checkout_id: Option<String>,
    /// **Read only** The buyer's email address.
    pub buyer_email_address: Option<String>,
    /// **Read only** The buyer's billing address.
    pub billing_address: Option<Address>,
    /// **Read only** The buyer's shipping address.
    pub shipping_address: Option<Address>,
    /// **Read only** An optional note to include when creating a payment.
    pub note: Option<String>,
    /// **Read only** Additional payment information that gets added to the customer's card
    /// statement as part of the statement description.
    ///
    /// Note that the `statement_description_identifier` might get truncated on the statement
    /// description to fit the required information including the Square identifier (SQ *) and the
    /// name of the seller taking the payment.
    pub statement_description_identifier: Option<String>,
    /// **Read only** Actions that can be performed on this payment.
    pub capabilities: Option<Vec<PaymentCapability>>,
    /// **Read only** The payment's receipt number. The field is missing if a payment is canceled.
    pub receipt_number: Option<String>,
    /// **Read only** The URL for the payment's receipt. The field is only populated for COMPLETED
    /// payments.
    pub receipt_url: Option<String>,
    /// **Read only** Details about the device that took the payment.
    pub device_details: Option<DeviceDetails>,
    /// **Read only** Details about the application that took the payment.
    pub application_details: Option<ApplicationDetails>,
    /// **Read only** Whether or not this payment was taken offline.
    pub is_offline_payment: Option<bool>,
    /// **Read only** Additional information about the payment if it was taken offline.
    pub offline_payment_details: Option<OfflinePaymentDetails>,
    /// Used for optimistic concurrency. This opaque token identifies a specific version of the
    /// `Payment` object.
    pub version_token: Option<String>,
}