1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
use serde::Serialize;
use crate::client::{Client, Response};
use crate::resources::SetupIntent;
use crate::{SetupIntentCancellationReason, SetupIntentId};
/// The set of parameters that can be used when confirming a setup_intent object.
///
/// For more details see <https://stripe.com/docs/api/setup_intents/confirm>
#[derive(Clone, Debug, Serialize)]
pub struct ConfirmSetupIntent {
/// The client secret if on the client side
#[serde(skip_serializing_if = "Option::is_none")]
pub client_secret: Option<String>,
/// Specifies which payment method
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_method: Option<String>,
// Mandate data and payment method options not implemented. If you want
// something better, create an issue and lets fix
/// The URL to redirect your customer back to after they authenticate on the payment method’s app or site.
#[serde(skip_serializing_if = "Option::is_none")]
pub return_url: Option<String>,
}
/// The set of parameters that can be used when canceling a setup_intent object.
///
/// For more details see <https://stripe.com/docs/api/setup_intents/cancel>
#[derive(Clone, Debug, Default, Serialize)]
pub struct CancelSetupIntent {
#[serde(skip_serializing_if = "Option::is_none")]
pub cancellation_reason: Option<SetupIntentCancellationReason>,
}
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)
}
/// A SetupIntent object can be canceled when it is in one of these statuses: requires_payment_method, requires_confirmation, or requires_action.
///
/// For more details see <https://stripe.com/docs/api/setup_intents/cancel>.
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 {}