14 releases (5 breaking)
0.6.1 | Jan 18, 2023 |
---|---|
0.6.0 | Jan 17, 2023 |
0.5.0 | Jan 17, 2023 |
0.4.2 | Jan 16, 2023 |
0.1.1 | Jan 9, 2023 |
#1880 in Web programming
42 downloads per month
190KB
2K
SLoC
ezstripe 💳
Use ezstripe to easily communicate with Stripe's API.
Usage
Installation
# Cargo.toml
[dependencies]
ezstripe = "0.6.1"
or
cargo add ezstripe
Features
All features are enabled by default, but you can only select the features you really need for your project.
# Cargo.toml
[dependencies]
ezstripe = { version = "0.6.1", default-features = false, features = ["payment_intent", "refund"] }
Example
# Cargo.toml
[dependencies]
ezstripe = "0.6.1"
env_logger = "0.10.0" # Optional
// Required to use the `ezbody!` macro
#[macro_use] extern crate ezstripe;
#[tokio::main]
async fn main() {
// To show possible errors (recommended for development)
env_logger::init_from_env(env_logger::Env::default().filter_or("MY_LOG_LEVEL", "debug"));
// We need a client to make requests
let client = ezstripe::Client::new("SECRET_KEY");
// Create a body for the request
let stripe_body = ezbody!(
"amount" => 1500,
"currency" => "eur",
"payment_method_types[]" => "card",
"payment_method_types[]" => "sofort",
"capture_method" => "automatic",
"shipping[name]" => "Your Name",
"shipping[address][city]" => "Test"
);
// Now send a request to Stripe's API
let stripe_response = client.create_payment_intent(stripe_body).send().await;
if let Err((e_msg, e_info)) = stripe_response {
if let Some(r) = e_info {
println!("{}: {} | {} | {}", e_msg, r.r#type, r.code, r.message);
} else { // Such an error only occurs when a request to Stripe failed
println!("{}", e_msg);
}
std::process::exit(1);
}
// No error, so let's unpack the answer
let stripe_result = stripe_response.unwrap();
// Print the unique ID from the created PaymentIntent
println!("Created: {}", stripe_result.id);
}
Status
A list of currently supported and planned features.
- Balance
- Balance Transactions
- Charges
- Customers
- Disputes
- Events
- Files
- File Links
- Mandates
- PaymentIntents
- SetupIntents
- SetupAttempts
- Payouts
- Refunds
- Tokens
Contributing
Note
We don't bring in code from other projects! I ask you to respect the projects of others and the time invested and not to copy anything! No Struct! No Line!
Interested in contributing to this SDK? Github offers you the possibility to create pull requests where you can contribute your work to improve the experience with ezstripe!
License
I spent hours writing the code and creating each member of a struct. So please respect my time and work.
This project is licensed under MIT license.
Dependencies
~4–15MB
~220K SLoC