stripe/lib.rs
1// Copyright 2019 Wyyerd Group, LLC.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9#![doc(html_root_url = "https://docs.rs/async-stripe/")]
10#![recursion_limit = "128"]
11
12//! This crate provides Rust bindings to the Stripe HTTP API.
13//!
14//! ## Getting Started
15//!
16//! To get started, we need to create a [Client]:
17//!
18//! ```
19//! # #[cfg(feature = "__hyper")]
20//! let client = stripe::Client::new("sk_test_YOUR_STRIPE_SECRET");
21//! ```
22//!
23//! Then we can begin making requests as we'd like. Most Stripe requests accept
24//! many optional parameters, so we usually get the `::new(...)` with any required
25//! params and then set the ones we want from there.
26//!
27//! Most requests for creating or updating a Stripe object use the same Rust struct,
28//! so you may frequently need to refer to the [official API docs](https://stripe.com/docs/api)
29//! to determine which fields are required for either request.
30//!
31//! > **Note:** We have an extensive collection of examples which are interspersed in
32//! > the documentation. Any time an API is used in an example it is highlighted in the
33//! > docs for that item. You can also find all the raw examples in the `examples` directory.
34//! > Please have a look at those for inspiration or ideas on how to get started.
35//!
36//! ## Idempotency / Request Strategies
37//!
38//! This library provides a few basic request strategies for making requests to the Stripe API.
39//! This is currently implemented as an enum with the following variants:
40//!
41//! - [`RequestStrategy::Once`]: This is the default strategy. It will make a request to the Stripe API and,
42//! whether the request fails or not, will simply return the response.
43//! - [`RequestStrategy::Idempotent`]: This strategy will make a request to stripe api, passing the provided
44//! key to Stripe as the `Idempotency-Key` header, ensuring that the request is idempotent. If the request fails, you may retry it.
45//!
46//! - [`RequestStrategy::Retry`]: Make a request to the Stripe API and, if the request fails, retry it up to n
47//! times with a timeout. The idempotency key is generated automatically and is stable across retries.
48//!
49//! - [`RequestStrategy::ExponentialBackoff`]: Make a request to the Stripe API and, if the request fails, retry
50//! it up to n times with exponential backoff. The idempotency key is generated automatically and is stable across retries.
51//!
52//! > Want to implement your own? If it is a common strategy, please consider opening a PR to add it to the library.
53//! > Otherwise, we are open to turning this into an open trait so that you can implement your own strategy.
54
55#![warn(clippy::missing_errors_doc, clippy::missing_panics_doc)]
56#![deny(missing_docs, missing_debug_implementations)]
57#![forbid(unsafe_code)]
58
59mod error;
60
61#[cfg(feature = "async-std-surf")]
62pub mod async_std;
63
64#[cfg(feature = "__hyper")]
65mod hyper;
66pub use error::StripeError;
67#[cfg(feature = "__hyper")]
68pub use hyper::*;
69pub use stripe_client_core::{
70 CustomizedStripeRequest, IdempotencyKey, IdempotentKeyError, ListPaginator, PaginationExt,
71 RequestStrategy, StripeRequest,
72};
73pub use stripe_shared::api_errors::*;
74pub use stripe_shared::{AccountId, ApplicationId};