Crates.io | ezstripe |
lib.rs | ezstripe |
version | 0.6.1 |
source | src |
created_at | 2023-01-09 13:33:42.725627 |
updated_at | 2023-01-18 09:19:34.289491 |
description | Use ezstripe to easily communicate with Stripe's API. |
homepage | |
repository | https://github.com/EntenKoeniq/ezstripe |
max_upload_size | |
id | 754524 |
size | 216,480 |
Use ezstripe to easily communicate with Stripe's API.
# Cargo.toml
[dependencies]
ezstripe = "0.6.1"
or
cargo add ezstripe
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"] }
# 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);
}
A list of currently supported and planned features.
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!
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.