square_api_client/models/
payment.rs

1//! Model struct for Payment type
2
3use serde::{Deserialize, Serialize};
4
5use super::{
6    enums::{PaymentCapability, PaymentDelayAction, PaymentSourceType, PaymentStatus},
7    Address, ApplicationDetails, BankAccountPaymentDetails, BuyNowPayLaterDetails,
8    CardPaymentDetails, CashPaymentDetails, DateTime, DeviceDetails, DigitalWalletDetails,
9    ExternalPaymentDetails, Money, ProcessingFee, RiskEvaluation,
10};
11
12/// Represents a payment processed by the Square API.
13#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
14pub struct Payment {
15    /// **Read only** A unique ID for the payment.
16    pub id: Option<String>,
17    /// **Read only** The timestamp of when the payment was created.
18    pub created_at: Option<DateTime>,
19    /// **Read only** The timestamp of when the payment was last updated.
20    pub updated_at: Option<DateTime>,
21    /// The amount processed for this payment, not including `tip_money`.
22    ///
23    /// The amount is specified in the smallest denomination of the applicable currency (for
24    /// example, US dollar amounts are specified in cents). For more information, see [Working with
25    /// Monetary
26    /// Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts).
27    pub amount_money: Option<Money>,
28    /// The amount designated as a tip.
29    ///
30    /// This amount is specified in the smallest denomination of the applicable currency (for
31    /// example, US dollar amounts are specified in cents). For more information, see [Working with
32    /// Monetary
33    /// Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts).
34    pub tip_money: Option<Money>,
35    /// **Read only** The total amount for the payment, including `amount_money` and `tip_money`.
36    /// This amount is specified in the smallest denomination of the applicable currency (for
37    /// example, US dollar amounts are specified in cents). For more information, see [Working with
38    /// Monetary
39    /// Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts).
40    pub total_money: Option<Money>,
41    /// The amount the developer is taking as a fee for facilitating the payment on behalf of the
42    /// seller. This amount is specified in the smallest denomination of the applicable currency
43    /// (for example, US dollar amounts are specified in cents). For more information, see [Take
44    /// Payments and Collect
45    /// Fees](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees).
46    ///
47    /// The amount cannot be more than 90% of the `total_money` value.
48    ///
49    /// To set this field, `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required. For
50    /// more information, see
51    /// [Permissions](https://developer.squareup.com/docs/payments-api/take-payments-and-collect-fees#permissions).
52    pub app_fee_money: Option<Money>,
53    /// The initial amount of money approved for this payment.
54    pub approved_money: Option<Money>,
55    /// **Read only** The processing fees and fee adjustments assessed by Square for this payment.
56    pub processing_fee: Option<Vec<ProcessingFee>>,
57    /// **Read only** The total amount of the payment refunded to date.
58    ///
59    /// This amount is specified in the smallest denomination of the applicable currency (for
60    /// example, US dollar amounts are specified in cents).
61    pub refunded_money: Option<Money>,
62    /// **Read only** The payment's current status.
63    pub status: Option<PaymentStatus>,
64    /// **Read only** The duration of time after the payment's creation when Square automatically
65    /// applies the `delay_action` to the payment. This automatic `delay_action` applies only to
66    /// payments that do not reach a terminal state (COMPLETED, CANCELED, or FAILED) before the
67    /// `delay_duration` time period.
68    ///
69    /// This field is specified as a time duration, in RFC 3339 format.
70    ///
71    /// Notes: This feature is only supported for card payments.
72    ///
73    /// Default:
74    /// * Card-present payments: "PT36H" (36 hours) from the creation time.
75    /// * Card-not-present payments: "P7D" (7 days) from the creation time.
76    ///
77    /// Example for 2 days, 12 hours, 30 minutes, and 15 seconds: P2DT12H30M15S
78    pub delay_duration: Option<String>,
79    /// **Read only** The action to be applied to the payment when the `delay_duration` has elapsed.
80    /// This field is read-only.
81    pub delay_action: Option<PaymentDelayAction>,
82    /// **Read only** The read-only timestamp of when the `delay_action` is automatically applied.
83    ///
84    /// Note that this field is calculated by summing the payment's `delay_duration` and
85    /// `created_at` fields. The `created_at` field is generated by Square and might not exactly
86    /// match the time on your local machine.
87    pub delayed_until: Option<DateTime>,
88    /// **Read only** The source type for this payment.
89    ///
90    /// For information about these payment source types, see [Take
91    /// Payments](https://developer.squareup.com/docs/payments-api/take-payments).
92    pub source_type: Option<PaymentSourceType>,
93    /// **Read only** Details about a card payment. These details are only populated if the
94    /// `source_type` is `CARD`.
95    pub card_details: Option<CardPaymentDetails>,
96    /// Details about a cash payment. These details are only populated if the `source_type` is
97    /// `CASH`.
98    pub cash_details: Option<CashPaymentDetails>,
99    /// **Read only** Details about a bank account payment. These details are only populated if the
100    /// `source_type` is `BANK_ACCOUNT`.
101    pub bank_account_details: Option<BankAccountPaymentDetails>,
102    /// **Read only** Details about an external payment. The details are only populated if the
103    /// `source_type` is `EXTERNAL`.
104    pub external_details: Option<ExternalPaymentDetails>,
105    /// **Read only** Details about an wallet payment. The details are only populated if the
106    /// `source_type` is `WALLET`.
107    pub wallet_details: Option<DigitalWalletDetails>,
108    /// **Read only** Details about a Buy Now Pay Later payment. The details are only populated if
109    /// the `source_type` is `BUY_NOW_PAY_LATER`. For more information, see [Afterpay
110    /// Payments](https://developer.squareup.com/docs/payments-api/take-payments/afterpay-payments).
111    pub buy_now_pay_later_details: Option<BuyNowPayLaterDetails>,
112    /// **Read only** The ID of the location associated with the payment.
113    pub location_id: Option<String>,
114    /// **Read only** The ID of the [Order] associated with the payment.
115    pub order_id: Option<String>,
116    /// **Read only** An optional ID that associates the payment with an entity in another system.
117    pub reference_id: Option<String>,
118    /// **Read only** The [Customer] ID of the customer associated with the payment.
119    pub customer_id: Option<String>,
120    /// **Read only Deprecated:** Use `Payment.team_member_id` instead.
121    ///
122    /// An optional ID of the employee associated with taking the payment.
123    #[deprecated]
124    pub employee_id: Option<String>,
125    /// **Read only** An optional ID of the [TeamMember] associated with taking the payment.
126    pub team_member_id: Option<String>,
127    /// **Read only** A list of `refund_ids` identifying refunds for the payment.
128    pub refund_ids: Option<Vec<String>>,
129    /// **Read only** Provides information about the risk associated with the payment, as determined
130    /// by Square. This field is present for payments to sellers that have opted in to receive risk
131    /// evaluations.
132    pub risk_evaluation: Option<RiskEvaluation>,
133    /// **Read only** The buyer's email address.
134    pub buyer_email_address: Option<String>,
135    /// **Read only** The buyer's billing address.
136    pub billing_address: Option<Address>,
137    /// **Read only** The buyer's shipping address.
138    pub shipping_address: Option<Address>,
139    /// **Read only** An optional note to include when creating a payment.
140    pub note: Option<String>,
141    /// **Read only** Additional payment information that gets added to the customer's card
142    /// statement as part of the statement description.
143    ///
144    /// Note that the `statement_description_identifier` might get truncated on the statement
145    /// description to fit the required information including the Square identifier (SQ *) and the
146    /// name of the seller taking the payment.
147    pub statement_description_identifier: Option<String>,
148    /// **Read only** Actions that can be performed on this payment.
149    pub capabilities: Option<Vec<PaymentCapability>>,
150    /// **Read only** The payment's receipt number. The field is missing if a payment is canceled.
151    pub receipt_number: Option<String>,
152    /// **Read only** The URL for the payment's receipt. The field is only populated for COMPLETED
153    /// payments.
154    pub receipt_url: Option<String>,
155    /// **Read only** Details about the device that took the payment.
156    pub device_details: Option<DeviceDetails>,
157    /// **Read only** Details about the application that took the payment.
158    pub application_details: Option<ApplicationDetails>,
159    /// Used for optimistic concurrency. This opaque token identifies a specific version of the
160    /// `Payment` object.
161    pub version_token: Option<String>,
162}