#[derive(Clone)]
#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
pub struct PaymentIntent {
pub amount: i64,
pub amount_capturable: i64,
pub amount_details: Option<stripe_shared::PaymentFlowsAmountDetails>,
pub amount_received: i64,
pub application: Option<stripe_types::Expandable<stripe_shared::Application>>,
pub application_fee_amount: Option<i64>,
pub automatic_payment_methods:
Option<stripe_shared::PaymentFlowsAutomaticPaymentMethodsPaymentIntent>,
pub canceled_at: Option<stripe_types::Timestamp>,
pub cancellation_reason: Option<PaymentIntentCancellationReason>,
pub capture_method: stripe_shared::PaymentIntentCaptureMethod,
pub client_secret: Option<String>,
pub confirmation_method: stripe_shared::PaymentIntentConfirmationMethod,
pub created: stripe_types::Timestamp,
pub currency: stripe_types::Currency,
pub customer: Option<stripe_types::Expandable<stripe_shared::Customer>>,
pub customer_account: Option<String>,
pub description: Option<String>,
pub excluded_payment_method_types:
Option<Vec<stripe_shared::PaymentIntentExcludedPaymentMethodTypes>>,
pub hooks: Option<stripe_shared::PaymentFlowsPaymentIntentAsyncWorkflows>,
pub id: stripe_shared::PaymentIntentId,
pub last_payment_error: Option<Box<stripe_shared::ApiErrors>>,
pub latest_charge: Option<stripe_types::Expandable<stripe_shared::Charge>>,
pub livemode: bool,
pub managed_payments: Option<stripe_shared::SmorResourceManagedPayments>,
pub metadata: std::collections::HashMap<String, String>,
pub next_action: Option<stripe_shared::PaymentIntentNextAction>,
pub on_behalf_of: Option<stripe_types::Expandable<stripe_shared::Account>>,
pub payment_details: Option<stripe_shared::PaymentFlowsPaymentDetails>,
pub payment_method: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>,
pub payment_method_configuration_details:
Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>,
pub payment_method_options: Option<stripe_shared::PaymentIntentPaymentMethodOptions>,
pub payment_method_types: Vec<String>,
pub presentment_details: Option<stripe_shared::PaymentFlowsPaymentIntentPresentmentDetails>,
pub processing: Option<stripe_shared::PaymentIntentProcessing>,
pub receipt_email: Option<String>,
pub review: Option<stripe_types::Expandable<stripe_shared::Review>>,
pub setup_future_usage: Option<stripe_shared::PaymentIntentSetupFutureUsage>,
pub shipping: Option<stripe_shared::Shipping>,
pub source: Option<stripe_types::Expandable<stripe_shared::PaymentSource>>,
pub statement_descriptor: Option<String>,
pub statement_descriptor_suffix: Option<String>,
pub status: PaymentIntentStatus,
pub transfer_data: Option<stripe_shared::TransferData>,
pub transfer_group: Option<String>,
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentIntent {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("PaymentIntent").finish_non_exhaustive()
}
}
#[doc(hidden)]
pub struct PaymentIntentBuilder {
amount: Option<i64>,
amount_capturable: Option<i64>,
amount_details: Option<Option<stripe_shared::PaymentFlowsAmountDetails>>,
amount_received: Option<i64>,
application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>,
application_fee_amount: Option<Option<i64>>,
automatic_payment_methods:
Option<Option<stripe_shared::PaymentFlowsAutomaticPaymentMethodsPaymentIntent>>,
canceled_at: Option<Option<stripe_types::Timestamp>>,
cancellation_reason: Option<Option<PaymentIntentCancellationReason>>,
capture_method: Option<stripe_shared::PaymentIntentCaptureMethod>,
client_secret: Option<Option<String>>,
confirmation_method: Option<stripe_shared::PaymentIntentConfirmationMethod>,
created: Option<stripe_types::Timestamp>,
currency: Option<stripe_types::Currency>,
customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>,
customer_account: Option<Option<String>>,
description: Option<Option<String>>,
excluded_payment_method_types:
Option<Option<Vec<stripe_shared::PaymentIntentExcludedPaymentMethodTypes>>>,
hooks: Option<Option<stripe_shared::PaymentFlowsPaymentIntentAsyncWorkflows>>,
id: Option<stripe_shared::PaymentIntentId>,
last_payment_error: Option<Option<Box<stripe_shared::ApiErrors>>>,
latest_charge: Option<Option<stripe_types::Expandable<stripe_shared::Charge>>>,
livemode: Option<bool>,
managed_payments: Option<Option<stripe_shared::SmorResourceManagedPayments>>,
metadata: Option<std::collections::HashMap<String, String>>,
next_action: Option<Option<stripe_shared::PaymentIntentNextAction>>,
on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>,
payment_details: Option<Option<stripe_shared::PaymentFlowsPaymentDetails>>,
payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>,
payment_method_configuration_details:
Option<Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>>,
payment_method_options: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptions>>,
payment_method_types: Option<Vec<String>>,
presentment_details: Option<Option<stripe_shared::PaymentFlowsPaymentIntentPresentmentDetails>>,
processing: Option<Option<stripe_shared::PaymentIntentProcessing>>,
receipt_email: Option<Option<String>>,
review: Option<Option<stripe_types::Expandable<stripe_shared::Review>>>,
setup_future_usage: Option<Option<stripe_shared::PaymentIntentSetupFutureUsage>>,
shipping: Option<Option<stripe_shared::Shipping>>,
source: Option<Option<stripe_types::Expandable<stripe_shared::PaymentSource>>>,
statement_descriptor: Option<Option<String>>,
statement_descriptor_suffix: Option<Option<String>>,
status: Option<PaymentIntentStatus>,
transfer_data: Option<Option<stripe_shared::TransferData>>,
transfer_group: Option<Option<String>>,
}
#[allow(
unused_variables,
irrefutable_let_patterns,
clippy::let_unit_value,
clippy::match_single_binding,
clippy::single_match
)]
const _: () = {
use miniserde::de::{Map, Visitor};
use miniserde::json::Value;
use miniserde::{Deserialize, Result, make_place};
use stripe_types::miniserde_helpers::FromValueOpt;
use stripe_types::{MapBuilder, ObjectDeser};
make_place!(Place);
impl Deserialize for PaymentIntent {
fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
Place::new(out)
}
}
struct Builder<'a> {
out: &'a mut Option<PaymentIntent>,
builder: PaymentIntentBuilder,
}
impl Visitor for Place<PaymentIntent> {
fn map(&mut self) -> Result<Box<dyn Map + '_>> {
Ok(Box::new(Builder {
out: &mut self.out,
builder: PaymentIntentBuilder::deser_default(),
}))
}
}
impl MapBuilder for PaymentIntentBuilder {
type Out = PaymentIntent;
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
Ok(match k {
"amount" => Deserialize::begin(&mut self.amount),
"amount_capturable" => Deserialize::begin(&mut self.amount_capturable),
"amount_details" => Deserialize::begin(&mut self.amount_details),
"amount_received" => Deserialize::begin(&mut self.amount_received),
"application" => Deserialize::begin(&mut self.application),
"application_fee_amount" => Deserialize::begin(&mut self.application_fee_amount),
"automatic_payment_methods" => {
Deserialize::begin(&mut self.automatic_payment_methods)
}
"canceled_at" => Deserialize::begin(&mut self.canceled_at),
"cancellation_reason" => Deserialize::begin(&mut self.cancellation_reason),
"capture_method" => Deserialize::begin(&mut self.capture_method),
"client_secret" => Deserialize::begin(&mut self.client_secret),
"confirmation_method" => Deserialize::begin(&mut self.confirmation_method),
"created" => Deserialize::begin(&mut self.created),
"currency" => Deserialize::begin(&mut self.currency),
"customer" => Deserialize::begin(&mut self.customer),
"customer_account" => Deserialize::begin(&mut self.customer_account),
"description" => Deserialize::begin(&mut self.description),
"excluded_payment_method_types" => {
Deserialize::begin(&mut self.excluded_payment_method_types)
}
"hooks" => Deserialize::begin(&mut self.hooks),
"id" => Deserialize::begin(&mut self.id),
"last_payment_error" => Deserialize::begin(&mut self.last_payment_error),
"latest_charge" => Deserialize::begin(&mut self.latest_charge),
"livemode" => Deserialize::begin(&mut self.livemode),
"managed_payments" => Deserialize::begin(&mut self.managed_payments),
"metadata" => Deserialize::begin(&mut self.metadata),
"next_action" => Deserialize::begin(&mut self.next_action),
"on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of),
"payment_details" => Deserialize::begin(&mut self.payment_details),
"payment_method" => Deserialize::begin(&mut self.payment_method),
"payment_method_configuration_details" => {
Deserialize::begin(&mut self.payment_method_configuration_details)
}
"payment_method_options" => Deserialize::begin(&mut self.payment_method_options),
"payment_method_types" => Deserialize::begin(&mut self.payment_method_types),
"presentment_details" => Deserialize::begin(&mut self.presentment_details),
"processing" => Deserialize::begin(&mut self.processing),
"receipt_email" => Deserialize::begin(&mut self.receipt_email),
"review" => Deserialize::begin(&mut self.review),
"setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
"shipping" => Deserialize::begin(&mut self.shipping),
"source" => Deserialize::begin(&mut self.source),
"statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor),
"statement_descriptor_suffix" => {
Deserialize::begin(&mut self.statement_descriptor_suffix)
}
"status" => Deserialize::begin(&mut self.status),
"transfer_data" => Deserialize::begin(&mut self.transfer_data),
"transfer_group" => Deserialize::begin(&mut self.transfer_group),
_ => <dyn Visitor>::ignore(),
})
}
fn deser_default() -> Self {
Self {
amount: None,
amount_capturable: None,
amount_details: Some(None),
amount_received: None,
application: Some(None),
application_fee_amount: Some(None),
automatic_payment_methods: Some(None),
canceled_at: Some(None),
cancellation_reason: Some(None),
capture_method: None,
client_secret: Some(None),
confirmation_method: None,
created: None,
currency: None,
customer: Some(None),
customer_account: Some(None),
description: Some(None),
excluded_payment_method_types: Some(None),
hooks: Some(None),
id: None,
last_payment_error: Some(None),
latest_charge: Some(None),
livemode: None,
managed_payments: Some(None),
metadata: None,
next_action: Some(None),
on_behalf_of: Some(None),
payment_details: Some(None),
payment_method: Some(None),
payment_method_configuration_details: Some(None),
payment_method_options: Some(None),
payment_method_types: None,
presentment_details: Some(None),
processing: Some(None),
receipt_email: Some(None),
review: Some(None),
setup_future_usage: Some(None),
shipping: Some(None),
source: Some(None),
statement_descriptor: Some(None),
statement_descriptor_suffix: Some(None),
status: None,
transfer_data: Some(None),
transfer_group: Some(None),
}
}
fn take_out(&mut self) -> Option<Self::Out> {
let (
Some(amount),
Some(amount_capturable),
Some(amount_details),
Some(amount_received),
Some(application),
Some(application_fee_amount),
Some(automatic_payment_methods),
Some(canceled_at),
Some(cancellation_reason),
Some(capture_method),
Some(client_secret),
Some(confirmation_method),
Some(created),
Some(currency),
Some(customer),
Some(customer_account),
Some(description),
Some(excluded_payment_method_types),
Some(hooks),
Some(id),
Some(last_payment_error),
Some(latest_charge),
Some(livemode),
Some(managed_payments),
Some(metadata),
Some(next_action),
Some(on_behalf_of),
Some(payment_details),
Some(payment_method),
Some(payment_method_configuration_details),
Some(payment_method_options),
Some(payment_method_types),
Some(presentment_details),
Some(processing),
Some(receipt_email),
Some(review),
Some(setup_future_usage),
Some(shipping),
Some(source),
Some(statement_descriptor),
Some(statement_descriptor_suffix),
Some(status),
Some(transfer_data),
Some(transfer_group),
) = (
self.amount,
self.amount_capturable,
self.amount_details.take(),
self.amount_received,
self.application.take(),
self.application_fee_amount,
self.automatic_payment_methods.take(),
self.canceled_at,
self.cancellation_reason.take(),
self.capture_method.take(),
self.client_secret.take(),
self.confirmation_method.take(),
self.created,
self.currency.take(),
self.customer.take(),
self.customer_account.take(),
self.description.take(),
self.excluded_payment_method_types.take(),
self.hooks.take(),
self.id.take(),
self.last_payment_error.take(),
self.latest_charge.take(),
self.livemode,
self.managed_payments,
self.metadata.take(),
self.next_action.take(),
self.on_behalf_of.take(),
self.payment_details.take(),
self.payment_method.take(),
self.payment_method_configuration_details.take(),
self.payment_method_options.take(),
self.payment_method_types.take(),
self.presentment_details.take(),
self.processing.take(),
self.receipt_email.take(),
self.review.take(),
self.setup_future_usage.take(),
self.shipping.take(),
self.source.take(),
self.statement_descriptor.take(),
self.statement_descriptor_suffix.take(),
self.status.take(),
self.transfer_data.take(),
self.transfer_group.take(),
)
else {
return None;
};
Some(Self::Out {
amount,
amount_capturable,
amount_details,
amount_received,
application,
application_fee_amount,
automatic_payment_methods,
canceled_at,
cancellation_reason,
capture_method,
client_secret,
confirmation_method,
created,
currency,
customer,
customer_account,
description,
excluded_payment_method_types,
hooks,
id,
last_payment_error,
latest_charge,
livemode,
managed_payments,
metadata,
next_action,
on_behalf_of,
payment_details,
payment_method,
payment_method_configuration_details,
payment_method_options,
payment_method_types,
presentment_details,
processing,
receipt_email,
review,
setup_future_usage,
shipping,
source,
statement_descriptor,
statement_descriptor_suffix,
status,
transfer_data,
transfer_group,
})
}
}
impl Map for Builder<'_> {
fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
self.builder.key(k)
}
fn finish(&mut self) -> Result<()> {
*self.out = self.builder.take_out();
Ok(())
}
}
impl ObjectDeser for PaymentIntent {
type Builder = PaymentIntentBuilder;
}
impl FromValueOpt for PaymentIntent {
fn from_value(v: Value) -> Option<Self> {
let Value::Object(obj) = v else {
return None;
};
let mut b = PaymentIntentBuilder::deser_default();
for (k, v) in obj {
match k.as_str() {
"amount" => b.amount = FromValueOpt::from_value(v),
"amount_capturable" => b.amount_capturable = FromValueOpt::from_value(v),
"amount_details" => b.amount_details = FromValueOpt::from_value(v),
"amount_received" => b.amount_received = FromValueOpt::from_value(v),
"application" => b.application = FromValueOpt::from_value(v),
"application_fee_amount" => {
b.application_fee_amount = FromValueOpt::from_value(v)
}
"automatic_payment_methods" => {
b.automatic_payment_methods = FromValueOpt::from_value(v)
}
"canceled_at" => b.canceled_at = FromValueOpt::from_value(v),
"cancellation_reason" => b.cancellation_reason = FromValueOpt::from_value(v),
"capture_method" => b.capture_method = FromValueOpt::from_value(v),
"client_secret" => b.client_secret = FromValueOpt::from_value(v),
"confirmation_method" => b.confirmation_method = FromValueOpt::from_value(v),
"created" => b.created = FromValueOpt::from_value(v),
"currency" => b.currency = FromValueOpt::from_value(v),
"customer" => b.customer = FromValueOpt::from_value(v),
"customer_account" => b.customer_account = FromValueOpt::from_value(v),
"description" => b.description = FromValueOpt::from_value(v),
"excluded_payment_method_types" => {
b.excluded_payment_method_types = FromValueOpt::from_value(v)
}
"hooks" => b.hooks = FromValueOpt::from_value(v),
"id" => b.id = FromValueOpt::from_value(v),
"last_payment_error" => b.last_payment_error = FromValueOpt::from_value(v),
"latest_charge" => b.latest_charge = FromValueOpt::from_value(v),
"livemode" => b.livemode = FromValueOpt::from_value(v),
"managed_payments" => b.managed_payments = FromValueOpt::from_value(v),
"metadata" => b.metadata = FromValueOpt::from_value(v),
"next_action" => b.next_action = FromValueOpt::from_value(v),
"on_behalf_of" => b.on_behalf_of = FromValueOpt::from_value(v),
"payment_details" => b.payment_details = FromValueOpt::from_value(v),
"payment_method" => b.payment_method = FromValueOpt::from_value(v),
"payment_method_configuration_details" => {
b.payment_method_configuration_details = FromValueOpt::from_value(v)
}
"payment_method_options" => {
b.payment_method_options = FromValueOpt::from_value(v)
}
"payment_method_types" => b.payment_method_types = FromValueOpt::from_value(v),
"presentment_details" => b.presentment_details = FromValueOpt::from_value(v),
"processing" => b.processing = FromValueOpt::from_value(v),
"receipt_email" => b.receipt_email = FromValueOpt::from_value(v),
"review" => b.review = FromValueOpt::from_value(v),
"setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
"shipping" => b.shipping = FromValueOpt::from_value(v),
"source" => b.source = FromValueOpt::from_value(v),
"statement_descriptor" => b.statement_descriptor = FromValueOpt::from_value(v),
"statement_descriptor_suffix" => {
b.statement_descriptor_suffix = FromValueOpt::from_value(v)
}
"status" => b.status = FromValueOpt::from_value(v),
"transfer_data" => b.transfer_data = FromValueOpt::from_value(v),
"transfer_group" => b.transfer_group = FromValueOpt::from_value(v),
_ => {}
}
}
b.take_out()
}
}
};
#[cfg(feature = "serialize")]
impl serde::Serialize for PaymentIntent {
fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = s.serialize_struct("PaymentIntent", 45)?;
s.serialize_field("amount", &self.amount)?;
s.serialize_field("amount_capturable", &self.amount_capturable)?;
s.serialize_field("amount_details", &self.amount_details)?;
s.serialize_field("amount_received", &self.amount_received)?;
s.serialize_field("application", &self.application)?;
s.serialize_field("application_fee_amount", &self.application_fee_amount)?;
s.serialize_field("automatic_payment_methods", &self.automatic_payment_methods)?;
s.serialize_field("canceled_at", &self.canceled_at)?;
s.serialize_field("cancellation_reason", &self.cancellation_reason)?;
s.serialize_field("capture_method", &self.capture_method)?;
s.serialize_field("client_secret", &self.client_secret)?;
s.serialize_field("confirmation_method", &self.confirmation_method)?;
s.serialize_field("created", &self.created)?;
s.serialize_field("currency", &self.currency)?;
s.serialize_field("customer", &self.customer)?;
s.serialize_field("customer_account", &self.customer_account)?;
s.serialize_field("description", &self.description)?;
s.serialize_field("excluded_payment_method_types", &self.excluded_payment_method_types)?;
s.serialize_field("hooks", &self.hooks)?;
s.serialize_field("id", &self.id)?;
s.serialize_field("last_payment_error", &self.last_payment_error)?;
s.serialize_field("latest_charge", &self.latest_charge)?;
s.serialize_field("livemode", &self.livemode)?;
s.serialize_field("managed_payments", &self.managed_payments)?;
s.serialize_field("metadata", &self.metadata)?;
s.serialize_field("next_action", &self.next_action)?;
s.serialize_field("on_behalf_of", &self.on_behalf_of)?;
s.serialize_field("payment_details", &self.payment_details)?;
s.serialize_field("payment_method", &self.payment_method)?;
s.serialize_field(
"payment_method_configuration_details",
&self.payment_method_configuration_details,
)?;
s.serialize_field("payment_method_options", &self.payment_method_options)?;
s.serialize_field("payment_method_types", &self.payment_method_types)?;
s.serialize_field("presentment_details", &self.presentment_details)?;
s.serialize_field("processing", &self.processing)?;
s.serialize_field("receipt_email", &self.receipt_email)?;
s.serialize_field("review", &self.review)?;
s.serialize_field("setup_future_usage", &self.setup_future_usage)?;
s.serialize_field("shipping", &self.shipping)?;
s.serialize_field("source", &self.source)?;
s.serialize_field("statement_descriptor", &self.statement_descriptor)?;
s.serialize_field("statement_descriptor_suffix", &self.statement_descriptor_suffix)?;
s.serialize_field("status", &self.status)?;
s.serialize_field("transfer_data", &self.transfer_data)?;
s.serialize_field("transfer_group", &self.transfer_group)?;
s.serialize_field("object", "payment_intent")?;
s.end()
}
}
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum PaymentIntentCancellationReason {
Abandoned,
Automatic,
Duplicate,
Expired,
FailedInvoice,
Fraudulent,
RequestedByCustomer,
VoidInvoice,
Unknown(String),
}
impl PaymentIntentCancellationReason {
pub fn as_str(&self) -> &str {
use PaymentIntentCancellationReason::*;
match self {
Abandoned => "abandoned",
Automatic => "automatic",
Duplicate => "duplicate",
Expired => "expired",
FailedInvoice => "failed_invoice",
Fraudulent => "fraudulent",
RequestedByCustomer => "requested_by_customer",
VoidInvoice => "void_invoice",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for PaymentIntentCancellationReason {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use PaymentIntentCancellationReason::*;
match s {
"abandoned" => Ok(Abandoned),
"automatic" => Ok(Automatic),
"duplicate" => Ok(Duplicate),
"expired" => Ok(Expired),
"failed_invoice" => Ok(FailedInvoice),
"fraudulent" => Ok(Fraudulent),
"requested_by_customer" => Ok(RequestedByCustomer),
"void_invoice" => Ok(VoidInvoice),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"PaymentIntentCancellationReason"
);
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for PaymentIntentCancellationReason {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for PaymentIntentCancellationReason {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentIntentCancellationReason {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(PaymentIntentCancellationReason)).finish_non_exhaustive()
}
}
#[cfg(feature = "serialize")]
impl serde::Serialize for PaymentIntentCancellationReason {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl miniserde::Deserialize for PaymentIntentCancellationReason {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor for crate::Place<PaymentIntentCancellationReason> {
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out = Some(PaymentIntentCancellationReason::from_str(s).expect("infallible"));
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(PaymentIntentCancellationReason);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for PaymentIntentCancellationReason {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use std::str::FromStr;
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
Ok(Self::from_str(&s).expect("infallible"))
}
}
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum PaymentIntentStatus {
Canceled,
Processing,
RequiresAction,
RequiresCapture,
RequiresConfirmation,
RequiresPaymentMethod,
Succeeded,
Unknown(String),
}
impl PaymentIntentStatus {
pub fn as_str(&self) -> &str {
use PaymentIntentStatus::*;
match self {
Canceled => "canceled",
Processing => "processing",
RequiresAction => "requires_action",
RequiresCapture => "requires_capture",
RequiresConfirmation => "requires_confirmation",
RequiresPaymentMethod => "requires_payment_method",
Succeeded => "succeeded",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for PaymentIntentStatus {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use PaymentIntentStatus::*;
match s {
"canceled" => Ok(Canceled),
"processing" => Ok(Processing),
"requires_action" => Ok(RequiresAction),
"requires_capture" => Ok(RequiresCapture),
"requires_confirmation" => Ok(RequiresConfirmation),
"requires_payment_method" => Ok(RequiresPaymentMethod),
"succeeded" => Ok(Succeeded),
v => {
tracing::warn!("Unknown value '{}' for enum '{}'", v, "PaymentIntentStatus");
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for PaymentIntentStatus {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for PaymentIntentStatus {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentIntentStatus {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(PaymentIntentStatus)).finish_non_exhaustive()
}
}
#[cfg(feature = "serialize")]
impl serde::Serialize for PaymentIntentStatus {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl miniserde::Deserialize for PaymentIntentStatus {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor for crate::Place<PaymentIntentStatus> {
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out = Some(PaymentIntentStatus::from_str(s).expect("infallible"));
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(PaymentIntentStatus);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for PaymentIntentStatus {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use std::str::FromStr;
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
Ok(Self::from_str(&s).expect("infallible"))
}
}
impl stripe_types::Object for PaymentIntent {
type Id = stripe_shared::PaymentIntentId;
fn id(&self) -> &Self::Id {
&self.id
}
fn into_id(self) -> Self::Id {
self.id
}
}
stripe_types::def_id!(PaymentIntentId);
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum PaymentIntentCaptureMethod {
Automatic,
AutomaticAsync,
Manual,
Unknown(String),
}
impl PaymentIntentCaptureMethod {
pub fn as_str(&self) -> &str {
use PaymentIntentCaptureMethod::*;
match self {
Automatic => "automatic",
AutomaticAsync => "automatic_async",
Manual => "manual",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for PaymentIntentCaptureMethod {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use PaymentIntentCaptureMethod::*;
match s {
"automatic" => Ok(Automatic),
"automatic_async" => Ok(AutomaticAsync),
"manual" => Ok(Manual),
v => {
tracing::warn!("Unknown value '{}' for enum '{}'", v, "PaymentIntentCaptureMethod");
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for PaymentIntentCaptureMethod {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for PaymentIntentCaptureMethod {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentIntentCaptureMethod {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(PaymentIntentCaptureMethod)).finish_non_exhaustive()
}
}
impl serde::Serialize for PaymentIntentCaptureMethod {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl miniserde::Deserialize for PaymentIntentCaptureMethod {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor for crate::Place<PaymentIntentCaptureMethod> {
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out = Some(PaymentIntentCaptureMethod::from_str(s).expect("infallible"));
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(PaymentIntentCaptureMethod);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for PaymentIntentCaptureMethod {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use std::str::FromStr;
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
Ok(Self::from_str(&s).expect("infallible"))
}
}
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum PaymentIntentConfirmationMethod {
Automatic,
Manual,
Unknown(String),
}
impl PaymentIntentConfirmationMethod {
pub fn as_str(&self) -> &str {
use PaymentIntentConfirmationMethod::*;
match self {
Automatic => "automatic",
Manual => "manual",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for PaymentIntentConfirmationMethod {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use PaymentIntentConfirmationMethod::*;
match s {
"automatic" => Ok(Automatic),
"manual" => Ok(Manual),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"PaymentIntentConfirmationMethod"
);
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for PaymentIntentConfirmationMethod {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for PaymentIntentConfirmationMethod {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentIntentConfirmationMethod {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(PaymentIntentConfirmationMethod)).finish_non_exhaustive()
}
}
impl serde::Serialize for PaymentIntentConfirmationMethod {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl miniserde::Deserialize for PaymentIntentConfirmationMethod {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor for crate::Place<PaymentIntentConfirmationMethod> {
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out = Some(PaymentIntentConfirmationMethod::from_str(s).expect("infallible"));
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(PaymentIntentConfirmationMethod);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for PaymentIntentConfirmationMethod {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use std::str::FromStr;
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
Ok(Self::from_str(&s).expect("infallible"))
}
}
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum PaymentIntentExcludedPaymentMethodTypes {
AcssDebit,
Affirm,
AfterpayClearpay,
Alipay,
Alma,
AmazonPay,
AuBecsDebit,
BacsDebit,
Bancontact,
Billie,
Blik,
Boleto,
Card,
Cashapp,
Crypto,
CustomerBalance,
Eps,
Fpx,
Giropay,
Grabpay,
Ideal,
KakaoPay,
Klarna,
Konbini,
KrCard,
MbWay,
Mobilepay,
Multibanco,
NaverPay,
NzBankAccount,
Oxxo,
P24,
PayByBank,
Payco,
Paynow,
Paypal,
Payto,
Pix,
Promptpay,
RevolutPay,
SamsungPay,
Satispay,
SepaDebit,
Sofort,
Sunbit,
Swish,
Twint,
Upi,
UsBankAccount,
WechatPay,
Zip,
Unknown(String),
}
impl PaymentIntentExcludedPaymentMethodTypes {
pub fn as_str(&self) -> &str {
use PaymentIntentExcludedPaymentMethodTypes::*;
match self {
AcssDebit => "acss_debit",
Affirm => "affirm",
AfterpayClearpay => "afterpay_clearpay",
Alipay => "alipay",
Alma => "alma",
AmazonPay => "amazon_pay",
AuBecsDebit => "au_becs_debit",
BacsDebit => "bacs_debit",
Bancontact => "bancontact",
Billie => "billie",
Blik => "blik",
Boleto => "boleto",
Card => "card",
Cashapp => "cashapp",
Crypto => "crypto",
CustomerBalance => "customer_balance",
Eps => "eps",
Fpx => "fpx",
Giropay => "giropay",
Grabpay => "grabpay",
Ideal => "ideal",
KakaoPay => "kakao_pay",
Klarna => "klarna",
Konbini => "konbini",
KrCard => "kr_card",
MbWay => "mb_way",
Mobilepay => "mobilepay",
Multibanco => "multibanco",
NaverPay => "naver_pay",
NzBankAccount => "nz_bank_account",
Oxxo => "oxxo",
P24 => "p24",
PayByBank => "pay_by_bank",
Payco => "payco",
Paynow => "paynow",
Paypal => "paypal",
Payto => "payto",
Pix => "pix",
Promptpay => "promptpay",
RevolutPay => "revolut_pay",
SamsungPay => "samsung_pay",
Satispay => "satispay",
SepaDebit => "sepa_debit",
Sofort => "sofort",
Sunbit => "sunbit",
Swish => "swish",
Twint => "twint",
Upi => "upi",
UsBankAccount => "us_bank_account",
WechatPay => "wechat_pay",
Zip => "zip",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for PaymentIntentExcludedPaymentMethodTypes {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use PaymentIntentExcludedPaymentMethodTypes::*;
match s {
"acss_debit" => Ok(AcssDebit),
"affirm" => Ok(Affirm),
"afterpay_clearpay" => Ok(AfterpayClearpay),
"alipay" => Ok(Alipay),
"alma" => Ok(Alma),
"amazon_pay" => Ok(AmazonPay),
"au_becs_debit" => Ok(AuBecsDebit),
"bacs_debit" => Ok(BacsDebit),
"bancontact" => Ok(Bancontact),
"billie" => Ok(Billie),
"blik" => Ok(Blik),
"boleto" => Ok(Boleto),
"card" => Ok(Card),
"cashapp" => Ok(Cashapp),
"crypto" => Ok(Crypto),
"customer_balance" => Ok(CustomerBalance),
"eps" => Ok(Eps),
"fpx" => Ok(Fpx),
"giropay" => Ok(Giropay),
"grabpay" => Ok(Grabpay),
"ideal" => Ok(Ideal),
"kakao_pay" => Ok(KakaoPay),
"klarna" => Ok(Klarna),
"konbini" => Ok(Konbini),
"kr_card" => Ok(KrCard),
"mb_way" => Ok(MbWay),
"mobilepay" => Ok(Mobilepay),
"multibanco" => Ok(Multibanco),
"naver_pay" => Ok(NaverPay),
"nz_bank_account" => Ok(NzBankAccount),
"oxxo" => Ok(Oxxo),
"p24" => Ok(P24),
"pay_by_bank" => Ok(PayByBank),
"payco" => Ok(Payco),
"paynow" => Ok(Paynow),
"paypal" => Ok(Paypal),
"payto" => Ok(Payto),
"pix" => Ok(Pix),
"promptpay" => Ok(Promptpay),
"revolut_pay" => Ok(RevolutPay),
"samsung_pay" => Ok(SamsungPay),
"satispay" => Ok(Satispay),
"sepa_debit" => Ok(SepaDebit),
"sofort" => Ok(Sofort),
"sunbit" => Ok(Sunbit),
"swish" => Ok(Swish),
"twint" => Ok(Twint),
"upi" => Ok(Upi),
"us_bank_account" => Ok(UsBankAccount),
"wechat_pay" => Ok(WechatPay),
"zip" => Ok(Zip),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"PaymentIntentExcludedPaymentMethodTypes"
);
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for PaymentIntentExcludedPaymentMethodTypes {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for PaymentIntentExcludedPaymentMethodTypes {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentIntentExcludedPaymentMethodTypes {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(PaymentIntentExcludedPaymentMethodTypes)).finish_non_exhaustive()
}
}
impl serde::Serialize for PaymentIntentExcludedPaymentMethodTypes {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl miniserde::Deserialize for PaymentIntentExcludedPaymentMethodTypes {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor for crate::Place<PaymentIntentExcludedPaymentMethodTypes> {
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out = Some(PaymentIntentExcludedPaymentMethodTypes::from_str(s).expect("infallible"));
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(PaymentIntentExcludedPaymentMethodTypes);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for PaymentIntentExcludedPaymentMethodTypes {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use std::str::FromStr;
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
Ok(Self::from_str(&s).expect("infallible"))
}
}
#[derive(Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum PaymentIntentSetupFutureUsage {
OffSession,
OnSession,
Unknown(String),
}
impl PaymentIntentSetupFutureUsage {
pub fn as_str(&self) -> &str {
use PaymentIntentSetupFutureUsage::*;
match self {
OffSession => "off_session",
OnSession => "on_session",
Unknown(v) => v,
}
}
}
impl std::str::FromStr for PaymentIntentSetupFutureUsage {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
use PaymentIntentSetupFutureUsage::*;
match s {
"off_session" => Ok(OffSession),
"on_session" => Ok(OnSession),
v => {
tracing::warn!(
"Unknown value '{}' for enum '{}'",
v,
"PaymentIntentSetupFutureUsage"
);
Ok(Unknown(v.to_owned()))
}
}
}
}
impl std::fmt::Display for PaymentIntentSetupFutureUsage {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(not(feature = "redact-generated-debug"))]
impl std::fmt::Debug for PaymentIntentSetupFutureUsage {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[cfg(feature = "redact-generated-debug")]
impl std::fmt::Debug for PaymentIntentSetupFutureUsage {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct(stringify!(PaymentIntentSetupFutureUsage)).finish_non_exhaustive()
}
}
impl serde::Serialize for PaymentIntentSetupFutureUsage {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl miniserde::Deserialize for PaymentIntentSetupFutureUsage {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}
impl miniserde::de::Visitor for crate::Place<PaymentIntentSetupFutureUsage> {
fn string(&mut self, s: &str) -> miniserde::Result<()> {
use std::str::FromStr;
self.out = Some(PaymentIntentSetupFutureUsage::from_str(s).expect("infallible"));
Ok(())
}
}
stripe_types::impl_from_val_with_from_str!(PaymentIntentSetupFutureUsage);
#[cfg(feature = "deserialize")]
impl<'de> serde::Deserialize<'de> for PaymentIntentSetupFutureUsage {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use std::str::FromStr;
let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
Ok(Self::from_str(&s).expect("infallible"))
}
}