use serde::Serialize;
use crate::client::{Client, Response};
use crate::params::Expand;
use crate::resources::SetupIntent;
use crate::{PaymentMethodId, SetupIntentCancellationReason, SetupIntentId};
#[derive(Clone, Debug, Serialize)]
pub struct ConfirmSetupIntent {
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_method: Option<PaymentMethodId>,
#[serde(skip_serializing_if = "Option::is_none")]
pub mandate_data: Option<MandateData>,
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_method_data: Option<crate::UpdatePaymentIntentPaymentMethodData>,
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_method_options: Option<crate::UpdatePaymentIntentPaymentMethodOptions>,
#[serde(skip_serializing_if = "Option::is_none")]
pub return_url: Option<String>,
pub use_stripe_sdk: bool,
}
#[derive(Clone, Debug, Default, Serialize)]
pub struct MandateData {
pub customer_acceptance: crate::CustomerAcceptance,
}
#[derive(Clone, Debug, Default, Serialize)]
pub struct CancelSetupIntent {
#[serde(skip_serializing_if = "Option::is_none")]
pub cancellation_reason: Option<SetupIntentCancellationReason>,
}
#[derive(Clone, Debug, Default, Serialize)]
pub struct VerifyMicrodeposits<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub amounts: Option<Vec<i64>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub descriptor_code: Option<&'a str>,
#[serde(skip_serializing_if = "Expand::is_empty")]
pub expand: &'a [&'a str],
}
impl SetupIntent {
pub fn confirm(
client: &Client,
setup_id: &SetupIntentId,
params: ConfirmSetupIntent,
) -> Response<SetupIntent> {
#[allow(clippy::needless_borrows_for_generic_args)]
client.post_form(&format!("/setup_intents/{}/confirm", setup_id), ¶ms)
}
pub fn verify_micro_deposits(
client: &Client,
setup_id: &SetupIntentId,
params: VerifyMicrodeposits,
) -> Response<SetupIntent> {
client.post_form(&format!("/setup_intents/{}/verify_microdeposits", setup_id), ¶ms)
}
pub fn cancel(
client: &Client,
setup_id: &SetupIntentId,
params: CancelSetupIntent,
) -> Response<SetupIntent> {
client.post_form(&format!("/setup_intents/{}/cancel", setup_id), params)
}
}
#[cfg(test)]
mod test {}