| Crates.io | stripe-webhooks |
| lib.rs | stripe-webhooks |
| version | 0.3.0 |
| created_at | 2025-09-22 22:29:21.383385+00 |
| updated_at | 2025-11-27 23:25:02.119891+00 |
| description | Stripe webhook integration |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1850705 |
| size | 19,695 |
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.
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);
}
}
}