| Crates.io | simple-stripe |
| lib.rs | simple-stripe |
| version | 0.1.0 |
| created_at | 2025-07-31 04:25:38.821391+00 |
| updated_at | 2025-07-31 04:25:38.821391+00 |
| description | Simple Stripe for create checkout session and webhook event |
| homepage | |
| repository | https://github.com/sunhuachuang/simple-stripe |
| max_upload_size | |
| id | 1774401 |
| size | 72,495 |
Simple Stripe Client for basic create checkout session and webhook event.
Simplify Stripe integration.
payment and subscription.Webhook listening:
checkout.session.completedinvoice.paidinvoice.payment_failedcustomer.subscription.deleteduse simple_stripe::{SimpleEvent, Stripe};
#[tokio::main]
async fn main() {
let secret = "sk_xxx";
let webhook_key = "whsec_xxx";
let mut stripe = Stripe::init(secret, webhook_key);
stripe.add_payment_price(price_id1);
stripe.add_subscription_price(price_id2);
stripe.set_urls("https://success.url", "https://cacel.url");
let (session_id, session_url) = stripe.create_session(
your_uuid,
email_option,
customer_option,
price_id,
quantity
).await?;
// just open session url in front-end and pay
// listen the webhook and parse the event
let signature = headers.get("stripe-signature").unwrap().to_str().unwrap();
let event = stripe.simple_event(&request_body, &signature)
match event {
SimpleEvent::PaymentComplete(session_id, customer) => {
// handle the payment session paid & cimpleted
}
SimpleEvent::SubscriptionCreated(session, customer) => {
// handle the subscription session created
}
SimpleEvent::SubscriptionPaid(customer, _products) => {
// handle the subscription paid
}
SimpleEvent::SubscriptionDeleted(customer, _products) => {
// handle the subscription canceled
}
SimpleEvent::None(_type) => (),
}
}
This project is licensed under either of
at your option.