stripe-webhooks

Crates.iostripe-webhooks
lib.rsstripe-webhooks
version0.3.0
created_at2025-09-22 22:29:21.383385+00
updated_at2025-11-27 23:25:02.119891+00
descriptionStripe webhook integration
homepage
repository
max_upload_size
id1850705
size19,695
Marcello (boba-sh)

documentation

README

stripe-webhooks

Listens to basic webhooks from Stripe. Particularly those that are common for subscribing and cancelling a subscription from Stripe. However, you can also incorporate all of the hooks by using the StripeEvent::Unknown enum.

Usage

pub async handler(headers: HeaderMap, body: String) {
    let stripe_events = StripeListener::from_env();
    let stripe_event = match stripe_events.process(&headers, &body) {
        Ok(event) => event,
        Err(e) => {
            eprintln!("Failed to process webhook: {:?}", e)
            return;
        };
    };

    match stripe_event {
        StripeEvent::CheckoutSessionCompleted(ev) => {
            println!("Checkout session completed: {:?}", ev);
        },
        StripeEvent::CustomerSubscriptionDeleted(obj) => {
            println!("Customer subscription deleted: {:?}", obj);
        }
        StripeEvent::Unknown(obj) => {
            println!("Unknown Stripe event: {:?}", obj);
        }
    }
}
Commit count: 0

cargo fmt