stripe/model/
credit_note.rs

1use serde::{Serialize, Deserialize};
2use super::{CreditNoteLinesList, CreditNoteTaxAmount, DiscountsResourceDiscountAmount};
3/**Issue a credit note to adjust an invoice's amount after the invoice is finalized.
4
5Related guide: [Credit notes](https://stripe.com/docs/billing/invoices/credit-notes)*/
6#[derive(Debug, Clone, Serialize, Deserialize, Default)]
7pub struct CreditNote {
8    ///The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax.
9    pub amount: i64,
10    ///This is the sum of all the shipping amounts.
11    pub amount_shipping: i64,
12    ///Time at which the object was created. Measured in seconds since the Unix epoch.
13    pub created: i64,
14    ///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).
15    pub currency: String,
16    ///ID of the customer.
17    pub customer: serde_json::Value,
18    ///Customer balance transaction related to this credit note.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub customer_balance_transaction: Option<serde_json::Value>,
21    ///The integer amount in cents (or local equivalent) representing the total amount of discount that was credited.
22    pub discount_amount: i64,
23    ///The aggregate amounts calculated per discount for all line items.
24    pub discount_amounts: Vec<DiscountsResourceDiscountAmount>,
25    ///The date when this credit note is in effect. Same as `created` unless overwritten. When defined, this value replaces the system-generated 'Date of issue' printed on the credit note PDF.
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub effective_at: Option<i64>,
28    ///Unique identifier for the object.
29    pub id: String,
30    ///ID of the invoice.
31    pub invoice: serde_json::Value,
32    ///Line items that make up the credit note
33    pub lines: CreditNoteLinesList,
34    ///Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
35    pub livemode: bool,
36    ///Customer-facing text that appears on the credit note PDF.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub memo: Option<String>,
39    ///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.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub metadata: Option<serde_json::Value>,
42    ///A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice.
43    pub number: String,
44    ///String representing the object's type. Objects of the same type share the same value.
45    pub object: String,
46    ///Amount that was credited outside of Stripe.
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub out_of_band_amount: Option<i64>,
49    ///The link to download the PDF of the credit note.
50    pub pdf: String,
51    ///Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory`
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub reason: Option<String>,
54    ///Refund related to this credit note.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub refund: Option<serde_json::Value>,
57    ///The details of the cost of shipping, including the ShippingRate applied to the invoice.
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub shipping_cost: Option<serde_json::Value>,
60    ///Status of this credit note, one of `issued` or `void`. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding).
61    pub status: String,
62    ///The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding exclusive tax and invoice level discounts.
63    pub subtotal: i64,
64    ///The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding all tax and invoice level discounts.
65    #[serde(skip_serializing_if = "Option::is_none")]
66    pub subtotal_excluding_tax: Option<i64>,
67    ///The aggregate amounts calculated per tax rate for all line items.
68    pub tax_amounts: Vec<CreditNoteTaxAmount>,
69    ///The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax and all discount.
70    pub total: i64,
71    ///The integer amount in cents (or local equivalent) representing the total amount of the credit note, excluding tax, but including discounts.
72    #[serde(skip_serializing_if = "Option::is_none")]
73    pub total_excluding_tax: Option<i64>,
74    ///Type of this credit note, one of `pre_payment` or `post_payment`. A `pre_payment` credit note means it was issued when the invoice was open. A `post_payment` credit note means it was issued when the invoice was paid.
75    #[serde(rename = "type")]
76    pub type_: String,
77    ///The time that the credit note was voided.
78    #[serde(skip_serializing_if = "Option::is_none")]
79    pub voided_at: Option<i64>,
80}
81impl std::fmt::Display for CreditNote {
82    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
83        write!(f, "{}", serde_json::to_string(self).unwrap())
84    }
85}