Skip to main content

ferro_stripe/
error.rs

1/// Errors that can occur in ferro-stripe operations.
2#[derive(Debug, thiserror::Error)]
3pub enum Error {
4    /// Configuration error (missing env var or invalid value).
5    #[error("stripe config error: {0}")]
6    Config(String),
7
8    /// Stripe API returned an error.
9    #[error("stripe API error: {0}")]
10    Stripe(String),
11
12    /// No Connect account linked to this tenant.
13    #[error("no Stripe Connect account linked to this tenant")]
14    NoConnectAccount,
15
16    /// Webhook signature verification failed.
17    #[error("webhook verification failed: {0}")]
18    WebhookVerification(String),
19
20    /// Event was already processed (idempotency guard).
21    #[error("stripe event already processed: {0}")]
22    EventAlreadyProcessed(String),
23
24    /// Idempotency key not set on CheckoutBuilder before calling create().
25    #[error("idempotency key required: call .idempotency_key() before .create()")]
26    MissingIdempotencyKey,
27
28    /// manual_capture() requires Mode::Payment. Mode::Subscription does not support
29    /// deferred capture — each subscription invoice is charged automatically.
30    #[error("manual capture requires payment mode; use Mode::Payment with manual_capture()")]
31    ManualCaptureRequiresPaymentMode,
32}
33
34impl From<stripe::StripeError> for Error {
35    fn from(e: stripe::StripeError) -> Self {
36        Error::Stripe(e.to_string())
37    }
38}