stripe/resources/generated/issuing_transaction.rs
1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use crate::ids::IssuingTransactionId;
6use crate::params::{Expandable, Metadata, Object, Timestamp};
7use crate::resources::{
8 BalanceTransaction, Currency, IssuingAuthorization, IssuingCard, IssuingCardholder,
9 IssuingDispute, IssuingToken, IssuingTransactionType, MerchantData,
10};
11use serde::{Deserialize, Serialize};
12
13/// The resource representing a Stripe "IssuingTransaction".
14///
15/// For more details see <https://stripe.com/docs/api/issuing/transactions/object>
16#[derive(Clone, Debug, Default, Deserialize, Serialize)]
17pub struct IssuingTransaction {
18 /// Unique identifier for the object.
19 pub id: IssuingTransactionId,
20
21 /// The transaction amount, which will be reflected in your balance.
22 ///
23 /// This amount is in your currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
24 pub amount: i64,
25
26 /// Detailed breakdown of amount components.
27 ///
28 /// These amounts are denominated in `currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
29 pub amount_details: Option<IssuingTransactionAmountDetails>,
30
31 /// The `Authorization` object that led to this transaction.
32 pub authorization: Option<Expandable<IssuingAuthorization>>,
33
34 /// ID of the [balance transaction](https://stripe.com/docs/api/balance_transactions) associated with this transaction.
35 pub balance_transaction: Option<Expandable<BalanceTransaction>>,
36
37 /// The card used to make this transaction.
38 pub card: Expandable<IssuingCard>,
39
40 /// The cardholder to whom this transaction belongs.
41 pub cardholder: Option<Expandable<IssuingCardholder>>,
42
43 /// Time at which the object was created.
44 ///
45 /// Measured in seconds since the Unix epoch.
46 pub created: Timestamp,
47
48 /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
49 ///
50 /// Must be a [supported currency](https://stripe.com/docs/currencies).
51 pub currency: Currency,
52
53 /// If you've disputed the transaction, the ID of the dispute.
54 pub dispute: Option<Expandable<IssuingDispute>>,
55
56 /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
57 pub livemode: bool,
58
59 /// The amount that the merchant will receive, denominated in `merchant_currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
60 ///
61 /// It will be different from `amount` if the merchant is taking payment in a different currency.
62 pub merchant_amount: i64,
63
64 /// The currency with which the merchant is taking payment.
65 pub merchant_currency: Currency,
66
67 pub merchant_data: MerchantData,
68
69 /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
70 ///
71 /// This can be useful for storing additional information about the object in a structured format.
72 pub metadata: Metadata,
73
74 /// Details about the transaction, such as processing dates, set by the card network.
75 pub network_data: Option<IssuingTransactionNetworkData>,
76
77 /// Additional purchase information that is optionally provided by the merchant.
78 pub purchase_details: Option<IssuingTransactionPurchaseDetails>,
79
80 /// [Token](https://stripe.com/docs/api/issuing/tokens/object) object used for this transaction.
81 ///
82 /// If a network token was not used for this transaction, this field will be null.
83 #[serde(skip_serializing_if = "Option::is_none")]
84 pub token: Option<Expandable<IssuingToken>>,
85
86 /// [Treasury](https://stripe.com/docs/api/treasury) details related to this transaction if it was created on a [FinancialAccount](/docs/api/treasury/financial_accounts.
87 #[serde(skip_serializing_if = "Option::is_none")]
88 pub treasury: Option<IssuingTransactionTreasury>,
89
90 /// The nature of the transaction.
91 #[serde(rename = "type")]
92 pub type_: IssuingTransactionType,
93
94 /// The digital wallet used for this transaction.
95 ///
96 /// One of `apple_pay`, `google_pay`, or `samsung_pay`.
97 pub wallet: Option<IssuingTransactionWallet>,
98}
99
100impl Object for IssuingTransaction {
101 type Id = IssuingTransactionId;
102 fn id(&self) -> Self::Id {
103 self.id.clone()
104 }
105 fn object(&self) -> &'static str {
106 "issuing.transaction"
107 }
108}
109
110#[derive(Clone, Debug, Default, Deserialize, Serialize)]
111pub struct IssuingTransactionAmountDetails {
112 /// The fee charged by the ATM for the cash withdrawal.
113 pub atm_fee: Option<i64>,
114
115 /// The amount of cash requested by the cardholder.
116 pub cashback_amount: Option<i64>,
117}
118
119#[derive(Clone, Debug, Default, Deserialize, Serialize)]
120pub struct IssuingTransactionNetworkData {
121 /// A code created by Stripe which is shared with the merchant to validate the authorization.
122 ///
123 /// This field will be populated if the authorization message was approved.
124 /// The code typically starts with the letter "S", followed by a six-digit number.
125 /// For example, "S498162".
126 /// Please note that the code is not guaranteed to be unique across authorizations.
127 pub authorization_code: Option<String>,
128
129 /// The date the transaction was processed by the card network.
130 ///
131 /// This can be different from the date the seller recorded the transaction depending on when the acquirer submits the transaction to the network.
132 pub processing_date: Option<String>,
133
134 /// Unique identifier for the authorization assigned by the card network used to match subsequent messages, disputes, and transactions.
135 pub transaction_id: Option<String>,
136}
137
138#[derive(Clone, Debug, Default, Deserialize, Serialize)]
139pub struct IssuingTransactionPurchaseDetails {
140 /// Information about the flight that was purchased with this transaction.
141 pub flight: Option<IssuingTransactionFlightData>,
142
143 /// Information about fuel that was purchased with this transaction.
144 pub fuel: Option<IssuingTransactionFuelData>,
145
146 /// Information about lodging that was purchased with this transaction.
147 pub lodging: Option<IssuingTransactionLodgingData>,
148
149 /// The line items in the purchase.
150 pub receipt: Option<Vec<IssuingTransactionReceiptData>>,
151
152 /// A merchant-specific order number.
153 pub reference: Option<String>,
154}
155
156#[derive(Clone, Debug, Default, Deserialize, Serialize)]
157pub struct IssuingTransactionFlightData {
158 /// The time that the flight departed.
159 pub departure_at: Option<i64>,
160
161 /// The name of the passenger.
162 pub passenger_name: Option<String>,
163
164 /// Whether the ticket is refundable.
165 pub refundable: Option<bool>,
166
167 /// The legs of the trip.
168 pub segments: Option<Vec<IssuingTransactionFlightDataLeg>>,
169
170 /// The travel agency that issued the ticket.
171 pub travel_agency: Option<String>,
172}
173
174#[derive(Clone, Debug, Default, Deserialize, Serialize)]
175pub struct IssuingTransactionFlightDataLeg {
176 /// The three-letter IATA airport code of the flight's destination.
177 pub arrival_airport_code: Option<String>,
178
179 /// The airline carrier code.
180 pub carrier: Option<String>,
181
182 /// The three-letter IATA airport code that the flight departed from.
183 pub departure_airport_code: Option<String>,
184
185 /// The flight number.
186 pub flight_number: Option<String>,
187
188 /// The flight's service class.
189 pub service_class: Option<String>,
190
191 /// Whether a stopover is allowed on this flight.
192 pub stopover_allowed: Option<bool>,
193}
194
195#[derive(Clone, Debug, Default, Deserialize, Serialize)]
196pub struct IssuingTransactionFuelData {
197 /// The type of fuel that was purchased.
198 ///
199 /// One of `diesel`, `unleaded_plus`, `unleaded_regular`, `unleaded_super`, or `other`.
200 #[serde(rename = "type")]
201 pub type_: String,
202
203 /// The units for `volume_decimal`.
204 ///
205 /// One of `us_gallon` or `liter`.
206 pub unit: String,
207
208 /// The cost in cents per each unit of fuel, represented as a decimal string with at most 12 decimal places.
209 pub unit_cost_decimal: String,
210
211 /// The volume of the fuel that was pumped, represented as a decimal string with at most 12 decimal places.
212 pub volume_decimal: Option<String>,
213}
214
215#[derive(Clone, Debug, Default, Deserialize, Serialize)]
216pub struct IssuingTransactionLodgingData {
217 /// The time of checking into the lodging.
218 pub check_in_at: Option<i64>,
219
220 /// The number of nights stayed at the lodging.
221 pub nights: Option<i64>,
222}
223
224#[derive(Clone, Debug, Default, Deserialize, Serialize)]
225pub struct IssuingTransactionReceiptData {
226 /// The description of the item.
227 ///
228 /// The maximum length of this field is 26 characters.
229 pub description: Option<String>,
230
231 /// The quantity of the item.
232 pub quantity: Option<f64>,
233
234 /// The total for this line item in cents.
235 pub total: Option<i64>,
236
237 /// The unit cost of the item in cents.
238 pub unit_cost: Option<i64>,
239}
240
241#[derive(Clone, Debug, Default, Deserialize, Serialize)]
242pub struct IssuingTransactionTreasury {
243 /// The Treasury [ReceivedCredit](https://stripe.com/docs/api/treasury/received_credits) representing this Issuing transaction if it is a refund.
244 pub received_credit: Option<String>,
245
246 /// The Treasury [ReceivedDebit](https://stripe.com/docs/api/treasury/received_debits) representing this Issuing transaction if it is a capture.
247 pub received_debit: Option<String>,
248}
249
250/// An enum representing the possible values of an `IssuingTransaction`'s `wallet` field.
251#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
252#[serde(rename_all = "snake_case")]
253pub enum IssuingTransactionWallet {
254 ApplePay,
255 GooglePay,
256 SamsungPay,
257}
258
259impl IssuingTransactionWallet {
260 pub fn as_str(self) -> &'static str {
261 match self {
262 IssuingTransactionWallet::ApplePay => "apple_pay",
263 IssuingTransactionWallet::GooglePay => "google_pay",
264 IssuingTransactionWallet::SamsungPay => "samsung_pay",
265 }
266 }
267}
268
269impl AsRef<str> for IssuingTransactionWallet {
270 fn as_ref(&self) -> &str {
271 self.as_str()
272 }
273}
274
275impl std::fmt::Display for IssuingTransactionWallet {
276 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
277 self.as_str().fmt(f)
278 }
279}
280impl std::default::Default for IssuingTransactionWallet {
281 fn default() -> Self {
282 Self::ApplePay
283 }
284}