Is Shima Right for You?
Shima is a lightweight, high-performance Stripe API client library written in Rust. It is designed for developers who need a fast, type-safe, and minimal-dependency way to integrate Stripe payments into their Rust applications. With that being said, Shima is not suitable for all use cases. Here are some scenarios where Shima might be a good fit:
- You use Stripe for checkouts and customer management.
- You use Stripe for Subscriptions.
- You use Stripe for Webhooks regarding Subscriptions.
Benefits
- Shima compiles up to 10x faster than
async-stripe. - Fast
- Type-safe
- Minimal dependencies
- Easy to use
- Macros remove all the boilerplate code
Getting Started
Add shima to your Cargo.toml file:
# gives you the basics including macros
# if you want to use this with sqlx
# if you want to use this with webhooks
# or you can enable all features
Usage
Generating a new shima client
// You can generate a client directly from your environment variables
// if you have `STRIPE_SECRET_KEY` and will also set the webhook if
// `STRIPE_WEBHOOK_SECRET` is set. This is preferred.
let client = from_env;
// Alternatively, you can load it from a string without a webhook secret.
let client = new;
// Or, you can load it from a string with a webhook secret.
let client = new.with_webhook_secret;
Creating a Stripe Customer
There are two ways that you can create a Customer in Stripe. You can either use the create_customer! macro or go through the Customer struct.
/// This creates a new Customer in Stripe with the macro.
async
// Create a Customer in Stripe.
async
Purchasing Subscriptions / Checkout
There are two ways that you can create a Checkout Session for a Customer. You can either use the
checkout! macro or go through the CheckoutSession struct.
/// This creates a new Checkout Session for a Customer with the macro.
async
// Create a Checkout Session for a Customer.
async
Manage Subscriptions / Customer Portal
/// Bring the customer to their Customer Portal via the macro.
async
/// Bring the customer to their Customer Portal via code.
async
Webhooks
use ShimaEvent;
// Listen to Stripe events via webhooks