stripe_shared/
balance_transaction.rs

1/// Balance transactions represent funds moving through your Stripe account.
2/// Stripe creates them for every type of transaction that enters or leaves your Stripe account balance.
3///
4/// Related guide: [Balance transaction types](https://stripe.com/docs/reports/balance-transaction-types).
5///
6/// For more details see <<https://stripe.com/docs/api/balance_transactions/object>>.
7#[derive(Clone, Debug)]
8#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
9pub struct BalanceTransaction {
10    /// Gross amount of this transaction (in cents (or local equivalent)).
11    /// A positive value represents funds charged to another party, and a negative value represents funds sent to another party.
12    pub amount: i64,
13    /// The date that the transaction's net funds become available in the Stripe balance.
14    pub available_on: stripe_types::Timestamp,
15    /// The balance that this transaction impacts.
16    pub balance_type: Option<BalanceTransactionBalanceType>,
17    /// Time at which the object was created. Measured in seconds since the Unix epoch.
18    pub created: stripe_types::Timestamp,
19    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
20    /// Must be a [supported currency](https://stripe.com/docs/currencies).
21    pub currency: stripe_types::Currency,
22    /// An arbitrary string attached to the object. Often useful for displaying to users.
23    pub description: Option<String>,
24    /// If applicable, this transaction uses an exchange rate.
25    /// If money converts from currency A to currency B, then the `amount` in currency A, multipled by the `exchange_rate`, equals the `amount` in currency B.
26    /// For example, if you charge a customer 10.00 EUR, the PaymentIntent's `amount` is `1000` and `currency` is `eur`.
27    /// If this converts to 12.34 USD in your Stripe account, the BalanceTransaction's `amount` is `1234`, its `currency` is `usd`, and the `exchange_rate` is `1.234`.
28    pub exchange_rate: Option<f64>,
29    /// Fees (in cents (or local equivalent)) paid for this transaction.
30    /// Represented as a positive integer when assessed.
31    pub fee: i64,
32    /// Detailed breakdown of fees (in cents (or local equivalent)) paid for this transaction.
33    pub fee_details: Vec<stripe_shared::Fee>,
34    /// Unique identifier for the object.
35    pub id: stripe_shared::BalanceTransactionId,
36    /// Net impact to a Stripe balance (in cents (or local equivalent)).
37    /// A positive value represents incrementing a Stripe balance, and a negative value decrementing a Stripe balance.
38    /// You can calculate the net impact of a transaction on a balance by `amount` - `fee`.
39    pub net: i64,
40    /// Learn more about how [reporting categories](https://stripe.com/docs/reports/reporting-categories) can help you understand balance transactions from an accounting perspective.
41    pub reporting_category: String,
42    /// This transaction relates to the Stripe object.
43    pub source: Option<stripe_types::Expandable<stripe_shared::BalanceTransactionSource>>,
44    /// The transaction's net funds status in the Stripe balance, which are either `available` or `pending`.
45    pub status: String,
46    /// Transaction type: `adjustment`, `advance`, `advance_funding`, `anticipation_repayment`, `application_fee`, `application_fee_refund`, `charge`, `climate_order_purchase`, `climate_order_refund`, `connect_collection_transfer`, `contribution`, `issuing_authorization_hold`, `issuing_authorization_release`, `issuing_dispute`, `issuing_transaction`, `obligation_outbound`, `obligation_reversal_inbound`, `payment`, `payment_failure_refund`, `payment_network_reserve_hold`, `payment_network_reserve_release`, `payment_refund`, `payment_reversal`, `payment_unreconciled`, `payout`, `payout_cancel`, `payout_failure`, `payout_minimum_balance_hold`, `payout_minimum_balance_release`, `refund`, `refund_failure`, `reserve_transaction`, `reserved_funds`, `stripe_fee`, `stripe_fx_fee`, `stripe_balance_payment_debit`, `stripe_balance_payment_debit_reversal`, `tax_fee`, `topup`, `topup_reversal`, `transfer`, `transfer_cancel`, `transfer_failure`, or `transfer_refund`.
47    /// Learn more about [balance transaction types and what they represent](https://stripe.com/docs/reports/balance-transaction-types).
48    /// To classify transactions for accounting purposes, consider `reporting_category` instead.
49    #[cfg_attr(feature = "deserialize", serde(rename = "type"))]
50    pub type_: BalanceTransactionType,
51}
52#[doc(hidden)]
53pub struct BalanceTransactionBuilder {
54    amount: Option<i64>,
55    available_on: Option<stripe_types::Timestamp>,
56    balance_type: Option<Option<BalanceTransactionBalanceType>>,
57    created: Option<stripe_types::Timestamp>,
58    currency: Option<stripe_types::Currency>,
59    description: Option<Option<String>>,
60    exchange_rate: Option<Option<f64>>,
61    fee: Option<i64>,
62    fee_details: Option<Vec<stripe_shared::Fee>>,
63    id: Option<stripe_shared::BalanceTransactionId>,
64    net: Option<i64>,
65    reporting_category: Option<String>,
66    source: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransactionSource>>>,
67    status: Option<String>,
68    type_: Option<BalanceTransactionType>,
69}
70
71#[allow(
72    unused_variables,
73    irrefutable_let_patterns,
74    clippy::let_unit_value,
75    clippy::match_single_binding,
76    clippy::single_match
77)]
78const _: () = {
79    use miniserde::de::{Map, Visitor};
80    use miniserde::json::Value;
81    use miniserde::{Deserialize, Result, make_place};
82    use stripe_types::miniserde_helpers::FromValueOpt;
83    use stripe_types::{MapBuilder, ObjectDeser};
84
85    make_place!(Place);
86
87    impl Deserialize for BalanceTransaction {
88        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
89            Place::new(out)
90        }
91    }
92
93    struct Builder<'a> {
94        out: &'a mut Option<BalanceTransaction>,
95        builder: BalanceTransactionBuilder,
96    }
97
98    impl Visitor for Place<BalanceTransaction> {
99        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
100            Ok(Box::new(Builder {
101                out: &mut self.out,
102                builder: BalanceTransactionBuilder::deser_default(),
103            }))
104        }
105    }
106
107    impl MapBuilder for BalanceTransactionBuilder {
108        type Out = BalanceTransaction;
109        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
110            Ok(match k {
111                "amount" => Deserialize::begin(&mut self.amount),
112                "available_on" => Deserialize::begin(&mut self.available_on),
113                "balance_type" => Deserialize::begin(&mut self.balance_type),
114                "created" => Deserialize::begin(&mut self.created),
115                "currency" => Deserialize::begin(&mut self.currency),
116                "description" => Deserialize::begin(&mut self.description),
117                "exchange_rate" => Deserialize::begin(&mut self.exchange_rate),
118                "fee" => Deserialize::begin(&mut self.fee),
119                "fee_details" => Deserialize::begin(&mut self.fee_details),
120                "id" => Deserialize::begin(&mut self.id),
121                "net" => Deserialize::begin(&mut self.net),
122                "reporting_category" => Deserialize::begin(&mut self.reporting_category),
123                "source" => Deserialize::begin(&mut self.source),
124                "status" => Deserialize::begin(&mut self.status),
125                "type" => Deserialize::begin(&mut self.type_),
126                _ => <dyn Visitor>::ignore(),
127            })
128        }
129
130        fn deser_default() -> Self {
131            Self {
132                amount: Deserialize::default(),
133                available_on: Deserialize::default(),
134                balance_type: Deserialize::default(),
135                created: Deserialize::default(),
136                currency: Deserialize::default(),
137                description: Deserialize::default(),
138                exchange_rate: Deserialize::default(),
139                fee: Deserialize::default(),
140                fee_details: Deserialize::default(),
141                id: Deserialize::default(),
142                net: Deserialize::default(),
143                reporting_category: Deserialize::default(),
144                source: Deserialize::default(),
145                status: Deserialize::default(),
146                type_: Deserialize::default(),
147            }
148        }
149
150        fn take_out(&mut self) -> Option<Self::Out> {
151            let (
152                Some(amount),
153                Some(available_on),
154                Some(balance_type),
155                Some(created),
156                Some(currency),
157                Some(description),
158                Some(exchange_rate),
159                Some(fee),
160                Some(fee_details),
161                Some(id),
162                Some(net),
163                Some(reporting_category),
164                Some(source),
165                Some(status),
166                Some(type_),
167            ) = (
168                self.amount,
169                self.available_on,
170                self.balance_type.take(),
171                self.created,
172                self.currency.take(),
173                self.description.take(),
174                self.exchange_rate,
175                self.fee,
176                self.fee_details.take(),
177                self.id.take(),
178                self.net,
179                self.reporting_category.take(),
180                self.source.take(),
181                self.status.take(),
182                self.type_.take(),
183            )
184            else {
185                return None;
186            };
187            Some(Self::Out {
188                amount,
189                available_on,
190                balance_type,
191                created,
192                currency,
193                description,
194                exchange_rate,
195                fee,
196                fee_details,
197                id,
198                net,
199                reporting_category,
200                source,
201                status,
202                type_,
203            })
204        }
205    }
206
207    impl Map for Builder<'_> {
208        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
209            self.builder.key(k)
210        }
211
212        fn finish(&mut self) -> Result<()> {
213            *self.out = self.builder.take_out();
214            Ok(())
215        }
216    }
217
218    impl ObjectDeser for BalanceTransaction {
219        type Builder = BalanceTransactionBuilder;
220    }
221
222    impl FromValueOpt for BalanceTransaction {
223        fn from_value(v: Value) -> Option<Self> {
224            let Value::Object(obj) = v else {
225                return None;
226            };
227            let mut b = BalanceTransactionBuilder::deser_default();
228            for (k, v) in obj {
229                match k.as_str() {
230                    "amount" => b.amount = FromValueOpt::from_value(v),
231                    "available_on" => b.available_on = FromValueOpt::from_value(v),
232                    "balance_type" => b.balance_type = FromValueOpt::from_value(v),
233                    "created" => b.created = FromValueOpt::from_value(v),
234                    "currency" => b.currency = FromValueOpt::from_value(v),
235                    "description" => b.description = FromValueOpt::from_value(v),
236                    "exchange_rate" => b.exchange_rate = FromValueOpt::from_value(v),
237                    "fee" => b.fee = FromValueOpt::from_value(v),
238                    "fee_details" => b.fee_details = FromValueOpt::from_value(v),
239                    "id" => b.id = FromValueOpt::from_value(v),
240                    "net" => b.net = FromValueOpt::from_value(v),
241                    "reporting_category" => b.reporting_category = FromValueOpt::from_value(v),
242                    "source" => b.source = FromValueOpt::from_value(v),
243                    "status" => b.status = FromValueOpt::from_value(v),
244                    "type" => b.type_ = FromValueOpt::from_value(v),
245                    _ => {}
246                }
247            }
248            b.take_out()
249        }
250    }
251};
252#[cfg(feature = "serialize")]
253impl serde::Serialize for BalanceTransaction {
254    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
255        use serde::ser::SerializeStruct;
256        let mut s = s.serialize_struct("BalanceTransaction", 16)?;
257        s.serialize_field("amount", &self.amount)?;
258        s.serialize_field("available_on", &self.available_on)?;
259        s.serialize_field("balance_type", &self.balance_type)?;
260        s.serialize_field("created", &self.created)?;
261        s.serialize_field("currency", &self.currency)?;
262        s.serialize_field("description", &self.description)?;
263        s.serialize_field("exchange_rate", &self.exchange_rate)?;
264        s.serialize_field("fee", &self.fee)?;
265        s.serialize_field("fee_details", &self.fee_details)?;
266        s.serialize_field("id", &self.id)?;
267        s.serialize_field("net", &self.net)?;
268        s.serialize_field("reporting_category", &self.reporting_category)?;
269        s.serialize_field("source", &self.source)?;
270        s.serialize_field("status", &self.status)?;
271        s.serialize_field("type", &self.type_)?;
272
273        s.serialize_field("object", "balance_transaction")?;
274        s.end()
275    }
276}
277/// The balance that this transaction impacts.
278#[derive(Clone, Eq, PartialEq)]
279#[non_exhaustive]
280pub enum BalanceTransactionBalanceType {
281    Issuing,
282    Payments,
283    RefundAndDisputePrefunding,
284    /// An unrecognized value from Stripe. Should not be used as a request parameter.
285    Unknown(String),
286}
287impl BalanceTransactionBalanceType {
288    pub fn as_str(&self) -> &str {
289        use BalanceTransactionBalanceType::*;
290        match self {
291            Issuing => "issuing",
292            Payments => "payments",
293            RefundAndDisputePrefunding => "refund_and_dispute_prefunding",
294            Unknown(v) => v,
295        }
296    }
297}
298
299impl std::str::FromStr for BalanceTransactionBalanceType {
300    type Err = std::convert::Infallible;
301    fn from_str(s: &str) -> Result<Self, Self::Err> {
302        use BalanceTransactionBalanceType::*;
303        match s {
304            "issuing" => Ok(Issuing),
305            "payments" => Ok(Payments),
306            "refund_and_dispute_prefunding" => Ok(RefundAndDisputePrefunding),
307            v => {
308                tracing::warn!(
309                    "Unknown value '{}' for enum '{}'",
310                    v,
311                    "BalanceTransactionBalanceType"
312                );
313                Ok(Unknown(v.to_owned()))
314            }
315        }
316    }
317}
318impl std::fmt::Display for BalanceTransactionBalanceType {
319    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
320        f.write_str(self.as_str())
321    }
322}
323
324impl std::fmt::Debug for BalanceTransactionBalanceType {
325    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
326        f.write_str(self.as_str())
327    }
328}
329#[cfg(feature = "serialize")]
330impl serde::Serialize for BalanceTransactionBalanceType {
331    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
332    where
333        S: serde::Serializer,
334    {
335        serializer.serialize_str(self.as_str())
336    }
337}
338impl miniserde::Deserialize for BalanceTransactionBalanceType {
339    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
340        crate::Place::new(out)
341    }
342}
343
344impl miniserde::de::Visitor for crate::Place<BalanceTransactionBalanceType> {
345    fn string(&mut self, s: &str) -> miniserde::Result<()> {
346        use std::str::FromStr;
347        self.out = Some(BalanceTransactionBalanceType::from_str(s).expect("infallible"));
348        Ok(())
349    }
350}
351
352stripe_types::impl_from_val_with_from_str!(BalanceTransactionBalanceType);
353#[cfg(feature = "deserialize")]
354impl<'de> serde::Deserialize<'de> for BalanceTransactionBalanceType {
355    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
356        use std::str::FromStr;
357        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
358        Ok(Self::from_str(&s).expect("infallible"))
359    }
360}
361/// Transaction type: `adjustment`, `advance`, `advance_funding`, `anticipation_repayment`, `application_fee`, `application_fee_refund`, `charge`, `climate_order_purchase`, `climate_order_refund`, `connect_collection_transfer`, `contribution`, `issuing_authorization_hold`, `issuing_authorization_release`, `issuing_dispute`, `issuing_transaction`, `obligation_outbound`, `obligation_reversal_inbound`, `payment`, `payment_failure_refund`, `payment_network_reserve_hold`, `payment_network_reserve_release`, `payment_refund`, `payment_reversal`, `payment_unreconciled`, `payout`, `payout_cancel`, `payout_failure`, `payout_minimum_balance_hold`, `payout_minimum_balance_release`, `refund`, `refund_failure`, `reserve_transaction`, `reserved_funds`, `stripe_fee`, `stripe_fx_fee`, `stripe_balance_payment_debit`, `stripe_balance_payment_debit_reversal`, `tax_fee`, `topup`, `topup_reversal`, `transfer`, `transfer_cancel`, `transfer_failure`, or `transfer_refund`.
362/// Learn more about [balance transaction types and what they represent](https://stripe.com/docs/reports/balance-transaction-types).
363/// To classify transactions for accounting purposes, consider `reporting_category` instead.
364#[derive(Clone, Eq, PartialEq)]
365#[non_exhaustive]
366pub enum BalanceTransactionType {
367    Adjustment,
368    Advance,
369    AdvanceFunding,
370    AnticipationRepayment,
371    ApplicationFee,
372    ApplicationFeeRefund,
373    Charge,
374    ClimateOrderPurchase,
375    ClimateOrderRefund,
376    ConnectCollectionTransfer,
377    Contribution,
378    IssuingAuthorizationHold,
379    IssuingAuthorizationRelease,
380    IssuingDispute,
381    IssuingTransaction,
382    ObligationOutbound,
383    ObligationReversalInbound,
384    Payment,
385    PaymentFailureRefund,
386    PaymentNetworkReserveHold,
387    PaymentNetworkReserveRelease,
388    PaymentRefund,
389    PaymentReversal,
390    PaymentUnreconciled,
391    Payout,
392    PayoutCancel,
393    PayoutFailure,
394    PayoutMinimumBalanceHold,
395    PayoutMinimumBalanceRelease,
396    Refund,
397    RefundFailure,
398    ReserveTransaction,
399    ReservedFunds,
400    StripeBalancePaymentDebit,
401    StripeBalancePaymentDebitReversal,
402    StripeFee,
403    StripeFxFee,
404    TaxFee,
405    Topup,
406    TopupReversal,
407    Transfer,
408    TransferCancel,
409    TransferFailure,
410    TransferRefund,
411    /// An unrecognized value from Stripe. Should not be used as a request parameter.
412    Unknown(String),
413}
414impl BalanceTransactionType {
415    pub fn as_str(&self) -> &str {
416        use BalanceTransactionType::*;
417        match self {
418            Adjustment => "adjustment",
419            Advance => "advance",
420            AdvanceFunding => "advance_funding",
421            AnticipationRepayment => "anticipation_repayment",
422            ApplicationFee => "application_fee",
423            ApplicationFeeRefund => "application_fee_refund",
424            Charge => "charge",
425            ClimateOrderPurchase => "climate_order_purchase",
426            ClimateOrderRefund => "climate_order_refund",
427            ConnectCollectionTransfer => "connect_collection_transfer",
428            Contribution => "contribution",
429            IssuingAuthorizationHold => "issuing_authorization_hold",
430            IssuingAuthorizationRelease => "issuing_authorization_release",
431            IssuingDispute => "issuing_dispute",
432            IssuingTransaction => "issuing_transaction",
433            ObligationOutbound => "obligation_outbound",
434            ObligationReversalInbound => "obligation_reversal_inbound",
435            Payment => "payment",
436            PaymentFailureRefund => "payment_failure_refund",
437            PaymentNetworkReserveHold => "payment_network_reserve_hold",
438            PaymentNetworkReserveRelease => "payment_network_reserve_release",
439            PaymentRefund => "payment_refund",
440            PaymentReversal => "payment_reversal",
441            PaymentUnreconciled => "payment_unreconciled",
442            Payout => "payout",
443            PayoutCancel => "payout_cancel",
444            PayoutFailure => "payout_failure",
445            PayoutMinimumBalanceHold => "payout_minimum_balance_hold",
446            PayoutMinimumBalanceRelease => "payout_minimum_balance_release",
447            Refund => "refund",
448            RefundFailure => "refund_failure",
449            ReserveTransaction => "reserve_transaction",
450            ReservedFunds => "reserved_funds",
451            StripeBalancePaymentDebit => "stripe_balance_payment_debit",
452            StripeBalancePaymentDebitReversal => "stripe_balance_payment_debit_reversal",
453            StripeFee => "stripe_fee",
454            StripeFxFee => "stripe_fx_fee",
455            TaxFee => "tax_fee",
456            Topup => "topup",
457            TopupReversal => "topup_reversal",
458            Transfer => "transfer",
459            TransferCancel => "transfer_cancel",
460            TransferFailure => "transfer_failure",
461            TransferRefund => "transfer_refund",
462            Unknown(v) => v,
463        }
464    }
465}
466
467impl std::str::FromStr for BalanceTransactionType {
468    type Err = std::convert::Infallible;
469    fn from_str(s: &str) -> Result<Self, Self::Err> {
470        use BalanceTransactionType::*;
471        match s {
472            "adjustment" => Ok(Adjustment),
473            "advance" => Ok(Advance),
474            "advance_funding" => Ok(AdvanceFunding),
475            "anticipation_repayment" => Ok(AnticipationRepayment),
476            "application_fee" => Ok(ApplicationFee),
477            "application_fee_refund" => Ok(ApplicationFeeRefund),
478            "charge" => Ok(Charge),
479            "climate_order_purchase" => Ok(ClimateOrderPurchase),
480            "climate_order_refund" => Ok(ClimateOrderRefund),
481            "connect_collection_transfer" => Ok(ConnectCollectionTransfer),
482            "contribution" => Ok(Contribution),
483            "issuing_authorization_hold" => Ok(IssuingAuthorizationHold),
484            "issuing_authorization_release" => Ok(IssuingAuthorizationRelease),
485            "issuing_dispute" => Ok(IssuingDispute),
486            "issuing_transaction" => Ok(IssuingTransaction),
487            "obligation_outbound" => Ok(ObligationOutbound),
488            "obligation_reversal_inbound" => Ok(ObligationReversalInbound),
489            "payment" => Ok(Payment),
490            "payment_failure_refund" => Ok(PaymentFailureRefund),
491            "payment_network_reserve_hold" => Ok(PaymentNetworkReserveHold),
492            "payment_network_reserve_release" => Ok(PaymentNetworkReserveRelease),
493            "payment_refund" => Ok(PaymentRefund),
494            "payment_reversal" => Ok(PaymentReversal),
495            "payment_unreconciled" => Ok(PaymentUnreconciled),
496            "payout" => Ok(Payout),
497            "payout_cancel" => Ok(PayoutCancel),
498            "payout_failure" => Ok(PayoutFailure),
499            "payout_minimum_balance_hold" => Ok(PayoutMinimumBalanceHold),
500            "payout_minimum_balance_release" => Ok(PayoutMinimumBalanceRelease),
501            "refund" => Ok(Refund),
502            "refund_failure" => Ok(RefundFailure),
503            "reserve_transaction" => Ok(ReserveTransaction),
504            "reserved_funds" => Ok(ReservedFunds),
505            "stripe_balance_payment_debit" => Ok(StripeBalancePaymentDebit),
506            "stripe_balance_payment_debit_reversal" => Ok(StripeBalancePaymentDebitReversal),
507            "stripe_fee" => Ok(StripeFee),
508            "stripe_fx_fee" => Ok(StripeFxFee),
509            "tax_fee" => Ok(TaxFee),
510            "topup" => Ok(Topup),
511            "topup_reversal" => Ok(TopupReversal),
512            "transfer" => Ok(Transfer),
513            "transfer_cancel" => Ok(TransferCancel),
514            "transfer_failure" => Ok(TransferFailure),
515            "transfer_refund" => Ok(TransferRefund),
516            v => {
517                tracing::warn!("Unknown value '{}' for enum '{}'", v, "BalanceTransactionType");
518                Ok(Unknown(v.to_owned()))
519            }
520        }
521    }
522}
523impl std::fmt::Display for BalanceTransactionType {
524    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
525        f.write_str(self.as_str())
526    }
527}
528
529impl std::fmt::Debug for BalanceTransactionType {
530    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
531        f.write_str(self.as_str())
532    }
533}
534#[cfg(feature = "serialize")]
535impl serde::Serialize for BalanceTransactionType {
536    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
537    where
538        S: serde::Serializer,
539    {
540        serializer.serialize_str(self.as_str())
541    }
542}
543impl miniserde::Deserialize for BalanceTransactionType {
544    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
545        crate::Place::new(out)
546    }
547}
548
549impl miniserde::de::Visitor for crate::Place<BalanceTransactionType> {
550    fn string(&mut self, s: &str) -> miniserde::Result<()> {
551        use std::str::FromStr;
552        self.out = Some(BalanceTransactionType::from_str(s).expect("infallible"));
553        Ok(())
554    }
555}
556
557stripe_types::impl_from_val_with_from_str!(BalanceTransactionType);
558#[cfg(feature = "deserialize")]
559impl<'de> serde::Deserialize<'de> for BalanceTransactionType {
560    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
561        use std::str::FromStr;
562        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
563        Ok(Self::from_str(&s).expect("infallible"))
564    }
565}
566impl stripe_types::Object for BalanceTransaction {
567    type Id = stripe_shared::BalanceTransactionId;
568    fn id(&self) -> &Self::Id {
569        &self.id
570    }
571
572    fn into_id(self) -> Self::Id {
573        self.id
574    }
575}
576stripe_types::def_id!(BalanceTransactionId);