async-stripe
Rust API bindings for the Stripe v1 HTTP API.
This is compatible with all currently supported versions of Stripe's client-side libraries including https://js.stripe.com/v2/ and https://js.stripe.com/v3/.
API Version
The latest supported version of the Stripe API is 2020-08-27
.
Set the corresponding crate version depending on which version of the Stripe API you are pinned to.
If you don't see the specific version you are on, prefer the next available version.
0.13
- stripe version2020-08-27
0.12
- stripe version2019-09-09
Install
async-stripe
is compatible with the async-std
and tokio
runtimes and the native-tls
and rustls
backends. When adding the dependency, you much select a runtime feature.
[]
= { = "0.13.0-rc1", = ["runtime-async-std-surf"] }
Feature Flags
Runtimes
runtime-tokio-hyper
runtime-tokio-hyper-rustls
runtime-blocking
runtime-blocking-rustls
runtime-async-std-surf
API Features
Additionally, since this is a large library, it is possible to conditionally enable features as required to reduce compile times and final binary size. Refer to the Stripe API docs to determine which APIs are included as part of each feature flag.
# Example: Core-only (enough to create a `Charge` or `Card` or `Customer`)
= { = "*", = false, = ["runtime-async-std-surf"] }
# Example: Support for "Subscriptions" and "Invoices"
= { = "*", = false, = ["runtime-async-std-surf", "billing"] }
Getting Started
/* Create a Stripe Client */
let client = new;
/* Create a Stripe Charge */
let token = "TOKEN_FROM_CHECKOUT".parse.expect;
let mut params = new;
// NOTE: Stripe represents currency in the lowest denominations (e.g. cents)
params.amount = Some; // e.g. $10.95
params.source = Some;
// Example: Override currency to be in Canadian Dollars
params.currency = Some;
let charge = create.unwrap;
println!; // => Charge { id: "ch_12345", amount: 1095, .. }
/* List Stripe Charges */
let params = new;
let charges = list.unwrap;
println!; // => List { data: [Charge { id: "ch_12345", .. }] }
Most requests for creating or updating a Stripe object use the same Rust struct, so you may frequently need to refer to the official API docs to determine which fields are required for either request.
Using Custom Connect accounts
This crate supports impersonating a custom connect account. To impersonate the account get a new Client and pass in the account id.
let mut headers = default;
headers.stripe_account = Some;
headers.client_id = Some;
let client = client.with_headers;
// Then, all requests can be made normally
let params = default;
let customers = list.unwrap;
println!; // => List { data: [Customer { .. }] }
Contributing
See CONTRIBUTING.md for information on contributing to rustup.
License
This project started as a fork of stripe-rs. We would not be here without them! :)
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.