Skip to content

listen to webhooks from stripe supports basic events particularly around checkout completions and subscription deletions.

Notifications You must be signed in to change notification settings

bytebury/stripe-webhooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);
        }
    }
}

About

listen to webhooks from stripe supports basic events particularly around checkout completions and subscription deletions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages