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