Skip to main content

ferro_stripe/
lib.rs

1//! # ferro-stripe
2//!
3//! Stripe payment integration for the Ferro framework, organized along
4//! the capability axis: [`checkout`], [`refund`], [`account`],
5//! [`idempotency`], [`webhook`].
6//!
7//! ## Quick Start
8//!
9//! ```rust,ignore
10//! use ferro_stripe::{Stripe, StripeConfig};
11//!
12//! // Initialize once at app startup.
13//! let config = StripeConfig::from_env().expect("Stripe config not set");
14//! Stripe::init(config);
15//! ```
16//!
17//! ## Creating a Checkout session
18//!
19//! ```rust,ignore
20//! use ferro_stripe::{CheckoutBuilder, Mode, LineItem};
21//!
22//! let intent = CheckoutBuilder::new(Mode::Payment)
23//!     .line_item(LineItem {
24//!         name: "Widget".into(),
25//!         description: None,
26//!         unit_amount_cents: 1000,
27//!         quantity: 1,
28//!         currency: "usd".into(),
29//!     })
30//!     .success_url("https://example.com/ok")
31//!     .cancel_url("https://example.com/cancel")
32//!     .idempotency_key("order-42")
33//!     .create()
34//!     .await?;
35//! ```
36//!
37//! ## Webhook idempotency
38//!
39//! Implement [`ProcessedEventLog`] against your database (see the module
40//! docs on [`idempotency`] for the recommended SQL schema). Use
41//! [`MemoryProcessedLog`] in tests and single-process development only.
42
43pub mod account;
44pub mod checkout;
45pub mod client;
46pub mod config;
47pub mod error;
48pub mod idempotency;
49pub mod payment_intent;
50pub mod refund;
51#[cfg(any(test, feature = "test-helpers"))]
52pub mod testing;
53pub mod webhook;
54
55pub use account::{billing_portal_url, create_account, create_link, retrieve_account};
56pub use checkout::{CheckoutBuilder, CheckoutIntent, LineItem, Mode};
57pub use client::Stripe;
58pub use config::StripeConfig;
59pub use error::Error;
60pub use idempotency::{MemoryProcessedLog, ProcessedEventLog};
61pub use webhook::events::StripeEvent;
62pub use webhook::events::{
63    StripeChargeDisputeCreated, StripeChargeRefunded, StripeCheckoutCompleted,
64    StripeCheckoutExpired, StripeConnectAccountUpdated, StripeConnectPaymentSucceeded,
65    StripeInvoicePaid, StripePaymentIntentAmountCapturableUpdated, StripePaymentIntentCanceled,
66    StripePaymentIntentFailed, StripeSubscriptionDeleted, StripeSubscriptionUpdated, WebhookEvent,
67};
68pub use webhook::queue::ProcessStripeWebhook;
69pub use webhook::sync::SyncDispatcher;
70pub use webhook::verify::verify_webhook;