1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
//! Model struct for Payment type
use serde::{Deserialize, Serialize};
use super::{
enums::{PaymentCapability, PaymentDelayAction, PaymentSourceType, PaymentStatus},
Address, ApplicationDetails, BankAccountPaymentDetails, BuyNowPayLaterDetails,
CardPaymentDetails, CashPaymentDetails, DateTime, DeviceDetails, DigitalWalletDetails,
ExternalPaymentDetails, Money, ProcessingFee, RiskEvaluation,
};
/// 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, `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` 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 `BUY_NOW_PAY_LATER`. 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** 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** 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>,
/// Used for optimistic concurrency. This opaque token identifies a specific version of the
/// `Payment` object.
pub version_token: Option<String>,
}