1#[derive(Clone, Debug)]
15#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
16pub struct PaymentIntent {
17 pub amount: i64,
22 pub amount_capturable: i64,
24 pub amount_details: Option<stripe_shared::PaymentFlowsAmountDetails>,
25 pub amount_received: i64,
27 pub application: Option<stripe_types::Expandable<stripe_shared::Application>>,
29 pub application_fee_amount: Option<i64>,
33 pub automatic_payment_methods:
35 Option<stripe_shared::PaymentFlowsAutomaticPaymentMethodsPaymentIntent>,
36 pub canceled_at: Option<stripe_types::Timestamp>,
39 pub cancellation_reason: Option<PaymentIntentCancellationReason>,
41 pub capture_method: stripe_shared::PaymentIntentCaptureMethod,
43 pub client_secret: Option<String>,
51 pub confirmation_method: stripe_shared::PaymentIntentConfirmationMethod,
53 pub created: stripe_types::Timestamp,
55 pub currency: stripe_types::Currency,
58 pub customer: Option<stripe_types::Expandable<stripe_shared::Customer>>,
65 pub description: Option<String>,
67 pub excluded_payment_method_types:
69 Option<Vec<stripe_shared::PaymentIntentExcludedPaymentMethodTypes>>,
70 pub id: stripe_shared::PaymentIntentId,
72 pub last_payment_error: Option<Box<stripe_shared::ApiErrors>>,
75 pub latest_charge: Option<stripe_types::Expandable<stripe_shared::Charge>>,
78 pub livemode: bool,
80 pub metadata: std::collections::HashMap<String, String>,
84 pub next_action: Option<stripe_shared::PaymentIntentNextAction>,
86 pub on_behalf_of: Option<stripe_types::Expandable<stripe_shared::Account>>,
89 pub payment_method: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>,
91 pub payment_method_configuration_details:
93 Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>,
94 pub payment_method_options: Option<stripe_shared::PaymentIntentPaymentMethodOptions>,
96 pub payment_method_types: Vec<String>,
100 pub presentment_details: Option<stripe_shared::PaymentFlowsPaymentIntentPresentmentDetails>,
101 pub processing: Option<stripe_shared::PaymentIntentProcessing>,
103 pub receipt_email: Option<String>,
106 pub review: Option<stripe_types::Expandable<stripe_shared::Review>>,
108 pub setup_future_usage: Option<stripe_shared::PaymentIntentSetupFutureUsage>,
117 pub shipping: Option<stripe_shared::Shipping>,
119 pub source: Option<stripe_types::Expandable<stripe_shared::PaymentSource>>,
122 pub statement_descriptor: Option<String>,
129 pub statement_descriptor_suffix: Option<String>,
132 pub status: PaymentIntentStatus,
135 pub transfer_data: Option<stripe_shared::TransferData>,
138 pub transfer_group: Option<String>,
141}
142#[doc(hidden)]
143pub struct PaymentIntentBuilder {
144 amount: Option<i64>,
145 amount_capturable: Option<i64>,
146 amount_details: Option<Option<stripe_shared::PaymentFlowsAmountDetails>>,
147 amount_received: Option<i64>,
148 application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>,
149 application_fee_amount: Option<Option<i64>>,
150 automatic_payment_methods:
151 Option<Option<stripe_shared::PaymentFlowsAutomaticPaymentMethodsPaymentIntent>>,
152 canceled_at: Option<Option<stripe_types::Timestamp>>,
153 cancellation_reason: Option<Option<PaymentIntentCancellationReason>>,
154 capture_method: Option<stripe_shared::PaymentIntentCaptureMethod>,
155 client_secret: Option<Option<String>>,
156 confirmation_method: Option<stripe_shared::PaymentIntentConfirmationMethod>,
157 created: Option<stripe_types::Timestamp>,
158 currency: Option<stripe_types::Currency>,
159 customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>,
160 description: Option<Option<String>>,
161 excluded_payment_method_types:
162 Option<Option<Vec<stripe_shared::PaymentIntentExcludedPaymentMethodTypes>>>,
163 id: Option<stripe_shared::PaymentIntentId>,
164 last_payment_error: Option<Option<Box<stripe_shared::ApiErrors>>>,
165 latest_charge: Option<Option<stripe_types::Expandable<stripe_shared::Charge>>>,
166 livemode: Option<bool>,
167 metadata: Option<std::collections::HashMap<String, String>>,
168 next_action: Option<Option<stripe_shared::PaymentIntentNextAction>>,
169 on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>,
170 payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>,
171 payment_method_configuration_details:
172 Option<Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>>,
173 payment_method_options: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptions>>,
174 payment_method_types: Option<Vec<String>>,
175 presentment_details: Option<Option<stripe_shared::PaymentFlowsPaymentIntentPresentmentDetails>>,
176 processing: Option<Option<stripe_shared::PaymentIntentProcessing>>,
177 receipt_email: Option<Option<String>>,
178 review: Option<Option<stripe_types::Expandable<stripe_shared::Review>>>,
179 setup_future_usage: Option<Option<stripe_shared::PaymentIntentSetupFutureUsage>>,
180 shipping: Option<Option<stripe_shared::Shipping>>,
181 source: Option<Option<stripe_types::Expandable<stripe_shared::PaymentSource>>>,
182 statement_descriptor: Option<Option<String>>,
183 statement_descriptor_suffix: Option<Option<String>>,
184 status: Option<PaymentIntentStatus>,
185 transfer_data: Option<Option<stripe_shared::TransferData>>,
186 transfer_group: Option<Option<String>>,
187}
188
189#[allow(
190 unused_variables,
191 irrefutable_let_patterns,
192 clippy::let_unit_value,
193 clippy::match_single_binding,
194 clippy::single_match
195)]
196const _: () = {
197 use miniserde::de::{Map, Visitor};
198 use miniserde::json::Value;
199 use miniserde::{Deserialize, Result, make_place};
200 use stripe_types::miniserde_helpers::FromValueOpt;
201 use stripe_types::{MapBuilder, ObjectDeser};
202
203 make_place!(Place);
204
205 impl Deserialize for PaymentIntent {
206 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
207 Place::new(out)
208 }
209 }
210
211 struct Builder<'a> {
212 out: &'a mut Option<PaymentIntent>,
213 builder: PaymentIntentBuilder,
214 }
215
216 impl Visitor for Place<PaymentIntent> {
217 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
218 Ok(Box::new(Builder {
219 out: &mut self.out,
220 builder: PaymentIntentBuilder::deser_default(),
221 }))
222 }
223 }
224
225 impl MapBuilder for PaymentIntentBuilder {
226 type Out = PaymentIntent;
227 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
228 Ok(match k {
229 "amount" => Deserialize::begin(&mut self.amount),
230 "amount_capturable" => Deserialize::begin(&mut self.amount_capturable),
231 "amount_details" => Deserialize::begin(&mut self.amount_details),
232 "amount_received" => Deserialize::begin(&mut self.amount_received),
233 "application" => Deserialize::begin(&mut self.application),
234 "application_fee_amount" => Deserialize::begin(&mut self.application_fee_amount),
235 "automatic_payment_methods" => {
236 Deserialize::begin(&mut self.automatic_payment_methods)
237 }
238 "canceled_at" => Deserialize::begin(&mut self.canceled_at),
239 "cancellation_reason" => Deserialize::begin(&mut self.cancellation_reason),
240 "capture_method" => Deserialize::begin(&mut self.capture_method),
241 "client_secret" => Deserialize::begin(&mut self.client_secret),
242 "confirmation_method" => Deserialize::begin(&mut self.confirmation_method),
243 "created" => Deserialize::begin(&mut self.created),
244 "currency" => Deserialize::begin(&mut self.currency),
245 "customer" => Deserialize::begin(&mut self.customer),
246 "description" => Deserialize::begin(&mut self.description),
247 "excluded_payment_method_types" => {
248 Deserialize::begin(&mut self.excluded_payment_method_types)
249 }
250 "id" => Deserialize::begin(&mut self.id),
251 "last_payment_error" => Deserialize::begin(&mut self.last_payment_error),
252 "latest_charge" => Deserialize::begin(&mut self.latest_charge),
253 "livemode" => Deserialize::begin(&mut self.livemode),
254 "metadata" => Deserialize::begin(&mut self.metadata),
255 "next_action" => Deserialize::begin(&mut self.next_action),
256 "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of),
257 "payment_method" => Deserialize::begin(&mut self.payment_method),
258 "payment_method_configuration_details" => {
259 Deserialize::begin(&mut self.payment_method_configuration_details)
260 }
261 "payment_method_options" => Deserialize::begin(&mut self.payment_method_options),
262 "payment_method_types" => Deserialize::begin(&mut self.payment_method_types),
263 "presentment_details" => Deserialize::begin(&mut self.presentment_details),
264 "processing" => Deserialize::begin(&mut self.processing),
265 "receipt_email" => Deserialize::begin(&mut self.receipt_email),
266 "review" => Deserialize::begin(&mut self.review),
267 "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
268 "shipping" => Deserialize::begin(&mut self.shipping),
269 "source" => Deserialize::begin(&mut self.source),
270 "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor),
271 "statement_descriptor_suffix" => {
272 Deserialize::begin(&mut self.statement_descriptor_suffix)
273 }
274 "status" => Deserialize::begin(&mut self.status),
275 "transfer_data" => Deserialize::begin(&mut self.transfer_data),
276 "transfer_group" => Deserialize::begin(&mut self.transfer_group),
277
278 _ => <dyn Visitor>::ignore(),
279 })
280 }
281
282 fn deser_default() -> Self {
283 Self {
284 amount: Deserialize::default(),
285 amount_capturable: Deserialize::default(),
286 amount_details: Deserialize::default(),
287 amount_received: Deserialize::default(),
288 application: Deserialize::default(),
289 application_fee_amount: Deserialize::default(),
290 automatic_payment_methods: Deserialize::default(),
291 canceled_at: Deserialize::default(),
292 cancellation_reason: Deserialize::default(),
293 capture_method: Deserialize::default(),
294 client_secret: Deserialize::default(),
295 confirmation_method: Deserialize::default(),
296 created: Deserialize::default(),
297 currency: Deserialize::default(),
298 customer: Deserialize::default(),
299 description: Deserialize::default(),
300 excluded_payment_method_types: Deserialize::default(),
301 id: Deserialize::default(),
302 last_payment_error: Deserialize::default(),
303 latest_charge: Deserialize::default(),
304 livemode: Deserialize::default(),
305 metadata: Deserialize::default(),
306 next_action: Deserialize::default(),
307 on_behalf_of: Deserialize::default(),
308 payment_method: Deserialize::default(),
309 payment_method_configuration_details: Deserialize::default(),
310 payment_method_options: Deserialize::default(),
311 payment_method_types: Deserialize::default(),
312 presentment_details: Deserialize::default(),
313 processing: Deserialize::default(),
314 receipt_email: Deserialize::default(),
315 review: Deserialize::default(),
316 setup_future_usage: Deserialize::default(),
317 shipping: Deserialize::default(),
318 source: Deserialize::default(),
319 statement_descriptor: Deserialize::default(),
320 statement_descriptor_suffix: Deserialize::default(),
321 status: Deserialize::default(),
322 transfer_data: Deserialize::default(),
323 transfer_group: Deserialize::default(),
324 }
325 }
326
327 fn take_out(&mut self) -> Option<Self::Out> {
328 let (
329 Some(amount),
330 Some(amount_capturable),
331 Some(amount_details),
332 Some(amount_received),
333 Some(application),
334 Some(application_fee_amount),
335 Some(automatic_payment_methods),
336 Some(canceled_at),
337 Some(cancellation_reason),
338 Some(capture_method),
339 Some(client_secret),
340 Some(confirmation_method),
341 Some(created),
342 Some(currency),
343 Some(customer),
344 Some(description),
345 Some(excluded_payment_method_types),
346 Some(id),
347 Some(last_payment_error),
348 Some(latest_charge),
349 Some(livemode),
350 Some(metadata),
351 Some(next_action),
352 Some(on_behalf_of),
353 Some(payment_method),
354 Some(payment_method_configuration_details),
355 Some(payment_method_options),
356 Some(payment_method_types),
357 Some(presentment_details),
358 Some(processing),
359 Some(receipt_email),
360 Some(review),
361 Some(setup_future_usage),
362 Some(shipping),
363 Some(source),
364 Some(statement_descriptor),
365 Some(statement_descriptor_suffix),
366 Some(status),
367 Some(transfer_data),
368 Some(transfer_group),
369 ) = (
370 self.amount,
371 self.amount_capturable,
372 self.amount_details,
373 self.amount_received,
374 self.application.take(),
375 self.application_fee_amount,
376 self.automatic_payment_methods,
377 self.canceled_at,
378 self.cancellation_reason,
379 self.capture_method,
380 self.client_secret.take(),
381 self.confirmation_method,
382 self.created,
383 self.currency.take(),
384 self.customer.take(),
385 self.description.take(),
386 self.excluded_payment_method_types.take(),
387 self.id.take(),
388 self.last_payment_error.take(),
389 self.latest_charge.take(),
390 self.livemode,
391 self.metadata.take(),
392 self.next_action.take(),
393 self.on_behalf_of.take(),
394 self.payment_method.take(),
395 self.payment_method_configuration_details.take(),
396 self.payment_method_options.take(),
397 self.payment_method_types.take(),
398 self.presentment_details.take(),
399 self.processing,
400 self.receipt_email.take(),
401 self.review.take(),
402 self.setup_future_usage,
403 self.shipping.take(),
404 self.source.take(),
405 self.statement_descriptor.take(),
406 self.statement_descriptor_suffix.take(),
407 self.status,
408 self.transfer_data.take(),
409 self.transfer_group.take(),
410 )
411 else {
412 return None;
413 };
414 Some(Self::Out {
415 amount,
416 amount_capturable,
417 amount_details,
418 amount_received,
419 application,
420 application_fee_amount,
421 automatic_payment_methods,
422 canceled_at,
423 cancellation_reason,
424 capture_method,
425 client_secret,
426 confirmation_method,
427 created,
428 currency,
429 customer,
430 description,
431 excluded_payment_method_types,
432 id,
433 last_payment_error,
434 latest_charge,
435 livemode,
436 metadata,
437 next_action,
438 on_behalf_of,
439 payment_method,
440 payment_method_configuration_details,
441 payment_method_options,
442 payment_method_types,
443 presentment_details,
444 processing,
445 receipt_email,
446 review,
447 setup_future_usage,
448 shipping,
449 source,
450 statement_descriptor,
451 statement_descriptor_suffix,
452 status,
453 transfer_data,
454 transfer_group,
455 })
456 }
457 }
458
459 impl Map for Builder<'_> {
460 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
461 self.builder.key(k)
462 }
463
464 fn finish(&mut self) -> Result<()> {
465 *self.out = self.builder.take_out();
466 Ok(())
467 }
468 }
469
470 impl ObjectDeser for PaymentIntent {
471 type Builder = PaymentIntentBuilder;
472 }
473
474 impl FromValueOpt for PaymentIntent {
475 fn from_value(v: Value) -> Option<Self> {
476 let Value::Object(obj) = v else {
477 return None;
478 };
479 let mut b = PaymentIntentBuilder::deser_default();
480 for (k, v) in obj {
481 match k.as_str() {
482 "amount" => b.amount = FromValueOpt::from_value(v),
483 "amount_capturable" => b.amount_capturable = FromValueOpt::from_value(v),
484 "amount_details" => b.amount_details = FromValueOpt::from_value(v),
485 "amount_received" => b.amount_received = FromValueOpt::from_value(v),
486 "application" => b.application = FromValueOpt::from_value(v),
487 "application_fee_amount" => {
488 b.application_fee_amount = FromValueOpt::from_value(v)
489 }
490 "automatic_payment_methods" => {
491 b.automatic_payment_methods = FromValueOpt::from_value(v)
492 }
493 "canceled_at" => b.canceled_at = FromValueOpt::from_value(v),
494 "cancellation_reason" => b.cancellation_reason = FromValueOpt::from_value(v),
495 "capture_method" => b.capture_method = FromValueOpt::from_value(v),
496 "client_secret" => b.client_secret = FromValueOpt::from_value(v),
497 "confirmation_method" => b.confirmation_method = FromValueOpt::from_value(v),
498 "created" => b.created = FromValueOpt::from_value(v),
499 "currency" => b.currency = FromValueOpt::from_value(v),
500 "customer" => b.customer = FromValueOpt::from_value(v),
501 "description" => b.description = FromValueOpt::from_value(v),
502 "excluded_payment_method_types" => {
503 b.excluded_payment_method_types = FromValueOpt::from_value(v)
504 }
505 "id" => b.id = FromValueOpt::from_value(v),
506 "last_payment_error" => b.last_payment_error = FromValueOpt::from_value(v),
507 "latest_charge" => b.latest_charge = FromValueOpt::from_value(v),
508 "livemode" => b.livemode = FromValueOpt::from_value(v),
509 "metadata" => b.metadata = FromValueOpt::from_value(v),
510 "next_action" => b.next_action = FromValueOpt::from_value(v),
511 "on_behalf_of" => b.on_behalf_of = FromValueOpt::from_value(v),
512 "payment_method" => b.payment_method = FromValueOpt::from_value(v),
513 "payment_method_configuration_details" => {
514 b.payment_method_configuration_details = FromValueOpt::from_value(v)
515 }
516 "payment_method_options" => {
517 b.payment_method_options = FromValueOpt::from_value(v)
518 }
519 "payment_method_types" => b.payment_method_types = FromValueOpt::from_value(v),
520 "presentment_details" => b.presentment_details = FromValueOpt::from_value(v),
521 "processing" => b.processing = FromValueOpt::from_value(v),
522 "receipt_email" => b.receipt_email = FromValueOpt::from_value(v),
523 "review" => b.review = FromValueOpt::from_value(v),
524 "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
525 "shipping" => b.shipping = FromValueOpt::from_value(v),
526 "source" => b.source = FromValueOpt::from_value(v),
527 "statement_descriptor" => b.statement_descriptor = FromValueOpt::from_value(v),
528 "statement_descriptor_suffix" => {
529 b.statement_descriptor_suffix = FromValueOpt::from_value(v)
530 }
531 "status" => b.status = FromValueOpt::from_value(v),
532 "transfer_data" => b.transfer_data = FromValueOpt::from_value(v),
533 "transfer_group" => b.transfer_group = FromValueOpt::from_value(v),
534
535 _ => {}
536 }
537 }
538 b.take_out()
539 }
540 }
541};
542#[cfg(feature = "serialize")]
543impl serde::Serialize for PaymentIntent {
544 fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
545 use serde::ser::SerializeStruct;
546 let mut s = s.serialize_struct("PaymentIntent", 41)?;
547 s.serialize_field("amount", &self.amount)?;
548 s.serialize_field("amount_capturable", &self.amount_capturable)?;
549 s.serialize_field("amount_details", &self.amount_details)?;
550 s.serialize_field("amount_received", &self.amount_received)?;
551 s.serialize_field("application", &self.application)?;
552 s.serialize_field("application_fee_amount", &self.application_fee_amount)?;
553 s.serialize_field("automatic_payment_methods", &self.automatic_payment_methods)?;
554 s.serialize_field("canceled_at", &self.canceled_at)?;
555 s.serialize_field("cancellation_reason", &self.cancellation_reason)?;
556 s.serialize_field("capture_method", &self.capture_method)?;
557 s.serialize_field("client_secret", &self.client_secret)?;
558 s.serialize_field("confirmation_method", &self.confirmation_method)?;
559 s.serialize_field("created", &self.created)?;
560 s.serialize_field("currency", &self.currency)?;
561 s.serialize_field("customer", &self.customer)?;
562 s.serialize_field("description", &self.description)?;
563 s.serialize_field("excluded_payment_method_types", &self.excluded_payment_method_types)?;
564 s.serialize_field("id", &self.id)?;
565 s.serialize_field("last_payment_error", &self.last_payment_error)?;
566 s.serialize_field("latest_charge", &self.latest_charge)?;
567 s.serialize_field("livemode", &self.livemode)?;
568 s.serialize_field("metadata", &self.metadata)?;
569 s.serialize_field("next_action", &self.next_action)?;
570 s.serialize_field("on_behalf_of", &self.on_behalf_of)?;
571 s.serialize_field("payment_method", &self.payment_method)?;
572 s.serialize_field(
573 "payment_method_configuration_details",
574 &self.payment_method_configuration_details,
575 )?;
576 s.serialize_field("payment_method_options", &self.payment_method_options)?;
577 s.serialize_field("payment_method_types", &self.payment_method_types)?;
578 s.serialize_field("presentment_details", &self.presentment_details)?;
579 s.serialize_field("processing", &self.processing)?;
580 s.serialize_field("receipt_email", &self.receipt_email)?;
581 s.serialize_field("review", &self.review)?;
582 s.serialize_field("setup_future_usage", &self.setup_future_usage)?;
583 s.serialize_field("shipping", &self.shipping)?;
584 s.serialize_field("source", &self.source)?;
585 s.serialize_field("statement_descriptor", &self.statement_descriptor)?;
586 s.serialize_field("statement_descriptor_suffix", &self.statement_descriptor_suffix)?;
587 s.serialize_field("status", &self.status)?;
588 s.serialize_field("transfer_data", &self.transfer_data)?;
589 s.serialize_field("transfer_group", &self.transfer_group)?;
590
591 s.serialize_field("object", "payment_intent")?;
592 s.end()
593 }
594}
595#[derive(Copy, Clone, Eq, PartialEq)]
597pub enum PaymentIntentCancellationReason {
598 Abandoned,
599 Automatic,
600 Duplicate,
601 Expired,
602 FailedInvoice,
603 Fraudulent,
604 RequestedByCustomer,
605 VoidInvoice,
606}
607impl PaymentIntentCancellationReason {
608 pub fn as_str(self) -> &'static str {
609 use PaymentIntentCancellationReason::*;
610 match self {
611 Abandoned => "abandoned",
612 Automatic => "automatic",
613 Duplicate => "duplicate",
614 Expired => "expired",
615 FailedInvoice => "failed_invoice",
616 Fraudulent => "fraudulent",
617 RequestedByCustomer => "requested_by_customer",
618 VoidInvoice => "void_invoice",
619 }
620 }
621}
622
623impl std::str::FromStr for PaymentIntentCancellationReason {
624 type Err = stripe_types::StripeParseError;
625 fn from_str(s: &str) -> Result<Self, Self::Err> {
626 use PaymentIntentCancellationReason::*;
627 match s {
628 "abandoned" => Ok(Abandoned),
629 "automatic" => Ok(Automatic),
630 "duplicate" => Ok(Duplicate),
631 "expired" => Ok(Expired),
632 "failed_invoice" => Ok(FailedInvoice),
633 "fraudulent" => Ok(Fraudulent),
634 "requested_by_customer" => Ok(RequestedByCustomer),
635 "void_invoice" => Ok(VoidInvoice),
636 _ => Err(stripe_types::StripeParseError),
637 }
638 }
639}
640impl std::fmt::Display for PaymentIntentCancellationReason {
641 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
642 f.write_str(self.as_str())
643 }
644}
645
646impl std::fmt::Debug for PaymentIntentCancellationReason {
647 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
648 f.write_str(self.as_str())
649 }
650}
651#[cfg(feature = "serialize")]
652impl serde::Serialize for PaymentIntentCancellationReason {
653 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
654 where
655 S: serde::Serializer,
656 {
657 serializer.serialize_str(self.as_str())
658 }
659}
660impl miniserde::Deserialize for PaymentIntentCancellationReason {
661 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
662 crate::Place::new(out)
663 }
664}
665
666impl miniserde::de::Visitor for crate::Place<PaymentIntentCancellationReason> {
667 fn string(&mut self, s: &str) -> miniserde::Result<()> {
668 use std::str::FromStr;
669 self.out =
670 Some(PaymentIntentCancellationReason::from_str(s).map_err(|_| miniserde::Error)?);
671 Ok(())
672 }
673}
674
675stripe_types::impl_from_val_with_from_str!(PaymentIntentCancellationReason);
676#[cfg(feature = "deserialize")]
677impl<'de> serde::Deserialize<'de> for PaymentIntentCancellationReason {
678 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
679 use std::str::FromStr;
680 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
681 Self::from_str(&s).map_err(|_| {
682 serde::de::Error::custom("Unknown value for PaymentIntentCancellationReason")
683 })
684 }
685}
686#[derive(Copy, Clone, Eq, PartialEq)]
689pub enum PaymentIntentStatus {
690 Canceled,
691 Processing,
692 RequiresAction,
693 RequiresCapture,
694 RequiresConfirmation,
695 RequiresPaymentMethod,
696 Succeeded,
697}
698impl PaymentIntentStatus {
699 pub fn as_str(self) -> &'static str {
700 use PaymentIntentStatus::*;
701 match self {
702 Canceled => "canceled",
703 Processing => "processing",
704 RequiresAction => "requires_action",
705 RequiresCapture => "requires_capture",
706 RequiresConfirmation => "requires_confirmation",
707 RequiresPaymentMethod => "requires_payment_method",
708 Succeeded => "succeeded",
709 }
710 }
711}
712
713impl std::str::FromStr for PaymentIntentStatus {
714 type Err = stripe_types::StripeParseError;
715 fn from_str(s: &str) -> Result<Self, Self::Err> {
716 use PaymentIntentStatus::*;
717 match s {
718 "canceled" => Ok(Canceled),
719 "processing" => Ok(Processing),
720 "requires_action" => Ok(RequiresAction),
721 "requires_capture" => Ok(RequiresCapture),
722 "requires_confirmation" => Ok(RequiresConfirmation),
723 "requires_payment_method" => Ok(RequiresPaymentMethod),
724 "succeeded" => Ok(Succeeded),
725 _ => Err(stripe_types::StripeParseError),
726 }
727 }
728}
729impl std::fmt::Display for PaymentIntentStatus {
730 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
731 f.write_str(self.as_str())
732 }
733}
734
735impl std::fmt::Debug for PaymentIntentStatus {
736 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
737 f.write_str(self.as_str())
738 }
739}
740#[cfg(feature = "serialize")]
741impl serde::Serialize for PaymentIntentStatus {
742 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
743 where
744 S: serde::Serializer,
745 {
746 serializer.serialize_str(self.as_str())
747 }
748}
749impl miniserde::Deserialize for PaymentIntentStatus {
750 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
751 crate::Place::new(out)
752 }
753}
754
755impl miniserde::de::Visitor for crate::Place<PaymentIntentStatus> {
756 fn string(&mut self, s: &str) -> miniserde::Result<()> {
757 use std::str::FromStr;
758 self.out = Some(PaymentIntentStatus::from_str(s).map_err(|_| miniserde::Error)?);
759 Ok(())
760 }
761}
762
763stripe_types::impl_from_val_with_from_str!(PaymentIntentStatus);
764#[cfg(feature = "deserialize")]
765impl<'de> serde::Deserialize<'de> for PaymentIntentStatus {
766 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
767 use std::str::FromStr;
768 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
769 Self::from_str(&s)
770 .map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentStatus"))
771 }
772}
773impl stripe_types::Object for PaymentIntent {
774 type Id = stripe_shared::PaymentIntentId;
775 fn id(&self) -> &Self::Id {
776 &self.id
777 }
778
779 fn into_id(self) -> Self::Id {
780 self.id
781 }
782}
783stripe_types::def_id!(PaymentIntentId);
784#[derive(Copy, Clone, Eq, PartialEq)]
785pub enum PaymentIntentCaptureMethod {
786 Automatic,
787 AutomaticAsync,
788 Manual,
789}
790impl PaymentIntentCaptureMethod {
791 pub fn as_str(self) -> &'static str {
792 use PaymentIntentCaptureMethod::*;
793 match self {
794 Automatic => "automatic",
795 AutomaticAsync => "automatic_async",
796 Manual => "manual",
797 }
798 }
799}
800
801impl std::str::FromStr for PaymentIntentCaptureMethod {
802 type Err = stripe_types::StripeParseError;
803 fn from_str(s: &str) -> Result<Self, Self::Err> {
804 use PaymentIntentCaptureMethod::*;
805 match s {
806 "automatic" => Ok(Automatic),
807 "automatic_async" => Ok(AutomaticAsync),
808 "manual" => Ok(Manual),
809 _ => Err(stripe_types::StripeParseError),
810 }
811 }
812}
813impl std::fmt::Display for PaymentIntentCaptureMethod {
814 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
815 f.write_str(self.as_str())
816 }
817}
818
819impl std::fmt::Debug for PaymentIntentCaptureMethod {
820 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
821 f.write_str(self.as_str())
822 }
823}
824impl serde::Serialize for PaymentIntentCaptureMethod {
825 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
826 where
827 S: serde::Serializer,
828 {
829 serializer.serialize_str(self.as_str())
830 }
831}
832impl miniserde::Deserialize for PaymentIntentCaptureMethod {
833 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
834 crate::Place::new(out)
835 }
836}
837
838impl miniserde::de::Visitor for crate::Place<PaymentIntentCaptureMethod> {
839 fn string(&mut self, s: &str) -> miniserde::Result<()> {
840 use std::str::FromStr;
841 self.out = Some(PaymentIntentCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?);
842 Ok(())
843 }
844}
845
846stripe_types::impl_from_val_with_from_str!(PaymentIntentCaptureMethod);
847#[cfg(feature = "deserialize")]
848impl<'de> serde::Deserialize<'de> for PaymentIntentCaptureMethod {
849 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
850 use std::str::FromStr;
851 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
852 Self::from_str(&s)
853 .map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentCaptureMethod"))
854 }
855}
856#[derive(Copy, Clone, Eq, PartialEq)]
857pub enum PaymentIntentConfirmationMethod {
858 Automatic,
859 Manual,
860}
861impl PaymentIntentConfirmationMethod {
862 pub fn as_str(self) -> &'static str {
863 use PaymentIntentConfirmationMethod::*;
864 match self {
865 Automatic => "automatic",
866 Manual => "manual",
867 }
868 }
869}
870
871impl std::str::FromStr for PaymentIntentConfirmationMethod {
872 type Err = stripe_types::StripeParseError;
873 fn from_str(s: &str) -> Result<Self, Self::Err> {
874 use PaymentIntentConfirmationMethod::*;
875 match s {
876 "automatic" => Ok(Automatic),
877 "manual" => Ok(Manual),
878 _ => Err(stripe_types::StripeParseError),
879 }
880 }
881}
882impl std::fmt::Display for PaymentIntentConfirmationMethod {
883 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
884 f.write_str(self.as_str())
885 }
886}
887
888impl std::fmt::Debug for PaymentIntentConfirmationMethod {
889 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
890 f.write_str(self.as_str())
891 }
892}
893impl serde::Serialize for PaymentIntentConfirmationMethod {
894 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
895 where
896 S: serde::Serializer,
897 {
898 serializer.serialize_str(self.as_str())
899 }
900}
901impl miniserde::Deserialize for PaymentIntentConfirmationMethod {
902 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
903 crate::Place::new(out)
904 }
905}
906
907impl miniserde::de::Visitor for crate::Place<PaymentIntentConfirmationMethod> {
908 fn string(&mut self, s: &str) -> miniserde::Result<()> {
909 use std::str::FromStr;
910 self.out =
911 Some(PaymentIntentConfirmationMethod::from_str(s).map_err(|_| miniserde::Error)?);
912 Ok(())
913 }
914}
915
916stripe_types::impl_from_val_with_from_str!(PaymentIntentConfirmationMethod);
917#[cfg(feature = "deserialize")]
918impl<'de> serde::Deserialize<'de> for PaymentIntentConfirmationMethod {
919 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
920 use std::str::FromStr;
921 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
922 Self::from_str(&s).map_err(|_| {
923 serde::de::Error::custom("Unknown value for PaymentIntentConfirmationMethod")
924 })
925 }
926}
927#[derive(Clone, Eq, PartialEq)]
928#[non_exhaustive]
929pub enum PaymentIntentExcludedPaymentMethodTypes {
930 AcssDebit,
931 Affirm,
932 AfterpayClearpay,
933 Alipay,
934 Alma,
935 AmazonPay,
936 AuBecsDebit,
937 BacsDebit,
938 Bancontact,
939 Billie,
940 Blik,
941 Boleto,
942 Card,
943 Cashapp,
944 Crypto,
945 CustomerBalance,
946 Eps,
947 Fpx,
948 Giropay,
949 Grabpay,
950 Ideal,
951 KakaoPay,
952 Klarna,
953 Konbini,
954 KrCard,
955 MbWay,
956 Mobilepay,
957 Multibanco,
958 NaverPay,
959 NzBankAccount,
960 Oxxo,
961 P24,
962 PayByBank,
963 Payco,
964 Paynow,
965 Paypal,
966 Pix,
967 Promptpay,
968 RevolutPay,
969 SamsungPay,
970 Satispay,
971 SepaDebit,
972 Sofort,
973 Swish,
974 Twint,
975 UsBankAccount,
976 WechatPay,
977 Zip,
978 Unknown(String),
980}
981impl PaymentIntentExcludedPaymentMethodTypes {
982 pub fn as_str(&self) -> &str {
983 use PaymentIntentExcludedPaymentMethodTypes::*;
984 match self {
985 AcssDebit => "acss_debit",
986 Affirm => "affirm",
987 AfterpayClearpay => "afterpay_clearpay",
988 Alipay => "alipay",
989 Alma => "alma",
990 AmazonPay => "amazon_pay",
991 AuBecsDebit => "au_becs_debit",
992 BacsDebit => "bacs_debit",
993 Bancontact => "bancontact",
994 Billie => "billie",
995 Blik => "blik",
996 Boleto => "boleto",
997 Card => "card",
998 Cashapp => "cashapp",
999 Crypto => "crypto",
1000 CustomerBalance => "customer_balance",
1001 Eps => "eps",
1002 Fpx => "fpx",
1003 Giropay => "giropay",
1004 Grabpay => "grabpay",
1005 Ideal => "ideal",
1006 KakaoPay => "kakao_pay",
1007 Klarna => "klarna",
1008 Konbini => "konbini",
1009 KrCard => "kr_card",
1010 MbWay => "mb_way",
1011 Mobilepay => "mobilepay",
1012 Multibanco => "multibanco",
1013 NaverPay => "naver_pay",
1014 NzBankAccount => "nz_bank_account",
1015 Oxxo => "oxxo",
1016 P24 => "p24",
1017 PayByBank => "pay_by_bank",
1018 Payco => "payco",
1019 Paynow => "paynow",
1020 Paypal => "paypal",
1021 Pix => "pix",
1022 Promptpay => "promptpay",
1023 RevolutPay => "revolut_pay",
1024 SamsungPay => "samsung_pay",
1025 Satispay => "satispay",
1026 SepaDebit => "sepa_debit",
1027 Sofort => "sofort",
1028 Swish => "swish",
1029 Twint => "twint",
1030 UsBankAccount => "us_bank_account",
1031 WechatPay => "wechat_pay",
1032 Zip => "zip",
1033 Unknown(v) => v,
1034 }
1035 }
1036}
1037
1038impl std::str::FromStr for PaymentIntentExcludedPaymentMethodTypes {
1039 type Err = std::convert::Infallible;
1040 fn from_str(s: &str) -> Result<Self, Self::Err> {
1041 use PaymentIntentExcludedPaymentMethodTypes::*;
1042 match s {
1043 "acss_debit" => Ok(AcssDebit),
1044 "affirm" => Ok(Affirm),
1045 "afterpay_clearpay" => Ok(AfterpayClearpay),
1046 "alipay" => Ok(Alipay),
1047 "alma" => Ok(Alma),
1048 "amazon_pay" => Ok(AmazonPay),
1049 "au_becs_debit" => Ok(AuBecsDebit),
1050 "bacs_debit" => Ok(BacsDebit),
1051 "bancontact" => Ok(Bancontact),
1052 "billie" => Ok(Billie),
1053 "blik" => Ok(Blik),
1054 "boleto" => Ok(Boleto),
1055 "card" => Ok(Card),
1056 "cashapp" => Ok(Cashapp),
1057 "crypto" => Ok(Crypto),
1058 "customer_balance" => Ok(CustomerBalance),
1059 "eps" => Ok(Eps),
1060 "fpx" => Ok(Fpx),
1061 "giropay" => Ok(Giropay),
1062 "grabpay" => Ok(Grabpay),
1063 "ideal" => Ok(Ideal),
1064 "kakao_pay" => Ok(KakaoPay),
1065 "klarna" => Ok(Klarna),
1066 "konbini" => Ok(Konbini),
1067 "kr_card" => Ok(KrCard),
1068 "mb_way" => Ok(MbWay),
1069 "mobilepay" => Ok(Mobilepay),
1070 "multibanco" => Ok(Multibanco),
1071 "naver_pay" => Ok(NaverPay),
1072 "nz_bank_account" => Ok(NzBankAccount),
1073 "oxxo" => Ok(Oxxo),
1074 "p24" => Ok(P24),
1075 "pay_by_bank" => Ok(PayByBank),
1076 "payco" => Ok(Payco),
1077 "paynow" => Ok(Paynow),
1078 "paypal" => Ok(Paypal),
1079 "pix" => Ok(Pix),
1080 "promptpay" => Ok(Promptpay),
1081 "revolut_pay" => Ok(RevolutPay),
1082 "samsung_pay" => Ok(SamsungPay),
1083 "satispay" => Ok(Satispay),
1084 "sepa_debit" => Ok(SepaDebit),
1085 "sofort" => Ok(Sofort),
1086 "swish" => Ok(Swish),
1087 "twint" => Ok(Twint),
1088 "us_bank_account" => Ok(UsBankAccount),
1089 "wechat_pay" => Ok(WechatPay),
1090 "zip" => Ok(Zip),
1091 v => Ok(Unknown(v.to_owned())),
1092 }
1093 }
1094}
1095impl std::fmt::Display for PaymentIntentExcludedPaymentMethodTypes {
1096 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1097 f.write_str(self.as_str())
1098 }
1099}
1100
1101impl std::fmt::Debug for PaymentIntentExcludedPaymentMethodTypes {
1102 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1103 f.write_str(self.as_str())
1104 }
1105}
1106impl serde::Serialize for PaymentIntentExcludedPaymentMethodTypes {
1107 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1108 where
1109 S: serde::Serializer,
1110 {
1111 serializer.serialize_str(self.as_str())
1112 }
1113}
1114impl miniserde::Deserialize for PaymentIntentExcludedPaymentMethodTypes {
1115 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1116 crate::Place::new(out)
1117 }
1118}
1119
1120impl miniserde::de::Visitor for crate::Place<PaymentIntentExcludedPaymentMethodTypes> {
1121 fn string(&mut self, s: &str) -> miniserde::Result<()> {
1122 use std::str::FromStr;
1123 self.out = Some(PaymentIntentExcludedPaymentMethodTypes::from_str(s).unwrap());
1124 Ok(())
1125 }
1126}
1127
1128stripe_types::impl_from_val_with_from_str!(PaymentIntentExcludedPaymentMethodTypes);
1129#[cfg(feature = "deserialize")]
1130impl<'de> serde::Deserialize<'de> for PaymentIntentExcludedPaymentMethodTypes {
1131 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1132 use std::str::FromStr;
1133 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1134 Ok(Self::from_str(&s).unwrap())
1135 }
1136}
1137#[derive(Copy, Clone, Eq, PartialEq)]
1138pub enum PaymentIntentSetupFutureUsage {
1139 OffSession,
1140 OnSession,
1141}
1142impl PaymentIntentSetupFutureUsage {
1143 pub fn as_str(self) -> &'static str {
1144 use PaymentIntentSetupFutureUsage::*;
1145 match self {
1146 OffSession => "off_session",
1147 OnSession => "on_session",
1148 }
1149 }
1150}
1151
1152impl std::str::FromStr for PaymentIntentSetupFutureUsage {
1153 type Err = stripe_types::StripeParseError;
1154 fn from_str(s: &str) -> Result<Self, Self::Err> {
1155 use PaymentIntentSetupFutureUsage::*;
1156 match s {
1157 "off_session" => Ok(OffSession),
1158 "on_session" => Ok(OnSession),
1159 _ => Err(stripe_types::StripeParseError),
1160 }
1161 }
1162}
1163impl std::fmt::Display for PaymentIntentSetupFutureUsage {
1164 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1165 f.write_str(self.as_str())
1166 }
1167}
1168
1169impl std::fmt::Debug for PaymentIntentSetupFutureUsage {
1170 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1171 f.write_str(self.as_str())
1172 }
1173}
1174impl serde::Serialize for PaymentIntentSetupFutureUsage {
1175 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1176 where
1177 S: serde::Serializer,
1178 {
1179 serializer.serialize_str(self.as_str())
1180 }
1181}
1182impl miniserde::Deserialize for PaymentIntentSetupFutureUsage {
1183 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1184 crate::Place::new(out)
1185 }
1186}
1187
1188impl miniserde::de::Visitor for crate::Place<PaymentIntentSetupFutureUsage> {
1189 fn string(&mut self, s: &str) -> miniserde::Result<()> {
1190 use std::str::FromStr;
1191 self.out = Some(PaymentIntentSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?);
1192 Ok(())
1193 }
1194}
1195
1196stripe_types::impl_from_val_with_from_str!(PaymentIntentSetupFutureUsage);
1197#[cfg(feature = "deserialize")]
1198impl<'de> serde::Deserialize<'de> for PaymentIntentSetupFutureUsage {
1199 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1200 use std::str::FromStr;
1201 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1202 Self::from_str(&s).map_err(|_| {
1203 serde::de::Error::custom("Unknown value for PaymentIntentSetupFutureUsage")
1204 })
1205 }
1206}