stripe/model/
charge.rs

1use serde::{Serialize, Deserialize};
2use super::{BillingDetails, RadarRadarOptions, RefundList};
3/**The `Charge` object represents a single attempt to move money into your Stripe account.
4PaymentIntent confirmation is the most common way to create Charges, but transferring
5money to a different Stripe account through Connect also creates Charges.
6Some legacy payment flows create Charges directly, which is not recommended for new integrations.*/
7#[derive(Debug, Clone, Serialize, Deserialize, Default)]
8pub struct Charge {
9    ///Amount intended to be collected by this payment. A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or [equivalent in charge currency](https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts). The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99).
10    pub amount: i64,
11    ///Amount in cents (or local equivalent) captured (can be less than the amount attribute on the charge if a partial capture was made).
12    pub amount_captured: i64,
13    ///Amount in cents (or local equivalent) refunded (can be less than the amount attribute on the charge if a partial refund was issued).
14    pub amount_refunded: i64,
15    ///ID of the Connect application that created the charge.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub application: Option<serde_json::Value>,
18    ///The application fee (if any) for the charge. [See the Connect documentation](https://stripe.com/docs/connect/direct-charges#collecting-fees) for details.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub application_fee: Option<serde_json::Value>,
21    ///The amount of the application fee (if any) requested for the charge. [See the Connect documentation](https://stripe.com/docs/connect/direct-charges#collecting-fees) for details.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub application_fee_amount: Option<i64>,
24    ///ID of the balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes).
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub balance_transaction: Option<serde_json::Value>,
27    ///
28    pub billing_details: BillingDetails,
29    ///The full statement descriptor that is passed to card networks, and that is displayed on your customers' credit card and bank statements. Allows you to see what the statement descriptor looks like after the static and dynamic portions are combined.
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub calculated_statement_descriptor: Option<String>,
32    ///If the charge was created without capturing, this Boolean represents whether it is still uncaptured or has since been captured.
33    pub captured: bool,
34    ///Time at which the object was created. Measured in seconds since the Unix epoch.
35    pub created: i64,
36    ///Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
37    pub currency: String,
38    ///ID of the customer this charge is for if one exists.
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub customer: Option<serde_json::Value>,
41    ///An arbitrary string attached to the object. Often useful for displaying to users.
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub description: Option<String>,
44    ///Whether the charge has been disputed.
45    pub disputed: bool,
46    ///ID of the balance transaction that describes the reversal of the balance on your account due to payment failure.
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub failure_balance_transaction: Option<serde_json::Value>,
49    ///Error code explaining reason for charge failure if available (see [the errors section](https://stripe.com/docs/error-codes) for a list of codes).
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub failure_code: Option<String>,
52    ///Message to user further explaining reason for charge failure if available.
53    #[serde(skip_serializing_if = "Option::is_none")]
54    pub failure_message: Option<String>,
55    ///Information on fraud assessments for the charge.
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub fraud_details: Option<serde_json::Value>,
58    ///Unique identifier for the object.
59    pub id: String,
60    ///ID of the invoice this charge is for if one exists.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub invoice: Option<serde_json::Value>,
63    ///Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
64    pub livemode: bool,
65    ///Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
66    pub metadata: serde_json::Value,
67    ///String representing the object's type. Objects of the same type share the same value.
68    pub object: String,
69    ///The account (if any) the charge was made on behalf of without triggering an automatic transfer. See the [Connect documentation](https://stripe.com/docs/connect/separate-charges-and-transfers) for details.
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub on_behalf_of: Option<serde_json::Value>,
72    ///Details about whether the payment was accepted, and why. See [understanding declines](https://stripe.com/docs/declines) for details.
73    #[serde(skip_serializing_if = "Option::is_none")]
74    pub outcome: Option<serde_json::Value>,
75    ///`true` if the charge succeeded, or was successfully authorized for later capture.
76    pub paid: bool,
77    ///ID of the PaymentIntent associated with this charge, if one exists.
78    #[serde(skip_serializing_if = "Option::is_none")]
79    pub payment_intent: Option<serde_json::Value>,
80    ///ID of the payment method used in this charge.
81    #[serde(skip_serializing_if = "Option::is_none")]
82    pub payment_method: Option<String>,
83    ///Details about the payment method at the time of the transaction.
84    #[serde(skip_serializing_if = "Option::is_none")]
85    pub payment_method_details: Option<serde_json::Value>,
86    ///Options to configure Radar. See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information.
87    #[serde(skip_serializing_if = "Option::is_none")]
88    pub radar_options: Option<RadarRadarOptions>,
89    ///This is the email address that the receipt for this charge was sent to.
90    #[serde(skip_serializing_if = "Option::is_none")]
91    pub receipt_email: Option<String>,
92    ///This is the transaction number that appears on email receipts sent for this charge. This attribute will be `null` until a receipt has been sent.
93    #[serde(skip_serializing_if = "Option::is_none")]
94    pub receipt_number: Option<String>,
95    ///This is the URL to view the receipt for this charge. The receipt is kept up-to-date to the latest state of the charge, including any refunds. If the charge is for an Invoice, the receipt will be stylized as an Invoice receipt.
96    #[serde(skip_serializing_if = "Option::is_none")]
97    pub receipt_url: Option<String>,
98    ///Whether the charge has been fully refunded. If the charge is only partially refunded, this attribute will still be false.
99    pub refunded: bool,
100    ///A list of refunds that have been applied to the charge.
101    #[serde(skip_serializing_if = "Option::is_none")]
102    pub refunds: Option<RefundList>,
103    ///ID of the review associated with this charge if one exists.
104    #[serde(skip_serializing_if = "Option::is_none")]
105    pub review: Option<serde_json::Value>,
106    ///Shipping information for the charge.
107    #[serde(skip_serializing_if = "Option::is_none")]
108    pub shipping: Option<serde_json::Value>,
109    ///The transfer ID which created this charge. Only present if the charge came from another Stripe account. [See the Connect documentation](https://stripe.com/docs/connect/destination-charges) for details.
110    #[serde(skip_serializing_if = "Option::is_none")]
111    pub source_transfer: Option<serde_json::Value>,
112    ///For card charges, use `statement_descriptor_suffix` instead. Otherwise, you can use this value as the complete description of a charge on your customers’ statements. Must contain at least one letter, maximum 22 characters.
113    #[serde(skip_serializing_if = "Option::is_none")]
114    pub statement_descriptor: Option<String>,
115    ///Provides information about the charge that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.
116    #[serde(skip_serializing_if = "Option::is_none")]
117    pub statement_descriptor_suffix: Option<String>,
118    ///The status of the payment is either `succeeded`, `pending`, or `failed`.
119    pub status: String,
120    ///ID of the transfer to the `destination` account (only applicable if the charge was created using the `destination` parameter).
121    #[serde(skip_serializing_if = "Option::is_none")]
122    pub transfer: Option<serde_json::Value>,
123    ///An optional dictionary including the account to automatically transfer to as part of a destination charge. [See the Connect documentation](https://stripe.com/docs/connect/destination-charges) for details.
124    #[serde(skip_serializing_if = "Option::is_none")]
125    pub transfer_data: Option<serde_json::Value>,
126    ///A string that identifies this transaction as part of a group. See the [Connect documentation](https://stripe.com/docs/connect/separate-charges-and-transfers#transfer-options) for details.
127    #[serde(skip_serializing_if = "Option::is_none")]
128    pub transfer_group: Option<String>,
129}
130impl std::fmt::Display for Charge {
131    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
132        write!(f, "{}", serde_json::to_string(self).unwrap())
133    }
134}