async-stripe-shared 1.0.0-rc.6

API bindings for the Stripe HTTP API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
/// Balance transactions represent funds moving through your Stripe account.
/// Stripe creates them for every type of transaction that enters or leaves your Stripe account balance.
///
/// Related guide: [Balance transaction types](https://docs.stripe.com/reports/balance-transaction-types).
///
/// For more details see <<https://stripe.com/docs/api/balance_transactions/object>>.
#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
pub struct BalanceTransaction {
    /// Gross amount of this transaction (in cents (or local equivalent)).
    /// A positive value represents funds charged to another party, and a negative value represents funds sent to another party.
    pub amount: i64,
    /// The date that the transaction's net funds become available in the Stripe balance.
    pub available_on: stripe_types::Timestamp,
    /// The balance that this transaction impacts.
    pub balance_type: BalanceTransactionBalanceType,
    /// Time at which the object was created. Measured in seconds since the Unix epoch.
    pub created: stripe_types::Timestamp,
    /// 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).
    pub currency: stripe_types::Currency,
    /// An arbitrary string attached to the object. Often useful for displaying to users.
    pub description: Option<String>,
    /// If applicable, this transaction uses an exchange rate.
    /// 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.
    /// For example, if you charge a customer 10.00 EUR, the PaymentIntent's `amount` is `1000` and `currency` is `eur`.
    /// 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`.
    pub exchange_rate: Option<f64>,
    /// Fees (in cents (or local equivalent)) paid for this transaction.
    /// Represented as a positive integer when assessed.
    pub fee: i64,
    /// Detailed breakdown of fees (in cents (or local equivalent)) paid for this transaction.
    pub fee_details: Vec<stripe_shared::Fee>,
    /// Unique identifier for the object.
    pub id: stripe_shared::BalanceTransactionId,
    /// Net impact to a Stripe balance (in cents (or local equivalent)).
    /// A positive value represents incrementing a Stripe balance, and a negative value decrementing a Stripe balance.
    /// You can calculate the net impact of a transaction on a balance by `amount` - `fee`.
    pub net: i64,
    /// Learn more about how [reporting categories](https://stripe.com/docs/reports/reporting-categories) can help you understand balance transactions from an accounting perspective.
    pub reporting_category: String,
    /// This transaction relates to the Stripe object.
    pub source: Option<stripe_types::Expandable<stripe_shared::BalanceTransactionSource>>,
    /// The transaction's net funds status in the Stripe balance, which are either `available` or `pending`.
    pub status: String,
    /// Transaction type: `adjustment`, `advance`, `advance_funding`, `anticipation_repayment`, `application_fee`, `application_fee_refund`, `charge`, `climate_order_purchase`, `climate_order_refund`, `connect_collection_transfer`, `contribution`, `inbound_transfer`, `inbound_transfer_reversal`, `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`, `reserve_hold`, `reserve_release`, `stripe_fee`, `stripe_fx_fee`, `stripe_balance_payment_debit`, `stripe_balance_payment_debit_reversal`, `tax_fee`, `topup`, `topup_reversal`, `transfer`, `transfer_cancel`, `transfer_failure`, `transfer_refund`, or `fee_credit_funding`.
    /// Learn more about [balance transaction types and what they represent](https://stripe.com/docs/reports/balance-transaction-types).
    /// To classify transactions for accounting purposes, consider `reporting_category` instead.
    #[cfg_attr(feature = "deserialize", serde(rename = "type"))]
    pub type_: BalanceTransactionType,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for BalanceTransaction {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct("BalanceTransaction").finish_non_exhaustive()
    }
}
#[doc(hidden)]
pub struct BalanceTransactionBuilder {
    amount: Option<i64>,
    available_on: Option<stripe_types::Timestamp>,
    balance_type: Option<BalanceTransactionBalanceType>,
    created: Option<stripe_types::Timestamp>,
    currency: Option<stripe_types::Currency>,
    description: Option<Option<String>>,
    exchange_rate: Option<Option<f64>>,
    fee: Option<i64>,
    fee_details: Option<Vec<stripe_shared::Fee>>,
    id: Option<stripe_shared::BalanceTransactionId>,
    net: Option<i64>,
    reporting_category: Option<String>,
    source: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransactionSource>>>,
    status: Option<String>,
    type_: Option<BalanceTransactionType>,
}

#[allow(
    unused_variables,
    irrefutable_let_patterns,
    clippy::let_unit_value,
    clippy::match_single_binding,
    clippy::single_match
)]
const _: () = {
    use miniserde::de::{Map, Visitor};
    use miniserde::json::Value;
    use miniserde::{Deserialize, Result, make_place};
    use stripe_types::miniserde_helpers::FromValueOpt;
    use stripe_types::{MapBuilder, ObjectDeser};

    make_place!(Place);

    impl Deserialize for BalanceTransaction {
        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
            Place::new(out)
        }
    }

    struct Builder<'a> {
        out: &'a mut Option<BalanceTransaction>,
        builder: BalanceTransactionBuilder,
    }

    impl Visitor for Place<BalanceTransaction> {
        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
            Ok(Box::new(Builder {
                out: &mut self.out,
                builder: BalanceTransactionBuilder::deser_default(),
            }))
        }
    }

    impl MapBuilder for BalanceTransactionBuilder {
        type Out = BalanceTransaction;
        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
            Ok(match k {
                "amount" => Deserialize::begin(&mut self.amount),
                "available_on" => Deserialize::begin(&mut self.available_on),
                "balance_type" => Deserialize::begin(&mut self.balance_type),
                "created" => Deserialize::begin(&mut self.created),
                "currency" => Deserialize::begin(&mut self.currency),
                "description" => Deserialize::begin(&mut self.description),
                "exchange_rate" => Deserialize::begin(&mut self.exchange_rate),
                "fee" => Deserialize::begin(&mut self.fee),
                "fee_details" => Deserialize::begin(&mut self.fee_details),
                "id" => Deserialize::begin(&mut self.id),
                "net" => Deserialize::begin(&mut self.net),
                "reporting_category" => Deserialize::begin(&mut self.reporting_category),
                "source" => Deserialize::begin(&mut self.source),
                "status" => Deserialize::begin(&mut self.status),
                "type" => Deserialize::begin(&mut self.type_),
                _ => <dyn Visitor>::ignore(),
            })
        }

        fn deser_default() -> Self {
            Self {
                amount: None,
                available_on: None,
                balance_type: None,
                created: None,
                currency: None,
                description: Some(None),
                exchange_rate: Some(None),
                fee: None,
                fee_details: None,
                id: None,
                net: None,
                reporting_category: None,
                source: Some(None),
                status: None,
                type_: None,
            }
        }

        fn take_out(&mut self) -> Option<Self::Out> {
            let (
                Some(amount),
                Some(available_on),
                Some(balance_type),
                Some(created),
                Some(currency),
                Some(description),
                Some(exchange_rate),
                Some(fee),
                Some(fee_details),
                Some(id),
                Some(net),
                Some(reporting_category),
                Some(source),
                Some(status),
                Some(type_),
            ) = (
                self.amount,
                self.available_on,
                self.balance_type.take(),
                self.created,
                self.currency.take(),
                self.description.take(),
                self.exchange_rate,
                self.fee,
                self.fee_details.take(),
                self.id.take(),
                self.net,
                self.reporting_category.take(),
                self.source.take(),
                self.status.take(),
                self.type_.take(),
            )
            else {
                return None;
            };
            Some(Self::Out {
                amount,
                available_on,
                balance_type,
                created,
                currency,
                description,
                exchange_rate,
                fee,
                fee_details,
                id,
                net,
                reporting_category,
                source,
                status,
                type_,
            })
        }
    }

    impl Map for Builder<'_> {
        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
            self.builder.key(k)
        }

        fn finish(&mut self) -> Result<()> {
            *self.out = self.builder.take_out();
            Ok(())
        }
    }

    impl ObjectDeser for BalanceTransaction {
        type Builder = BalanceTransactionBuilder;
    }

    impl FromValueOpt for BalanceTransaction {
        fn from_value(v: Value) -> Option<Self> {
            let Value::Object(obj) = v else {
                return None;
            };
            let mut b = BalanceTransactionBuilder::deser_default();
            for (k, v) in obj {
                match k.as_str() {
                    "amount" => b.amount = FromValueOpt::from_value(v),
                    "available_on" => b.available_on = FromValueOpt::from_value(v),
                    "balance_type" => b.balance_type = FromValueOpt::from_value(v),
                    "created" => b.created = FromValueOpt::from_value(v),
                    "currency" => b.currency = FromValueOpt::from_value(v),
                    "description" => b.description = FromValueOpt::from_value(v),
                    "exchange_rate" => b.exchange_rate = FromValueOpt::from_value(v),
                    "fee" => b.fee = FromValueOpt::from_value(v),
                    "fee_details" => b.fee_details = FromValueOpt::from_value(v),
                    "id" => b.id = FromValueOpt::from_value(v),
                    "net" => b.net = FromValueOpt::from_value(v),
                    "reporting_category" => b.reporting_category = FromValueOpt::from_value(v),
                    "source" => b.source = FromValueOpt::from_value(v),
                    "status" => b.status = FromValueOpt::from_value(v),
                    "type" => b.type_ = FromValueOpt::from_value(v),
                    _ => {}
                }
            }
            b.take_out()
        }
    }
};
#[cfg(feature = "serialize")]
impl serde::Serialize for BalanceTransaction {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        use serde::ser::SerializeStruct;
        let mut s = s.serialize_struct("BalanceTransaction", 16)?;
        s.serialize_field("amount", &self.amount)?;
        s.serialize_field("available_on", &self.available_on)?;
        s.serialize_field("balance_type", &self.balance_type)?;
        s.serialize_field("created", &self.created)?;
        s.serialize_field("currency", &self.currency)?;
        s.serialize_field("description", &self.description)?;
        s.serialize_field("exchange_rate", &self.exchange_rate)?;
        s.serialize_field("fee", &self.fee)?;
        s.serialize_field("fee_details", &self.fee_details)?;
        s.serialize_field("id", &self.id)?;
        s.serialize_field("net", &self.net)?;
        s.serialize_field("reporting_category", &self.reporting_category)?;
        s.serialize_field("source", &self.source)?;
        s.serialize_field("status", &self.status)?;
        s.serialize_field("type", &self.type_)?;

        s.serialize_field("object", "balance_transaction")?;
        s.end()
    }
}
/// The balance that this transaction impacts.
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum BalanceTransactionBalanceType {
    Issuing,
    Payments,
    RefundAndDisputePrefunding,
    RiskReserved,
    /// An unrecognized value from Stripe. Should not be used as a request parameter.
    Unknown(String),
}
impl BalanceTransactionBalanceType {
    pub fn as_str(&self) -> &str {
        use BalanceTransactionBalanceType::*;
        match self {
            Issuing => "issuing",
            Payments => "payments",
            RefundAndDisputePrefunding => "refund_and_dispute_prefunding",
            RiskReserved => "risk_reserved",
            Unknown(v) => v,
        }
    }
}

impl std::str::FromStr for BalanceTransactionBalanceType {
    type Err = std::convert::Infallible;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        use BalanceTransactionBalanceType::*;
        match s {
            "issuing" => Ok(Issuing),
            "payments" => Ok(Payments),
            "refund_and_dispute_prefunding" => Ok(RefundAndDisputePrefunding),
            "risk_reserved" => Ok(RiskReserved),
            v => {
                tracing::warn!(
                    "Unknown value '{}' for enum '{}'",
                    v,
                    "BalanceTransactionBalanceType"
                );
                Ok(Unknown(v.to_owned()))
            }
        }
    }
}
impl std::fmt::Display for BalanceTransactionBalanceType {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for BalanceTransactionBalanceType {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for BalanceTransactionBalanceType {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct(stringify!(BalanceTransactionBalanceType)).finish_non_exhaustive()
    }
}
#[cfg(feature = "serialize")]
impl serde::Serialize for BalanceTransactionBalanceType {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
impl miniserde::Deserialize for BalanceTransactionBalanceType {
    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
        crate::Place::new(out)
    }
}

impl miniserde::de::Visitor for crate::Place<BalanceTransactionBalanceType> {
    fn string(&mut self, s: &str) -> miniserde::Result<()> {
        use std::str::FromStr;
        self.out = Some(BalanceTransactionBalanceType::from_str(s).expect("infallible"));
        Ok(())
    }
}

stripe_types::impl_from_val_with_from_str!(BalanceTransactionBalanceType);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for BalanceTransactionBalanceType {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        use std::str::FromStr;
        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
        Ok(Self::from_str(&s).expect("infallible"))
    }
}
/// Transaction type: `adjustment`, `advance`, `advance_funding`, `anticipation_repayment`, `application_fee`, `application_fee_refund`, `charge`, `climate_order_purchase`, `climate_order_refund`, `connect_collection_transfer`, `contribution`, `inbound_transfer`, `inbound_transfer_reversal`, `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`, `reserve_hold`, `reserve_release`, `stripe_fee`, `stripe_fx_fee`, `stripe_balance_payment_debit`, `stripe_balance_payment_debit_reversal`, `tax_fee`, `topup`, `topup_reversal`, `transfer`, `transfer_cancel`, `transfer_failure`, `transfer_refund`, or `fee_credit_funding`.
/// Learn more about [balance transaction types and what they represent](https://stripe.com/docs/reports/balance-transaction-types).
/// To classify transactions for accounting purposes, consider `reporting_category` instead.
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum BalanceTransactionType {
    Adjustment,
    Advance,
    AdvanceFunding,
    AnticipationRepayment,
    ApplicationFee,
    ApplicationFeeRefund,
    Charge,
    ClimateOrderPurchase,
    ClimateOrderRefund,
    ConnectCollectionTransfer,
    Contribution,
    FeeCreditFunding,
    InboundTransfer,
    InboundTransferReversal,
    IssuingAuthorizationHold,
    IssuingAuthorizationRelease,
    IssuingDispute,
    IssuingTransaction,
    ObligationOutbound,
    ObligationReversalInbound,
    Payment,
    PaymentFailureRefund,
    PaymentNetworkReserveHold,
    PaymentNetworkReserveRelease,
    PaymentRefund,
    PaymentReversal,
    PaymentUnreconciled,
    Payout,
    PayoutCancel,
    PayoutFailure,
    PayoutMinimumBalanceHold,
    PayoutMinimumBalanceRelease,
    Refund,
    RefundFailure,
    ReserveHold,
    ReserveRelease,
    ReserveTransaction,
    ReservedFunds,
    StripeBalancePaymentDebit,
    StripeBalancePaymentDebitReversal,
    StripeFee,
    StripeFxFee,
    TaxFee,
    Topup,
    TopupReversal,
    Transfer,
    TransferCancel,
    TransferFailure,
    TransferRefund,
    /// An unrecognized value from Stripe. Should not be used as a request parameter.
    Unknown(String),
}
impl BalanceTransactionType {
    pub fn as_str(&self) -> &str {
        use BalanceTransactionType::*;
        match self {
            Adjustment => "adjustment",
            Advance => "advance",
            AdvanceFunding => "advance_funding",
            AnticipationRepayment => "anticipation_repayment",
            ApplicationFee => "application_fee",
            ApplicationFeeRefund => "application_fee_refund",
            Charge => "charge",
            ClimateOrderPurchase => "climate_order_purchase",
            ClimateOrderRefund => "climate_order_refund",
            ConnectCollectionTransfer => "connect_collection_transfer",
            Contribution => "contribution",
            FeeCreditFunding => "fee_credit_funding",
            InboundTransfer => "inbound_transfer",
            InboundTransferReversal => "inbound_transfer_reversal",
            IssuingAuthorizationHold => "issuing_authorization_hold",
            IssuingAuthorizationRelease => "issuing_authorization_release",
            IssuingDispute => "issuing_dispute",
            IssuingTransaction => "issuing_transaction",
            ObligationOutbound => "obligation_outbound",
            ObligationReversalInbound => "obligation_reversal_inbound",
            Payment => "payment",
            PaymentFailureRefund => "payment_failure_refund",
            PaymentNetworkReserveHold => "payment_network_reserve_hold",
            PaymentNetworkReserveRelease => "payment_network_reserve_release",
            PaymentRefund => "payment_refund",
            PaymentReversal => "payment_reversal",
            PaymentUnreconciled => "payment_unreconciled",
            Payout => "payout",
            PayoutCancel => "payout_cancel",
            PayoutFailure => "payout_failure",
            PayoutMinimumBalanceHold => "payout_minimum_balance_hold",
            PayoutMinimumBalanceRelease => "payout_minimum_balance_release",
            Refund => "refund",
            RefundFailure => "refund_failure",
            ReserveHold => "reserve_hold",
            ReserveRelease => "reserve_release",
            ReserveTransaction => "reserve_transaction",
            ReservedFunds => "reserved_funds",
            StripeBalancePaymentDebit => "stripe_balance_payment_debit",
            StripeBalancePaymentDebitReversal => "stripe_balance_payment_debit_reversal",
            StripeFee => "stripe_fee",
            StripeFxFee => "stripe_fx_fee",
            TaxFee => "tax_fee",
            Topup => "topup",
            TopupReversal => "topup_reversal",
            Transfer => "transfer",
            TransferCancel => "transfer_cancel",
            TransferFailure => "transfer_failure",
            TransferRefund => "transfer_refund",
            Unknown(v) => v,
        }
    }
}

impl std::str::FromStr for BalanceTransactionType {
    type Err = std::convert::Infallible;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        use BalanceTransactionType::*;
        match s {
            "adjustment" => Ok(Adjustment),
            "advance" => Ok(Advance),
            "advance_funding" => Ok(AdvanceFunding),
            "anticipation_repayment" => Ok(AnticipationRepayment),
            "application_fee" => Ok(ApplicationFee),
            "application_fee_refund" => Ok(ApplicationFeeRefund),
            "charge" => Ok(Charge),
            "climate_order_purchase" => Ok(ClimateOrderPurchase),
            "climate_order_refund" => Ok(ClimateOrderRefund),
            "connect_collection_transfer" => Ok(ConnectCollectionTransfer),
            "contribution" => Ok(Contribution),
            "fee_credit_funding" => Ok(FeeCreditFunding),
            "inbound_transfer" => Ok(InboundTransfer),
            "inbound_transfer_reversal" => Ok(InboundTransferReversal),
            "issuing_authorization_hold" => Ok(IssuingAuthorizationHold),
            "issuing_authorization_release" => Ok(IssuingAuthorizationRelease),
            "issuing_dispute" => Ok(IssuingDispute),
            "issuing_transaction" => Ok(IssuingTransaction),
            "obligation_outbound" => Ok(ObligationOutbound),
            "obligation_reversal_inbound" => Ok(ObligationReversalInbound),
            "payment" => Ok(Payment),
            "payment_failure_refund" => Ok(PaymentFailureRefund),
            "payment_network_reserve_hold" => Ok(PaymentNetworkReserveHold),
            "payment_network_reserve_release" => Ok(PaymentNetworkReserveRelease),
            "payment_refund" => Ok(PaymentRefund),
            "payment_reversal" => Ok(PaymentReversal),
            "payment_unreconciled" => Ok(PaymentUnreconciled),
            "payout" => Ok(Payout),
            "payout_cancel" => Ok(PayoutCancel),
            "payout_failure" => Ok(PayoutFailure),
            "payout_minimum_balance_hold" => Ok(PayoutMinimumBalanceHold),
            "payout_minimum_balance_release" => Ok(PayoutMinimumBalanceRelease),
            "refund" => Ok(Refund),
            "refund_failure" => Ok(RefundFailure),
            "reserve_hold" => Ok(ReserveHold),
            "reserve_release" => Ok(ReserveRelease),
            "reserve_transaction" => Ok(ReserveTransaction),
            "reserved_funds" => Ok(ReservedFunds),
            "stripe_balance_payment_debit" => Ok(StripeBalancePaymentDebit),
            "stripe_balance_payment_debit_reversal" => Ok(StripeBalancePaymentDebitReversal),
            "stripe_fee" => Ok(StripeFee),
            "stripe_fx_fee" => Ok(StripeFxFee),
            "tax_fee" => Ok(TaxFee),
            "topup" => Ok(Topup),
            "topup_reversal" => Ok(TopupReversal),
            "transfer" => Ok(Transfer),
            "transfer_cancel" => Ok(TransferCancel),
            "transfer_failure" => Ok(TransferFailure),
            "transfer_refund" => Ok(TransferRefund),
            v => {
                tracing::warn!("Unknown value '{}' for enum '{}'", v, "BalanceTransactionType");
                Ok(Unknown(v.to_owned()))
            }
        }
    }
}
impl std::fmt::Display for BalanceTransactionType {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for BalanceTransactionType {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for BalanceTransactionType {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct(stringify!(BalanceTransactionType)).finish_non_exhaustive()
    }
}
#[cfg(feature = "serialize")]
impl serde::Serialize for BalanceTransactionType {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}
impl miniserde::Deserialize for BalanceTransactionType {
    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
        crate::Place::new(out)
    }
}

impl miniserde::de::Visitor for crate::Place<BalanceTransactionType> {
    fn string(&mut self, s: &str) -> miniserde::Result<()> {
        use std::str::FromStr;
        self.out = Some(BalanceTransactionType::from_str(s).expect("infallible"));
        Ok(())
    }
}

stripe_types::impl_from_val_with_from_str!(BalanceTransactionType);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for BalanceTransactionType {
    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        use std::str::FromStr;
        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
        Ok(Self::from_str(&s).expect("infallible"))
    }
}
impl stripe_types::Object for BalanceTransaction {
    type Id = stripe_shared::BalanceTransactionId;
    fn id(&self) -> &Self::Id {
        &self.id
    }

    fn into_id(self) -> Self::Id {
        self.id
    }
}
stripe_types::def_id!(BalanceTransactionId);