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 id: stripe_shared::PaymentIntentId,
69 pub last_payment_error: Option<Box<stripe_shared::ApiErrors>>,
72 pub latest_charge: Option<stripe_types::Expandable<stripe_shared::Charge>>,
75 pub livemode: bool,
77 pub metadata: std::collections::HashMap<String, String>,
81 pub next_action: Option<stripe_shared::PaymentIntentNextAction>,
83 pub on_behalf_of: Option<stripe_types::Expandable<stripe_shared::Account>>,
86 pub payment_method: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>,
88 pub payment_method_configuration_details:
90 Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>,
91 pub payment_method_options: Option<stripe_shared::PaymentIntentPaymentMethodOptions>,
93 pub payment_method_types: Vec<String>,
97 pub presentment_details: Option<stripe_shared::PaymentFlowsPaymentIntentPresentmentDetails>,
98 pub processing: Option<stripe_shared::PaymentIntentProcessing>,
100 pub receipt_email: Option<String>,
103 pub review: Option<stripe_types::Expandable<stripe_shared::Review>>,
105 pub setup_future_usage: Option<stripe_shared::PaymentIntentSetupFutureUsage>,
114 pub shipping: Option<stripe_shared::Shipping>,
116 pub source: Option<stripe_types::Expandable<stripe_shared::PaymentSource>>,
119 pub statement_descriptor: Option<String>,
126 pub statement_descriptor_suffix: Option<String>,
129 pub status: PaymentIntentStatus,
132 pub transfer_data: Option<stripe_shared::TransferData>,
135 pub transfer_group: Option<String>,
138}
139#[doc(hidden)]
140pub struct PaymentIntentBuilder {
141 amount: Option<i64>,
142 amount_capturable: Option<i64>,
143 amount_details: Option<Option<stripe_shared::PaymentFlowsAmountDetails>>,
144 amount_received: Option<i64>,
145 application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>,
146 application_fee_amount: Option<Option<i64>>,
147 automatic_payment_methods:
148 Option<Option<stripe_shared::PaymentFlowsAutomaticPaymentMethodsPaymentIntent>>,
149 canceled_at: Option<Option<stripe_types::Timestamp>>,
150 cancellation_reason: Option<Option<PaymentIntentCancellationReason>>,
151 capture_method: Option<stripe_shared::PaymentIntentCaptureMethod>,
152 client_secret: Option<Option<String>>,
153 confirmation_method: Option<stripe_shared::PaymentIntentConfirmationMethod>,
154 created: Option<stripe_types::Timestamp>,
155 currency: Option<stripe_types::Currency>,
156 customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>,
157 description: Option<Option<String>>,
158 id: Option<stripe_shared::PaymentIntentId>,
159 last_payment_error: Option<Option<Box<stripe_shared::ApiErrors>>>,
160 latest_charge: Option<Option<stripe_types::Expandable<stripe_shared::Charge>>>,
161 livemode: Option<bool>,
162 metadata: Option<std::collections::HashMap<String, String>>,
163 next_action: Option<Option<stripe_shared::PaymentIntentNextAction>>,
164 on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>,
165 payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>,
166 payment_method_configuration_details:
167 Option<Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>>,
168 payment_method_options: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptions>>,
169 payment_method_types: Option<Vec<String>>,
170 presentment_details: Option<Option<stripe_shared::PaymentFlowsPaymentIntentPresentmentDetails>>,
171 processing: Option<Option<stripe_shared::PaymentIntentProcessing>>,
172 receipt_email: Option<Option<String>>,
173 review: Option<Option<stripe_types::Expandable<stripe_shared::Review>>>,
174 setup_future_usage: Option<Option<stripe_shared::PaymentIntentSetupFutureUsage>>,
175 shipping: Option<Option<stripe_shared::Shipping>>,
176 source: Option<Option<stripe_types::Expandable<stripe_shared::PaymentSource>>>,
177 statement_descriptor: Option<Option<String>>,
178 statement_descriptor_suffix: Option<Option<String>>,
179 status: Option<PaymentIntentStatus>,
180 transfer_data: Option<Option<stripe_shared::TransferData>>,
181 transfer_group: Option<Option<String>>,
182}
183
184#[allow(
185 unused_variables,
186 irrefutable_let_patterns,
187 clippy::let_unit_value,
188 clippy::match_single_binding,
189 clippy::single_match
190)]
191const _: () = {
192 use miniserde::de::{Map, Visitor};
193 use miniserde::json::Value;
194 use miniserde::{make_place, Deserialize, Result};
195 use stripe_types::miniserde_helpers::FromValueOpt;
196 use stripe_types::{MapBuilder, ObjectDeser};
197
198 make_place!(Place);
199
200 impl Deserialize for PaymentIntent {
201 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
202 Place::new(out)
203 }
204 }
205
206 struct Builder<'a> {
207 out: &'a mut Option<PaymentIntent>,
208 builder: PaymentIntentBuilder,
209 }
210
211 impl Visitor for Place<PaymentIntent> {
212 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
213 Ok(Box::new(Builder {
214 out: &mut self.out,
215 builder: PaymentIntentBuilder::deser_default(),
216 }))
217 }
218 }
219
220 impl MapBuilder for PaymentIntentBuilder {
221 type Out = PaymentIntent;
222 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
223 Ok(match k {
224 "amount" => Deserialize::begin(&mut self.amount),
225 "amount_capturable" => Deserialize::begin(&mut self.amount_capturable),
226 "amount_details" => Deserialize::begin(&mut self.amount_details),
227 "amount_received" => Deserialize::begin(&mut self.amount_received),
228 "application" => Deserialize::begin(&mut self.application),
229 "application_fee_amount" => Deserialize::begin(&mut self.application_fee_amount),
230 "automatic_payment_methods" => {
231 Deserialize::begin(&mut self.automatic_payment_methods)
232 }
233 "canceled_at" => Deserialize::begin(&mut self.canceled_at),
234 "cancellation_reason" => Deserialize::begin(&mut self.cancellation_reason),
235 "capture_method" => Deserialize::begin(&mut self.capture_method),
236 "client_secret" => Deserialize::begin(&mut self.client_secret),
237 "confirmation_method" => Deserialize::begin(&mut self.confirmation_method),
238 "created" => Deserialize::begin(&mut self.created),
239 "currency" => Deserialize::begin(&mut self.currency),
240 "customer" => Deserialize::begin(&mut self.customer),
241 "description" => Deserialize::begin(&mut self.description),
242 "id" => Deserialize::begin(&mut self.id),
243 "last_payment_error" => Deserialize::begin(&mut self.last_payment_error),
244 "latest_charge" => Deserialize::begin(&mut self.latest_charge),
245 "livemode" => Deserialize::begin(&mut self.livemode),
246 "metadata" => Deserialize::begin(&mut self.metadata),
247 "next_action" => Deserialize::begin(&mut self.next_action),
248 "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of),
249 "payment_method" => Deserialize::begin(&mut self.payment_method),
250 "payment_method_configuration_details" => {
251 Deserialize::begin(&mut self.payment_method_configuration_details)
252 }
253 "payment_method_options" => Deserialize::begin(&mut self.payment_method_options),
254 "payment_method_types" => Deserialize::begin(&mut self.payment_method_types),
255 "presentment_details" => Deserialize::begin(&mut self.presentment_details),
256 "processing" => Deserialize::begin(&mut self.processing),
257 "receipt_email" => Deserialize::begin(&mut self.receipt_email),
258 "review" => Deserialize::begin(&mut self.review),
259 "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
260 "shipping" => Deserialize::begin(&mut self.shipping),
261 "source" => Deserialize::begin(&mut self.source),
262 "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor),
263 "statement_descriptor_suffix" => {
264 Deserialize::begin(&mut self.statement_descriptor_suffix)
265 }
266 "status" => Deserialize::begin(&mut self.status),
267 "transfer_data" => Deserialize::begin(&mut self.transfer_data),
268 "transfer_group" => Deserialize::begin(&mut self.transfer_group),
269
270 _ => <dyn Visitor>::ignore(),
271 })
272 }
273
274 fn deser_default() -> Self {
275 Self {
276 amount: Deserialize::default(),
277 amount_capturable: Deserialize::default(),
278 amount_details: Deserialize::default(),
279 amount_received: Deserialize::default(),
280 application: Deserialize::default(),
281 application_fee_amount: Deserialize::default(),
282 automatic_payment_methods: Deserialize::default(),
283 canceled_at: Deserialize::default(),
284 cancellation_reason: Deserialize::default(),
285 capture_method: Deserialize::default(),
286 client_secret: Deserialize::default(),
287 confirmation_method: Deserialize::default(),
288 created: Deserialize::default(),
289 currency: Deserialize::default(),
290 customer: Deserialize::default(),
291 description: Deserialize::default(),
292 id: Deserialize::default(),
293 last_payment_error: Deserialize::default(),
294 latest_charge: Deserialize::default(),
295 livemode: Deserialize::default(),
296 metadata: Deserialize::default(),
297 next_action: Deserialize::default(),
298 on_behalf_of: Deserialize::default(),
299 payment_method: Deserialize::default(),
300 payment_method_configuration_details: Deserialize::default(),
301 payment_method_options: Deserialize::default(),
302 payment_method_types: Deserialize::default(),
303 presentment_details: Deserialize::default(),
304 processing: Deserialize::default(),
305 receipt_email: Deserialize::default(),
306 review: Deserialize::default(),
307 setup_future_usage: Deserialize::default(),
308 shipping: Deserialize::default(),
309 source: Deserialize::default(),
310 statement_descriptor: Deserialize::default(),
311 statement_descriptor_suffix: Deserialize::default(),
312 status: Deserialize::default(),
313 transfer_data: Deserialize::default(),
314 transfer_group: Deserialize::default(),
315 }
316 }
317
318 fn take_out(&mut self) -> Option<Self::Out> {
319 let (
320 Some(amount),
321 Some(amount_capturable),
322 Some(amount_details),
323 Some(amount_received),
324 Some(application),
325 Some(application_fee_amount),
326 Some(automatic_payment_methods),
327 Some(canceled_at),
328 Some(cancellation_reason),
329 Some(capture_method),
330 Some(client_secret),
331 Some(confirmation_method),
332 Some(created),
333 Some(currency),
334 Some(customer),
335 Some(description),
336 Some(id),
337 Some(last_payment_error),
338 Some(latest_charge),
339 Some(livemode),
340 Some(metadata),
341 Some(next_action),
342 Some(on_behalf_of),
343 Some(payment_method),
344 Some(payment_method_configuration_details),
345 Some(payment_method_options),
346 Some(payment_method_types),
347 Some(presentment_details),
348 Some(processing),
349 Some(receipt_email),
350 Some(review),
351 Some(setup_future_usage),
352 Some(shipping),
353 Some(source),
354 Some(statement_descriptor),
355 Some(statement_descriptor_suffix),
356 Some(status),
357 Some(transfer_data),
358 Some(transfer_group),
359 ) = (
360 self.amount,
361 self.amount_capturable,
362 self.amount_details,
363 self.amount_received,
364 self.application.take(),
365 self.application_fee_amount,
366 self.automatic_payment_methods,
367 self.canceled_at,
368 self.cancellation_reason,
369 self.capture_method,
370 self.client_secret.take(),
371 self.confirmation_method,
372 self.created,
373 self.currency,
374 self.customer.take(),
375 self.description.take(),
376 self.id.take(),
377 self.last_payment_error.take(),
378 self.latest_charge.take(),
379 self.livemode,
380 self.metadata.take(),
381 self.next_action.take(),
382 self.on_behalf_of.take(),
383 self.payment_method.take(),
384 self.payment_method_configuration_details.take(),
385 self.payment_method_options.take(),
386 self.payment_method_types.take(),
387 self.presentment_details,
388 self.processing,
389 self.receipt_email.take(),
390 self.review.take(),
391 self.setup_future_usage,
392 self.shipping.take(),
393 self.source.take(),
394 self.statement_descriptor.take(),
395 self.statement_descriptor_suffix.take(),
396 self.status,
397 self.transfer_data.take(),
398 self.transfer_group.take(),
399 )
400 else {
401 return None;
402 };
403 Some(Self::Out {
404 amount,
405 amount_capturable,
406 amount_details,
407 amount_received,
408 application,
409 application_fee_amount,
410 automatic_payment_methods,
411 canceled_at,
412 cancellation_reason,
413 capture_method,
414 client_secret,
415 confirmation_method,
416 created,
417 currency,
418 customer,
419 description,
420 id,
421 last_payment_error,
422 latest_charge,
423 livemode,
424 metadata,
425 next_action,
426 on_behalf_of,
427 payment_method,
428 payment_method_configuration_details,
429 payment_method_options,
430 payment_method_types,
431 presentment_details,
432 processing,
433 receipt_email,
434 review,
435 setup_future_usage,
436 shipping,
437 source,
438 statement_descriptor,
439 statement_descriptor_suffix,
440 status,
441 transfer_data,
442 transfer_group,
443 })
444 }
445 }
446
447 impl<'a> Map for Builder<'a> {
448 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
449 self.builder.key(k)
450 }
451
452 fn finish(&mut self) -> Result<()> {
453 *self.out = self.builder.take_out();
454 Ok(())
455 }
456 }
457
458 impl ObjectDeser for PaymentIntent {
459 type Builder = PaymentIntentBuilder;
460 }
461
462 impl FromValueOpt for PaymentIntent {
463 fn from_value(v: Value) -> Option<Self> {
464 let Value::Object(obj) = v else {
465 return None;
466 };
467 let mut b = PaymentIntentBuilder::deser_default();
468 for (k, v) in obj {
469 match k.as_str() {
470 "amount" => b.amount = FromValueOpt::from_value(v),
471 "amount_capturable" => b.amount_capturable = FromValueOpt::from_value(v),
472 "amount_details" => b.amount_details = FromValueOpt::from_value(v),
473 "amount_received" => b.amount_received = FromValueOpt::from_value(v),
474 "application" => b.application = FromValueOpt::from_value(v),
475 "application_fee_amount" => {
476 b.application_fee_amount = FromValueOpt::from_value(v)
477 }
478 "automatic_payment_methods" => {
479 b.automatic_payment_methods = FromValueOpt::from_value(v)
480 }
481 "canceled_at" => b.canceled_at = FromValueOpt::from_value(v),
482 "cancellation_reason" => b.cancellation_reason = FromValueOpt::from_value(v),
483 "capture_method" => b.capture_method = FromValueOpt::from_value(v),
484 "client_secret" => b.client_secret = FromValueOpt::from_value(v),
485 "confirmation_method" => b.confirmation_method = FromValueOpt::from_value(v),
486 "created" => b.created = FromValueOpt::from_value(v),
487 "currency" => b.currency = FromValueOpt::from_value(v),
488 "customer" => b.customer = FromValueOpt::from_value(v),
489 "description" => b.description = FromValueOpt::from_value(v),
490 "id" => b.id = FromValueOpt::from_value(v),
491 "last_payment_error" => b.last_payment_error = FromValueOpt::from_value(v),
492 "latest_charge" => b.latest_charge = FromValueOpt::from_value(v),
493 "livemode" => b.livemode = FromValueOpt::from_value(v),
494 "metadata" => b.metadata = FromValueOpt::from_value(v),
495 "next_action" => b.next_action = FromValueOpt::from_value(v),
496 "on_behalf_of" => b.on_behalf_of = FromValueOpt::from_value(v),
497 "payment_method" => b.payment_method = FromValueOpt::from_value(v),
498 "payment_method_configuration_details" => {
499 b.payment_method_configuration_details = FromValueOpt::from_value(v)
500 }
501 "payment_method_options" => {
502 b.payment_method_options = FromValueOpt::from_value(v)
503 }
504 "payment_method_types" => b.payment_method_types = FromValueOpt::from_value(v),
505 "presentment_details" => b.presentment_details = FromValueOpt::from_value(v),
506 "processing" => b.processing = FromValueOpt::from_value(v),
507 "receipt_email" => b.receipt_email = FromValueOpt::from_value(v),
508 "review" => b.review = FromValueOpt::from_value(v),
509 "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
510 "shipping" => b.shipping = FromValueOpt::from_value(v),
511 "source" => b.source = FromValueOpt::from_value(v),
512 "statement_descriptor" => b.statement_descriptor = FromValueOpt::from_value(v),
513 "statement_descriptor_suffix" => {
514 b.statement_descriptor_suffix = FromValueOpt::from_value(v)
515 }
516 "status" => b.status = FromValueOpt::from_value(v),
517 "transfer_data" => b.transfer_data = FromValueOpt::from_value(v),
518 "transfer_group" => b.transfer_group = FromValueOpt::from_value(v),
519
520 _ => {}
521 }
522 }
523 b.take_out()
524 }
525 }
526};
527#[cfg(feature = "serialize")]
528impl serde::Serialize for PaymentIntent {
529 fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
530 use serde::ser::SerializeStruct;
531 let mut s = s.serialize_struct("PaymentIntent", 40)?;
532 s.serialize_field("amount", &self.amount)?;
533 s.serialize_field("amount_capturable", &self.amount_capturable)?;
534 s.serialize_field("amount_details", &self.amount_details)?;
535 s.serialize_field("amount_received", &self.amount_received)?;
536 s.serialize_field("application", &self.application)?;
537 s.serialize_field("application_fee_amount", &self.application_fee_amount)?;
538 s.serialize_field("automatic_payment_methods", &self.automatic_payment_methods)?;
539 s.serialize_field("canceled_at", &self.canceled_at)?;
540 s.serialize_field("cancellation_reason", &self.cancellation_reason)?;
541 s.serialize_field("capture_method", &self.capture_method)?;
542 s.serialize_field("client_secret", &self.client_secret)?;
543 s.serialize_field("confirmation_method", &self.confirmation_method)?;
544 s.serialize_field("created", &self.created)?;
545 s.serialize_field("currency", &self.currency)?;
546 s.serialize_field("customer", &self.customer)?;
547 s.serialize_field("description", &self.description)?;
548 s.serialize_field("id", &self.id)?;
549 s.serialize_field("last_payment_error", &self.last_payment_error)?;
550 s.serialize_field("latest_charge", &self.latest_charge)?;
551 s.serialize_field("livemode", &self.livemode)?;
552 s.serialize_field("metadata", &self.metadata)?;
553 s.serialize_field("next_action", &self.next_action)?;
554 s.serialize_field("on_behalf_of", &self.on_behalf_of)?;
555 s.serialize_field("payment_method", &self.payment_method)?;
556 s.serialize_field(
557 "payment_method_configuration_details",
558 &self.payment_method_configuration_details,
559 )?;
560 s.serialize_field("payment_method_options", &self.payment_method_options)?;
561 s.serialize_field("payment_method_types", &self.payment_method_types)?;
562 s.serialize_field("presentment_details", &self.presentment_details)?;
563 s.serialize_field("processing", &self.processing)?;
564 s.serialize_field("receipt_email", &self.receipt_email)?;
565 s.serialize_field("review", &self.review)?;
566 s.serialize_field("setup_future_usage", &self.setup_future_usage)?;
567 s.serialize_field("shipping", &self.shipping)?;
568 s.serialize_field("source", &self.source)?;
569 s.serialize_field("statement_descriptor", &self.statement_descriptor)?;
570 s.serialize_field("statement_descriptor_suffix", &self.statement_descriptor_suffix)?;
571 s.serialize_field("status", &self.status)?;
572 s.serialize_field("transfer_data", &self.transfer_data)?;
573 s.serialize_field("transfer_group", &self.transfer_group)?;
574
575 s.serialize_field("object", "payment_intent")?;
576 s.end()
577 }
578}
579#[derive(Copy, Clone, Eq, PartialEq)]
581pub enum PaymentIntentCancellationReason {
582 Abandoned,
583 Automatic,
584 Duplicate,
585 Expired,
586 FailedInvoice,
587 Fraudulent,
588 RequestedByCustomer,
589 VoidInvoice,
590}
591impl PaymentIntentCancellationReason {
592 pub fn as_str(self) -> &'static str {
593 use PaymentIntentCancellationReason::*;
594 match self {
595 Abandoned => "abandoned",
596 Automatic => "automatic",
597 Duplicate => "duplicate",
598 Expired => "expired",
599 FailedInvoice => "failed_invoice",
600 Fraudulent => "fraudulent",
601 RequestedByCustomer => "requested_by_customer",
602 VoidInvoice => "void_invoice",
603 }
604 }
605}
606
607impl std::str::FromStr for PaymentIntentCancellationReason {
608 type Err = stripe_types::StripeParseError;
609 fn from_str(s: &str) -> Result<Self, Self::Err> {
610 use PaymentIntentCancellationReason::*;
611 match s {
612 "abandoned" => Ok(Abandoned),
613 "automatic" => Ok(Automatic),
614 "duplicate" => Ok(Duplicate),
615 "expired" => Ok(Expired),
616 "failed_invoice" => Ok(FailedInvoice),
617 "fraudulent" => Ok(Fraudulent),
618 "requested_by_customer" => Ok(RequestedByCustomer),
619 "void_invoice" => Ok(VoidInvoice),
620 _ => Err(stripe_types::StripeParseError),
621 }
622 }
623}
624impl std::fmt::Display for PaymentIntentCancellationReason {
625 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
626 f.write_str(self.as_str())
627 }
628}
629
630impl std::fmt::Debug for PaymentIntentCancellationReason {
631 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
632 f.write_str(self.as_str())
633 }
634}
635#[cfg(feature = "serialize")]
636impl serde::Serialize for PaymentIntentCancellationReason {
637 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
638 where
639 S: serde::Serializer,
640 {
641 serializer.serialize_str(self.as_str())
642 }
643}
644impl miniserde::Deserialize for PaymentIntentCancellationReason {
645 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
646 crate::Place::new(out)
647 }
648}
649
650impl miniserde::de::Visitor for crate::Place<PaymentIntentCancellationReason> {
651 fn string(&mut self, s: &str) -> miniserde::Result<()> {
652 use std::str::FromStr;
653 self.out =
654 Some(PaymentIntentCancellationReason::from_str(s).map_err(|_| miniserde::Error)?);
655 Ok(())
656 }
657}
658
659stripe_types::impl_from_val_with_from_str!(PaymentIntentCancellationReason);
660#[cfg(feature = "deserialize")]
661impl<'de> serde::Deserialize<'de> for PaymentIntentCancellationReason {
662 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
663 use std::str::FromStr;
664 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
665 Self::from_str(&s).map_err(|_| {
666 serde::de::Error::custom("Unknown value for PaymentIntentCancellationReason")
667 })
668 }
669}
670#[derive(Copy, Clone, Eq, PartialEq)]
673pub enum PaymentIntentStatus {
674 Canceled,
675 Processing,
676 RequiresAction,
677 RequiresCapture,
678 RequiresConfirmation,
679 RequiresPaymentMethod,
680 Succeeded,
681}
682impl PaymentIntentStatus {
683 pub fn as_str(self) -> &'static str {
684 use PaymentIntentStatus::*;
685 match self {
686 Canceled => "canceled",
687 Processing => "processing",
688 RequiresAction => "requires_action",
689 RequiresCapture => "requires_capture",
690 RequiresConfirmation => "requires_confirmation",
691 RequiresPaymentMethod => "requires_payment_method",
692 Succeeded => "succeeded",
693 }
694 }
695}
696
697impl std::str::FromStr for PaymentIntentStatus {
698 type Err = stripe_types::StripeParseError;
699 fn from_str(s: &str) -> Result<Self, Self::Err> {
700 use PaymentIntentStatus::*;
701 match s {
702 "canceled" => Ok(Canceled),
703 "processing" => Ok(Processing),
704 "requires_action" => Ok(RequiresAction),
705 "requires_capture" => Ok(RequiresCapture),
706 "requires_confirmation" => Ok(RequiresConfirmation),
707 "requires_payment_method" => Ok(RequiresPaymentMethod),
708 "succeeded" => Ok(Succeeded),
709 _ => Err(stripe_types::StripeParseError),
710 }
711 }
712}
713impl std::fmt::Display for PaymentIntentStatus {
714 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
715 f.write_str(self.as_str())
716 }
717}
718
719impl std::fmt::Debug for PaymentIntentStatus {
720 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
721 f.write_str(self.as_str())
722 }
723}
724#[cfg(feature = "serialize")]
725impl serde::Serialize for PaymentIntentStatus {
726 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
727 where
728 S: serde::Serializer,
729 {
730 serializer.serialize_str(self.as_str())
731 }
732}
733impl miniserde::Deserialize for PaymentIntentStatus {
734 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
735 crate::Place::new(out)
736 }
737}
738
739impl miniserde::de::Visitor for crate::Place<PaymentIntentStatus> {
740 fn string(&mut self, s: &str) -> miniserde::Result<()> {
741 use std::str::FromStr;
742 self.out = Some(PaymentIntentStatus::from_str(s).map_err(|_| miniserde::Error)?);
743 Ok(())
744 }
745}
746
747stripe_types::impl_from_val_with_from_str!(PaymentIntentStatus);
748#[cfg(feature = "deserialize")]
749impl<'de> serde::Deserialize<'de> for PaymentIntentStatus {
750 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
751 use std::str::FromStr;
752 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
753 Self::from_str(&s)
754 .map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentStatus"))
755 }
756}
757impl stripe_types::Object for PaymentIntent {
758 type Id = stripe_shared::PaymentIntentId;
759 fn id(&self) -> &Self::Id {
760 &self.id
761 }
762
763 fn into_id(self) -> Self::Id {
764 self.id
765 }
766}
767stripe_types::def_id!(PaymentIntentId);
768#[derive(Copy, Clone, Eq, PartialEq)]
769pub enum PaymentIntentCaptureMethod {
770 Automatic,
771 AutomaticAsync,
772 Manual,
773}
774impl PaymentIntentCaptureMethod {
775 pub fn as_str(self) -> &'static str {
776 use PaymentIntentCaptureMethod::*;
777 match self {
778 Automatic => "automatic",
779 AutomaticAsync => "automatic_async",
780 Manual => "manual",
781 }
782 }
783}
784
785impl std::str::FromStr for PaymentIntentCaptureMethod {
786 type Err = stripe_types::StripeParseError;
787 fn from_str(s: &str) -> Result<Self, Self::Err> {
788 use PaymentIntentCaptureMethod::*;
789 match s {
790 "automatic" => Ok(Automatic),
791 "automatic_async" => Ok(AutomaticAsync),
792 "manual" => Ok(Manual),
793 _ => Err(stripe_types::StripeParseError),
794 }
795 }
796}
797impl std::fmt::Display for PaymentIntentCaptureMethod {
798 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
799 f.write_str(self.as_str())
800 }
801}
802
803impl std::fmt::Debug for PaymentIntentCaptureMethod {
804 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
805 f.write_str(self.as_str())
806 }
807}
808impl serde::Serialize for PaymentIntentCaptureMethod {
809 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
810 where
811 S: serde::Serializer,
812 {
813 serializer.serialize_str(self.as_str())
814 }
815}
816impl miniserde::Deserialize for PaymentIntentCaptureMethod {
817 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
818 crate::Place::new(out)
819 }
820}
821
822impl miniserde::de::Visitor for crate::Place<PaymentIntentCaptureMethod> {
823 fn string(&mut self, s: &str) -> miniserde::Result<()> {
824 use std::str::FromStr;
825 self.out = Some(PaymentIntentCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?);
826 Ok(())
827 }
828}
829
830stripe_types::impl_from_val_with_from_str!(PaymentIntentCaptureMethod);
831#[cfg(feature = "deserialize")]
832impl<'de> serde::Deserialize<'de> for PaymentIntentCaptureMethod {
833 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
834 use std::str::FromStr;
835 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
836 Self::from_str(&s)
837 .map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentCaptureMethod"))
838 }
839}
840#[derive(Copy, Clone, Eq, PartialEq)]
841pub enum PaymentIntentConfirmationMethod {
842 Automatic,
843 Manual,
844}
845impl PaymentIntentConfirmationMethod {
846 pub fn as_str(self) -> &'static str {
847 use PaymentIntentConfirmationMethod::*;
848 match self {
849 Automatic => "automatic",
850 Manual => "manual",
851 }
852 }
853}
854
855impl std::str::FromStr for PaymentIntentConfirmationMethod {
856 type Err = stripe_types::StripeParseError;
857 fn from_str(s: &str) -> Result<Self, Self::Err> {
858 use PaymentIntentConfirmationMethod::*;
859 match s {
860 "automatic" => Ok(Automatic),
861 "manual" => Ok(Manual),
862 _ => Err(stripe_types::StripeParseError),
863 }
864 }
865}
866impl std::fmt::Display for PaymentIntentConfirmationMethod {
867 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
868 f.write_str(self.as_str())
869 }
870}
871
872impl std::fmt::Debug for PaymentIntentConfirmationMethod {
873 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
874 f.write_str(self.as_str())
875 }
876}
877impl serde::Serialize for PaymentIntentConfirmationMethod {
878 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
879 where
880 S: serde::Serializer,
881 {
882 serializer.serialize_str(self.as_str())
883 }
884}
885impl miniserde::Deserialize for PaymentIntentConfirmationMethod {
886 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
887 crate::Place::new(out)
888 }
889}
890
891impl miniserde::de::Visitor for crate::Place<PaymentIntentConfirmationMethod> {
892 fn string(&mut self, s: &str) -> miniserde::Result<()> {
893 use std::str::FromStr;
894 self.out =
895 Some(PaymentIntentConfirmationMethod::from_str(s).map_err(|_| miniserde::Error)?);
896 Ok(())
897 }
898}
899
900stripe_types::impl_from_val_with_from_str!(PaymentIntentConfirmationMethod);
901#[cfg(feature = "deserialize")]
902impl<'de> serde::Deserialize<'de> for PaymentIntentConfirmationMethod {
903 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
904 use std::str::FromStr;
905 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
906 Self::from_str(&s).map_err(|_| {
907 serde::de::Error::custom("Unknown value for PaymentIntentConfirmationMethod")
908 })
909 }
910}
911#[derive(Copy, Clone, Eq, PartialEq)]
912pub enum PaymentIntentSetupFutureUsage {
913 OffSession,
914 OnSession,
915}
916impl PaymentIntentSetupFutureUsage {
917 pub fn as_str(self) -> &'static str {
918 use PaymentIntentSetupFutureUsage::*;
919 match self {
920 OffSession => "off_session",
921 OnSession => "on_session",
922 }
923 }
924}
925
926impl std::str::FromStr for PaymentIntentSetupFutureUsage {
927 type Err = stripe_types::StripeParseError;
928 fn from_str(s: &str) -> Result<Self, Self::Err> {
929 use PaymentIntentSetupFutureUsage::*;
930 match s {
931 "off_session" => Ok(OffSession),
932 "on_session" => Ok(OnSession),
933 _ => Err(stripe_types::StripeParseError),
934 }
935 }
936}
937impl std::fmt::Display for PaymentIntentSetupFutureUsage {
938 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
939 f.write_str(self.as_str())
940 }
941}
942
943impl std::fmt::Debug for PaymentIntentSetupFutureUsage {
944 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
945 f.write_str(self.as_str())
946 }
947}
948impl serde::Serialize for PaymentIntentSetupFutureUsage {
949 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
950 where
951 S: serde::Serializer,
952 {
953 serializer.serialize_str(self.as_str())
954 }
955}
956impl miniserde::Deserialize for PaymentIntentSetupFutureUsage {
957 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
958 crate::Place::new(out)
959 }
960}
961
962impl miniserde::de::Visitor for crate::Place<PaymentIntentSetupFutureUsage> {
963 fn string(&mut self, s: &str) -> miniserde::Result<()> {
964 use std::str::FromStr;
965 self.out = Some(PaymentIntentSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?);
966 Ok(())
967 }
968}
969
970stripe_types::impl_from_val_with_from_str!(PaymentIntentSetupFutureUsage);
971#[cfg(feature = "deserialize")]
972impl<'de> serde::Deserialize<'de> for PaymentIntentSetupFutureUsage {
973 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
974 use std::str::FromStr;
975 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
976 Self::from_str(&s).map_err(|_| {
977 serde::de::Error::custom("Unknown value for PaymentIntentSetupFutureUsage")
978 })
979 }
980}