1#[derive(Clone, Debug)]
9#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
10pub struct IssuingTransaction {
11 pub amount: i64,
14 pub amount_details: Option<stripe_shared::IssuingTransactionAmountDetails>,
17 pub authorization: Option<stripe_types::Expandable<stripe_shared::IssuingAuthorization>>,
19 pub balance_transaction: Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>,
21 pub card: stripe_types::Expandable<stripe_shared::IssuingCard>,
23 pub cardholder: Option<stripe_types::Expandable<stripe_shared::IssuingCardholder>>,
25 pub created: stripe_types::Timestamp,
27 pub currency: stripe_types::Currency,
30 pub dispute: Option<stripe_types::Expandable<stripe_shared::IssuingDispute>>,
32 pub id: stripe_shared::IssuingTransactionId,
34 pub livemode: bool,
36 pub merchant_amount: i64,
39 pub merchant_currency: stripe_types::Currency,
41 pub merchant_data: stripe_shared::IssuingAuthorizationMerchantData,
42 pub metadata: std::collections::HashMap<String, String>,
45 pub network_data: Option<stripe_shared::IssuingTransactionNetworkData>,
47 pub purchase_details: Option<stripe_shared::IssuingTransactionPurchaseDetails>,
49 pub token: Option<stripe_types::Expandable<stripe_shared::IssuingToken>>,
52 pub treasury: Option<stripe_shared::IssuingTransactionTreasury>,
54 #[cfg_attr(feature = "deserialize", serde(rename = "type"))]
56 pub type_: stripe_shared::IssuingTransactionType,
57 pub wallet: Option<IssuingTransactionWallet>,
59}
60#[doc(hidden)]
61pub struct IssuingTransactionBuilder {
62 amount: Option<i64>,
63 amount_details: Option<Option<stripe_shared::IssuingTransactionAmountDetails>>,
64 authorization: Option<Option<stripe_types::Expandable<stripe_shared::IssuingAuthorization>>>,
65 balance_transaction:
66 Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>>,
67 card: Option<stripe_types::Expandable<stripe_shared::IssuingCard>>,
68 cardholder: Option<Option<stripe_types::Expandable<stripe_shared::IssuingCardholder>>>,
69 created: Option<stripe_types::Timestamp>,
70 currency: Option<stripe_types::Currency>,
71 dispute: Option<Option<stripe_types::Expandable<stripe_shared::IssuingDispute>>>,
72 id: Option<stripe_shared::IssuingTransactionId>,
73 livemode: Option<bool>,
74 merchant_amount: Option<i64>,
75 merchant_currency: Option<stripe_types::Currency>,
76 merchant_data: Option<stripe_shared::IssuingAuthorizationMerchantData>,
77 metadata: Option<std::collections::HashMap<String, String>>,
78 network_data: Option<Option<stripe_shared::IssuingTransactionNetworkData>>,
79 purchase_details: Option<Option<stripe_shared::IssuingTransactionPurchaseDetails>>,
80 token: Option<Option<stripe_types::Expandable<stripe_shared::IssuingToken>>>,
81 treasury: Option<Option<stripe_shared::IssuingTransactionTreasury>>,
82 type_: Option<stripe_shared::IssuingTransactionType>,
83 wallet: Option<Option<IssuingTransactionWallet>>,
84}
85
86#[allow(
87 unused_variables,
88 irrefutable_let_patterns,
89 clippy::let_unit_value,
90 clippy::match_single_binding,
91 clippy::single_match
92)]
93const _: () = {
94 use miniserde::de::{Map, Visitor};
95 use miniserde::json::Value;
96 use miniserde::{Deserialize, Result, make_place};
97 use stripe_types::miniserde_helpers::FromValueOpt;
98 use stripe_types::{MapBuilder, ObjectDeser};
99
100 make_place!(Place);
101
102 impl Deserialize for IssuingTransaction {
103 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
104 Place::new(out)
105 }
106 }
107
108 struct Builder<'a> {
109 out: &'a mut Option<IssuingTransaction>,
110 builder: IssuingTransactionBuilder,
111 }
112
113 impl Visitor for Place<IssuingTransaction> {
114 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
115 Ok(Box::new(Builder {
116 out: &mut self.out,
117 builder: IssuingTransactionBuilder::deser_default(),
118 }))
119 }
120 }
121
122 impl MapBuilder for IssuingTransactionBuilder {
123 type Out = IssuingTransaction;
124 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
125 Ok(match k {
126 "amount" => Deserialize::begin(&mut self.amount),
127 "amount_details" => Deserialize::begin(&mut self.amount_details),
128 "authorization" => Deserialize::begin(&mut self.authorization),
129 "balance_transaction" => Deserialize::begin(&mut self.balance_transaction),
130 "card" => Deserialize::begin(&mut self.card),
131 "cardholder" => Deserialize::begin(&mut self.cardholder),
132 "created" => Deserialize::begin(&mut self.created),
133 "currency" => Deserialize::begin(&mut self.currency),
134 "dispute" => Deserialize::begin(&mut self.dispute),
135 "id" => Deserialize::begin(&mut self.id),
136 "livemode" => Deserialize::begin(&mut self.livemode),
137 "merchant_amount" => Deserialize::begin(&mut self.merchant_amount),
138 "merchant_currency" => Deserialize::begin(&mut self.merchant_currency),
139 "merchant_data" => Deserialize::begin(&mut self.merchant_data),
140 "metadata" => Deserialize::begin(&mut self.metadata),
141 "network_data" => Deserialize::begin(&mut self.network_data),
142 "purchase_details" => Deserialize::begin(&mut self.purchase_details),
143 "token" => Deserialize::begin(&mut self.token),
144 "treasury" => Deserialize::begin(&mut self.treasury),
145 "type" => Deserialize::begin(&mut self.type_),
146 "wallet" => Deserialize::begin(&mut self.wallet),
147 _ => <dyn Visitor>::ignore(),
148 })
149 }
150
151 fn deser_default() -> Self {
152 Self {
153 amount: Deserialize::default(),
154 amount_details: Deserialize::default(),
155 authorization: Deserialize::default(),
156 balance_transaction: Deserialize::default(),
157 card: Deserialize::default(),
158 cardholder: Deserialize::default(),
159 created: Deserialize::default(),
160 currency: Deserialize::default(),
161 dispute: Deserialize::default(),
162 id: Deserialize::default(),
163 livemode: Deserialize::default(),
164 merchant_amount: Deserialize::default(),
165 merchant_currency: Deserialize::default(),
166 merchant_data: Deserialize::default(),
167 metadata: Deserialize::default(),
168 network_data: Deserialize::default(),
169 purchase_details: Deserialize::default(),
170 token: Deserialize::default(),
171 treasury: Deserialize::default(),
172 type_: Deserialize::default(),
173 wallet: Deserialize::default(),
174 }
175 }
176
177 fn take_out(&mut self) -> Option<Self::Out> {
178 let (
179 Some(amount),
180 Some(amount_details),
181 Some(authorization),
182 Some(balance_transaction),
183 Some(card),
184 Some(cardholder),
185 Some(created),
186 Some(currency),
187 Some(dispute),
188 Some(id),
189 Some(livemode),
190 Some(merchant_amount),
191 Some(merchant_currency),
192 Some(merchant_data),
193 Some(metadata),
194 Some(network_data),
195 Some(purchase_details),
196 Some(token),
197 Some(treasury),
198 Some(type_),
199 Some(wallet),
200 ) = (
201 self.amount,
202 self.amount_details,
203 self.authorization.take(),
204 self.balance_transaction.take(),
205 self.card.take(),
206 self.cardholder.take(),
207 self.created,
208 self.currency.take(),
209 self.dispute.take(),
210 self.id.take(),
211 self.livemode,
212 self.merchant_amount,
213 self.merchant_currency.take(),
214 self.merchant_data.take(),
215 self.metadata.take(),
216 self.network_data.take(),
217 self.purchase_details.take(),
218 self.token.take(),
219 self.treasury.take(),
220 self.type_.take(),
221 self.wallet.take(),
222 )
223 else {
224 return None;
225 };
226 Some(Self::Out {
227 amount,
228 amount_details,
229 authorization,
230 balance_transaction,
231 card,
232 cardholder,
233 created,
234 currency,
235 dispute,
236 id,
237 livemode,
238 merchant_amount,
239 merchant_currency,
240 merchant_data,
241 metadata,
242 network_data,
243 purchase_details,
244 token,
245 treasury,
246 type_,
247 wallet,
248 })
249 }
250 }
251
252 impl Map for Builder<'_> {
253 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
254 self.builder.key(k)
255 }
256
257 fn finish(&mut self) -> Result<()> {
258 *self.out = self.builder.take_out();
259 Ok(())
260 }
261 }
262
263 impl ObjectDeser for IssuingTransaction {
264 type Builder = IssuingTransactionBuilder;
265 }
266
267 impl FromValueOpt for IssuingTransaction {
268 fn from_value(v: Value) -> Option<Self> {
269 let Value::Object(obj) = v else {
270 return None;
271 };
272 let mut b = IssuingTransactionBuilder::deser_default();
273 for (k, v) in obj {
274 match k.as_str() {
275 "amount" => b.amount = FromValueOpt::from_value(v),
276 "amount_details" => b.amount_details = FromValueOpt::from_value(v),
277 "authorization" => b.authorization = FromValueOpt::from_value(v),
278 "balance_transaction" => b.balance_transaction = FromValueOpt::from_value(v),
279 "card" => b.card = FromValueOpt::from_value(v),
280 "cardholder" => b.cardholder = FromValueOpt::from_value(v),
281 "created" => b.created = FromValueOpt::from_value(v),
282 "currency" => b.currency = FromValueOpt::from_value(v),
283 "dispute" => b.dispute = FromValueOpt::from_value(v),
284 "id" => b.id = FromValueOpt::from_value(v),
285 "livemode" => b.livemode = FromValueOpt::from_value(v),
286 "merchant_amount" => b.merchant_amount = FromValueOpt::from_value(v),
287 "merchant_currency" => b.merchant_currency = FromValueOpt::from_value(v),
288 "merchant_data" => b.merchant_data = FromValueOpt::from_value(v),
289 "metadata" => b.metadata = FromValueOpt::from_value(v),
290 "network_data" => b.network_data = FromValueOpt::from_value(v),
291 "purchase_details" => b.purchase_details = FromValueOpt::from_value(v),
292 "token" => b.token = FromValueOpt::from_value(v),
293 "treasury" => b.treasury = FromValueOpt::from_value(v),
294 "type" => b.type_ = FromValueOpt::from_value(v),
295 "wallet" => b.wallet = FromValueOpt::from_value(v),
296 _ => {}
297 }
298 }
299 b.take_out()
300 }
301 }
302};
303#[cfg(feature = "serialize")]
304impl serde::Serialize for IssuingTransaction {
305 fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
306 use serde::ser::SerializeStruct;
307 let mut s = s.serialize_struct("IssuingTransaction", 22)?;
308 s.serialize_field("amount", &self.amount)?;
309 s.serialize_field("amount_details", &self.amount_details)?;
310 s.serialize_field("authorization", &self.authorization)?;
311 s.serialize_field("balance_transaction", &self.balance_transaction)?;
312 s.serialize_field("card", &self.card)?;
313 s.serialize_field("cardholder", &self.cardholder)?;
314 s.serialize_field("created", &self.created)?;
315 s.serialize_field("currency", &self.currency)?;
316 s.serialize_field("dispute", &self.dispute)?;
317 s.serialize_field("id", &self.id)?;
318 s.serialize_field("livemode", &self.livemode)?;
319 s.serialize_field("merchant_amount", &self.merchant_amount)?;
320 s.serialize_field("merchant_currency", &self.merchant_currency)?;
321 s.serialize_field("merchant_data", &self.merchant_data)?;
322 s.serialize_field("metadata", &self.metadata)?;
323 s.serialize_field("network_data", &self.network_data)?;
324 s.serialize_field("purchase_details", &self.purchase_details)?;
325 s.serialize_field("token", &self.token)?;
326 s.serialize_field("treasury", &self.treasury)?;
327 s.serialize_field("type", &self.type_)?;
328 s.serialize_field("wallet", &self.wallet)?;
329
330 s.serialize_field("object", "issuing.transaction")?;
331 s.end()
332 }
333}
334#[derive(Clone, Eq, PartialEq)]
336#[non_exhaustive]
337pub enum IssuingTransactionWallet {
338 ApplePay,
339 GooglePay,
340 SamsungPay,
341 Unknown(String),
343}
344impl IssuingTransactionWallet {
345 pub fn as_str(&self) -> &str {
346 use IssuingTransactionWallet::*;
347 match self {
348 ApplePay => "apple_pay",
349 GooglePay => "google_pay",
350 SamsungPay => "samsung_pay",
351 Unknown(v) => v,
352 }
353 }
354}
355
356impl std::str::FromStr for IssuingTransactionWallet {
357 type Err = std::convert::Infallible;
358 fn from_str(s: &str) -> Result<Self, Self::Err> {
359 use IssuingTransactionWallet::*;
360 match s {
361 "apple_pay" => Ok(ApplePay),
362 "google_pay" => Ok(GooglePay),
363 "samsung_pay" => Ok(SamsungPay),
364 v => {
365 tracing::warn!("Unknown value '{}' for enum '{}'", v, "IssuingTransactionWallet");
366 Ok(Unknown(v.to_owned()))
367 }
368 }
369 }
370}
371impl std::fmt::Display for IssuingTransactionWallet {
372 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
373 f.write_str(self.as_str())
374 }
375}
376
377impl std::fmt::Debug for IssuingTransactionWallet {
378 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
379 f.write_str(self.as_str())
380 }
381}
382#[cfg(feature = "serialize")]
383impl serde::Serialize for IssuingTransactionWallet {
384 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
385 where
386 S: serde::Serializer,
387 {
388 serializer.serialize_str(self.as_str())
389 }
390}
391impl miniserde::Deserialize for IssuingTransactionWallet {
392 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
393 crate::Place::new(out)
394 }
395}
396
397impl miniserde::de::Visitor for crate::Place<IssuingTransactionWallet> {
398 fn string(&mut self, s: &str) -> miniserde::Result<()> {
399 use std::str::FromStr;
400 self.out = Some(IssuingTransactionWallet::from_str(s).expect("infallible"));
401 Ok(())
402 }
403}
404
405stripe_types::impl_from_val_with_from_str!(IssuingTransactionWallet);
406#[cfg(feature = "deserialize")]
407impl<'de> serde::Deserialize<'de> for IssuingTransactionWallet {
408 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
409 use std::str::FromStr;
410 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
411 Ok(Self::from_str(&s).expect("infallible"))
412 }
413}
414impl stripe_types::Object for IssuingTransaction {
415 type Id = stripe_shared::IssuingTransactionId;
416 fn id(&self) -> &Self::Id {
417 &self.id
418 }
419
420 fn into_id(self) -> Self::Id {
421 self.id
422 }
423}
424stripe_types::def_id!(IssuingTransactionId);
425#[derive(Clone, Eq, PartialEq)]
426#[non_exhaustive]
427pub enum IssuingTransactionType {
428 Capture,
429 Refund,
430 Unknown(String),
432}
433impl IssuingTransactionType {
434 pub fn as_str(&self) -> &str {
435 use IssuingTransactionType::*;
436 match self {
437 Capture => "capture",
438 Refund => "refund",
439 Unknown(v) => v,
440 }
441 }
442}
443
444impl std::str::FromStr for IssuingTransactionType {
445 type Err = std::convert::Infallible;
446 fn from_str(s: &str) -> Result<Self, Self::Err> {
447 use IssuingTransactionType::*;
448 match s {
449 "capture" => Ok(Capture),
450 "refund" => Ok(Refund),
451 v => {
452 tracing::warn!("Unknown value '{}' for enum '{}'", v, "IssuingTransactionType");
453 Ok(Unknown(v.to_owned()))
454 }
455 }
456 }
457}
458impl std::fmt::Display for IssuingTransactionType {
459 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
460 f.write_str(self.as_str())
461 }
462}
463
464impl std::fmt::Debug for IssuingTransactionType {
465 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
466 f.write_str(self.as_str())
467 }
468}
469impl serde::Serialize for IssuingTransactionType {
470 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
471 where
472 S: serde::Serializer,
473 {
474 serializer.serialize_str(self.as_str())
475 }
476}
477impl miniserde::Deserialize for IssuingTransactionType {
478 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
479 crate::Place::new(out)
480 }
481}
482
483impl miniserde::de::Visitor for crate::Place<IssuingTransactionType> {
484 fn string(&mut self, s: &str) -> miniserde::Result<()> {
485 use std::str::FromStr;
486 self.out = Some(IssuingTransactionType::from_str(s).expect("infallible"));
487 Ok(())
488 }
489}
490
491stripe_types::impl_from_val_with_from_str!(IssuingTransactionType);
492#[cfg(feature = "deserialize")]
493impl<'de> serde::Deserialize<'de> for IssuingTransactionType {
494 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
495 use std::str::FromStr;
496 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
497 Ok(Self::from_str(&s).expect("infallible"))
498 }
499}