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