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
#[derive(Clone, Eq, PartialEq)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
pub struct PaymentMethodDetailsCard {
    /// The authorized amount.
pub amount_authorized: Option<i64>,
    /// Authorization code on the charge.
pub authorization_code: Option<String>,
        /// Card brand.
    /// Can be `amex`, `cartes_bancaires`, `diners`, `discover`, `eftpos_au`, `jcb`, `link`, `mastercard`, `unionpay`, `visa` or `unknown`.
pub brand: Option<String>,
        /// When using manual capture, a future timestamp at which the charge will be automatically refunded if uncaptured.
pub capture_before: Option<stripe_types::Timestamp>,
    /// Check results by Card networks on Card address and CVC at time of payment.
pub checks: Option<stripe_shared::PaymentMethodDetailsCardChecks>,
        /// Two-letter ISO code representing the country of the card.
    /// You could use this attribute to get a sense of the international breakdown of cards you've collected.
pub country: Option<String>,
        /// A high-level description of the type of cards issued in this range.
    /// (For internal use only and not typically available in standard API requests.).
pub description: Option<String>,
    /// Two-digit number representing the card's expiration month.
pub exp_month: i64,
    /// Four-digit number representing the card's expiration year.
pub exp_year: i64,
pub extended_authorization: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorization>,
        /// Uniquely identifies this particular card number.
    /// You can use this attribute to check whether two customers who’ve signed up with you are using the same card number, for example.
    /// For payment methods that tokenize card information (Apple Pay, Google Pay), the tokenized number might be provided instead of the underlying card number.
    ///
        /// *As of May 1, 2021, card fingerprint in India for Connect changed to allow two fingerprints for the same card---one for India and one for the rest of the world.*.
pub fingerprint: Option<String>,
    /// Card funding type. Can be `credit`, `debit`, `prepaid`, or `unknown`.
pub funding: Option<String>,
        /// Issuer identification number of the card.
    /// (For internal use only and not typically available in standard API requests.).
pub iin: Option<String>,
pub incremental_authorization: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorization>,
    /// Installment details for this payment.
    ///
        /// For more information, see the [installments integration guide](https://docs.stripe.com/payments/installments).
pub installments: Option<stripe_shared::PaymentMethodDetailsCardInstallments>,
        /// The name of the card's issuing bank.
    /// (For internal use only and not typically available in standard API requests.).
pub issuer: Option<String>,
    /// The last four digits of the card.
pub last4: Option<String>,
    /// ID of the mandate used to make this payment or created by it.
pub mandate: Option<String>,
    /// True if this payment was marked as MOTO and out of scope for SCA.
pub moto: Option<bool>,
pub multicapture: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticapture>,
        /// Identifies which network this charge was processed on.
    /// Can be `amex`, `cartes_bancaires`, `diners`, `discover`, `eftpos_au`, `interac`, `jcb`, `link`, `mastercard`, `unionpay`, `visa`, or `unknown`.
pub network: Option<String>,
        /// If this card has network token credentials, this contains the details of the network token credentials.
pub network_token: Option<stripe_shared::PaymentMethodDetailsCardNetworkToken>,
        /// This is used by the financial networks to identify a transaction.
    /// Visa calls this the Transaction ID, Mastercard calls this the Trace ID, and American Express calls this the Acquirer Reference Data.
    /// This value will be present if it is returned by the financial network in the authorization response, and null otherwise.
pub network_transaction_id: Option<String>,
pub overcapture: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercapture>,
    /// Status of a card based on the card issuer.
pub regulated_status: Option<PaymentMethodDetailsCardRegulatedStatus>,
    /// Populated if this transaction used 3D Secure authentication.
pub three_d_secure: Option<stripe_shared::ThreeDSecureDetailsCharge>,
    /// If this Card is part of a card wallet, this contains the details of the card wallet.
pub wallet: Option<stripe_shared::PaymentMethodDetailsCardWallet>,

}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentMethodDetailsCard {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct("PaymentMethodDetailsCard").finish_non_exhaustive()
    }
}
#[doc(hidden)]
pub struct PaymentMethodDetailsCardBuilder {
    amount_authorized: Option<Option<i64>>,
authorization_code: Option<Option<String>>,
brand: Option<Option<String>>,
capture_before: Option<Option<stripe_types::Timestamp>>,
checks: Option<Option<stripe_shared::PaymentMethodDetailsCardChecks>>,
country: Option<Option<String>>,
description: Option<Option<String>>,
exp_month: Option<i64>,
exp_year: Option<i64>,
extended_authorization: Option<Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorization>>,
fingerprint: Option<Option<String>>,
funding: Option<Option<String>>,
iin: Option<Option<String>>,
incremental_authorization: Option<Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorization>>,
installments: Option<Option<stripe_shared::PaymentMethodDetailsCardInstallments>>,
issuer: Option<Option<String>>,
last4: Option<Option<String>>,
mandate: Option<Option<String>>,
moto: Option<Option<bool>>,
multicapture: Option<Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticapture>>,
network: Option<Option<String>>,
network_token: Option<Option<stripe_shared::PaymentMethodDetailsCardNetworkToken>>,
network_transaction_id: Option<Option<String>>,
overcapture: Option<Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercapture>>,
regulated_status: Option<Option<PaymentMethodDetailsCardRegulatedStatus>>,
three_d_secure: Option<Option<stripe_shared::ThreeDSecureDetailsCharge>>,
wallet: Option<Option<stripe_shared::PaymentMethodDetailsCardWallet>>,

}

#[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 PaymentMethodDetailsCard {
        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
            Place::new(out)
        }
    }

    struct Builder<'a> {
        out: &'a mut Option<PaymentMethodDetailsCard>,
        builder: PaymentMethodDetailsCardBuilder,
    }

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

    impl MapBuilder for PaymentMethodDetailsCardBuilder {
        type Out = PaymentMethodDetailsCard;
        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
            Ok(match k {
                "amount_authorized" => Deserialize::begin(&mut self.amount_authorized),
                "authorization_code" => Deserialize::begin(&mut self.authorization_code),
                "brand" => Deserialize::begin(&mut self.brand),
                "capture_before" => Deserialize::begin(&mut self.capture_before),
                "checks" => Deserialize::begin(&mut self.checks),
                "country" => Deserialize::begin(&mut self.country),
                "description" => Deserialize::begin(&mut self.description),
                "exp_month" => Deserialize::begin(&mut self.exp_month),
                "exp_year" => Deserialize::begin(&mut self.exp_year),
                "extended_authorization" => Deserialize::begin(&mut self.extended_authorization),
                "fingerprint" => Deserialize::begin(&mut self.fingerprint),
                "funding" => Deserialize::begin(&mut self.funding),
                "iin" => Deserialize::begin(&mut self.iin),
                "incremental_authorization" => {
                    Deserialize::begin(&mut self.incremental_authorization)
                }
                "installments" => Deserialize::begin(&mut self.installments),
                "issuer" => Deserialize::begin(&mut self.issuer),
                "last4" => Deserialize::begin(&mut self.last4),
                "mandate" => Deserialize::begin(&mut self.mandate),
                "moto" => Deserialize::begin(&mut self.moto),
                "multicapture" => Deserialize::begin(&mut self.multicapture),
                "network" => Deserialize::begin(&mut self.network),
                "network_token" => Deserialize::begin(&mut self.network_token),
                "network_transaction_id" => Deserialize::begin(&mut self.network_transaction_id),
                "overcapture" => Deserialize::begin(&mut self.overcapture),
                "regulated_status" => Deserialize::begin(&mut self.regulated_status),
                "three_d_secure" => Deserialize::begin(&mut self.three_d_secure),
                "wallet" => Deserialize::begin(&mut self.wallet),
                _ => <dyn Visitor>::ignore(),
            })
        }

        fn deser_default() -> Self {
            Self {
                amount_authorized: Some(None),
                authorization_code: Some(None),
                brand: Some(None),
                capture_before: Some(None),
                checks: Some(None),
                country: Some(None),
                description: Some(None),
                exp_month: None,
                exp_year: None,
                extended_authorization: Some(None),
                fingerprint: Some(None),
                funding: Some(None),
                iin: Some(None),
                incremental_authorization: Some(None),
                installments: Some(None),
                issuer: Some(None),
                last4: Some(None),
                mandate: Some(None),
                moto: Some(None),
                multicapture: Some(None),
                network: Some(None),
                network_token: Some(None),
                network_transaction_id: Some(None),
                overcapture: Some(None),
                regulated_status: Some(None),
                three_d_secure: Some(None),
                wallet: Some(None),
            }
        }

        fn take_out(&mut self) -> Option<Self::Out> {
            let (
                Some(amount_authorized),
                Some(authorization_code),
                Some(brand),
                Some(capture_before),
                Some(checks),
                Some(country),
                Some(description),
                Some(exp_month),
                Some(exp_year),
                Some(extended_authorization),
                Some(fingerprint),
                Some(funding),
                Some(iin),
                Some(incremental_authorization),
                Some(installments),
                Some(issuer),
                Some(last4),
                Some(mandate),
                Some(moto),
                Some(multicapture),
                Some(network),
                Some(network_token),
                Some(network_transaction_id),
                Some(overcapture),
                Some(regulated_status),
                Some(three_d_secure),
                Some(wallet),
            ) = (
                self.amount_authorized,
                self.authorization_code.take(),
                self.brand.take(),
                self.capture_before,
                self.checks.take(),
                self.country.take(),
                self.description.take(),
                self.exp_month,
                self.exp_year,
                self.extended_authorization.take(),
                self.fingerprint.take(),
                self.funding.take(),
                self.iin.take(),
                self.incremental_authorization.take(),
                self.installments.take(),
                self.issuer.take(),
                self.last4.take(),
                self.mandate.take(),
                self.moto,
                self.multicapture.take(),
                self.network.take(),
                self.network_token,
                self.network_transaction_id.take(),
                self.overcapture.take(),
                self.regulated_status.take(),
                self.three_d_secure.take(),
                self.wallet.take(),
            )
            else {
                return None;
            };
            Some(Self::Out {
                amount_authorized,
                authorization_code,
                brand,
                capture_before,
                checks,
                country,
                description,
                exp_month,
                exp_year,
                extended_authorization,
                fingerprint,
                funding,
                iin,
                incremental_authorization,
                installments,
                issuer,
                last4,
                mandate,
                moto,
                multicapture,
                network,
                network_token,
                network_transaction_id,
                overcapture,
                regulated_status,
                three_d_secure,
                wallet,
            })
        }
    }

    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 PaymentMethodDetailsCard {
        type Builder = PaymentMethodDetailsCardBuilder;
    }

    impl FromValueOpt for PaymentMethodDetailsCard {
        fn from_value(v: Value) -> Option<Self> {
            let Value::Object(obj) = v else {
                return None;
            };
            let mut b = PaymentMethodDetailsCardBuilder::deser_default();
            for (k, v) in obj {
                match k.as_str() {
                    "amount_authorized" => b.amount_authorized = FromValueOpt::from_value(v),
                    "authorization_code" => b.authorization_code = FromValueOpt::from_value(v),
                    "brand" => b.brand = FromValueOpt::from_value(v),
                    "capture_before" => b.capture_before = FromValueOpt::from_value(v),
                    "checks" => b.checks = FromValueOpt::from_value(v),
                    "country" => b.country = FromValueOpt::from_value(v),
                    "description" => b.description = FromValueOpt::from_value(v),
                    "exp_month" => b.exp_month = FromValueOpt::from_value(v),
                    "exp_year" => b.exp_year = FromValueOpt::from_value(v),
                    "extended_authorization" => {
                        b.extended_authorization = FromValueOpt::from_value(v)
                    }
                    "fingerprint" => b.fingerprint = FromValueOpt::from_value(v),
                    "funding" => b.funding = FromValueOpt::from_value(v),
                    "iin" => b.iin = FromValueOpt::from_value(v),
                    "incremental_authorization" => {
                        b.incremental_authorization = FromValueOpt::from_value(v)
                    }
                    "installments" => b.installments = FromValueOpt::from_value(v),
                    "issuer" => b.issuer = FromValueOpt::from_value(v),
                    "last4" => b.last4 = FromValueOpt::from_value(v),
                    "mandate" => b.mandate = FromValueOpt::from_value(v),
                    "moto" => b.moto = FromValueOpt::from_value(v),
                    "multicapture" => b.multicapture = FromValueOpt::from_value(v),
                    "network" => b.network = FromValueOpt::from_value(v),
                    "network_token" => b.network_token = FromValueOpt::from_value(v),
                    "network_transaction_id" => {
                        b.network_transaction_id = FromValueOpt::from_value(v)
                    }
                    "overcapture" => b.overcapture = FromValueOpt::from_value(v),
                    "regulated_status" => b.regulated_status = FromValueOpt::from_value(v),
                    "three_d_secure" => b.three_d_secure = FromValueOpt::from_value(v),
                    "wallet" => b.wallet = FromValueOpt::from_value(v),
                    _ => {}
                }
            }
            b.take_out()
        }
    }
};
/// Status of a card based on the card issuer.
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum PaymentMethodDetailsCardRegulatedStatus {
    Regulated,
    Unregulated,
    /// An unrecognized value from Stripe. Should not be used as a request parameter.
    Unknown(String),
}
impl PaymentMethodDetailsCardRegulatedStatus {
    pub fn as_str(&self) -> &str {
        use PaymentMethodDetailsCardRegulatedStatus::*;
        match self {
            Regulated => "regulated",
            Unregulated => "unregulated",
            Unknown(v) => v,
        }
    }
}

impl std::str::FromStr for PaymentMethodDetailsCardRegulatedStatus {
    type Err = std::convert::Infallible;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        use PaymentMethodDetailsCardRegulatedStatus::*;
        match s {
            "regulated" => Ok(Regulated),
            "unregulated" => Ok(Unregulated),
            v => {
                tracing::warn!(
                    "Unknown value '{}' for enum '{}'",
                    v,
                    "PaymentMethodDetailsCardRegulatedStatus"
                );
                Ok(Unknown(v.to_owned()))
            }
        }
    }
}
impl std::fmt::Display for PaymentMethodDetailsCardRegulatedStatus {
    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 PaymentMethodDetailsCardRegulatedStatus {
    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 PaymentMethodDetailsCardRegulatedStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        f.debug_struct(stringify!(PaymentMethodDetailsCardRegulatedStatus)).finish_non_exhaustive()
    }
}
#[cfg(feature = "serialize")]
impl serde::Serialize for PaymentMethodDetailsCardRegulatedStatus {
    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 PaymentMethodDetailsCardRegulatedStatus {
    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
        crate::Place::new(out)
    }
}

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

stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsCardRegulatedStatus);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsCardRegulatedStatus {
    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"))
    }
}