Use ezstripe to easily communicate with Stripe's API.
```toml
[dependencies]
ezstripe = "0.2.0"
``
or
cargo add ezstripe`
```toml
[dependencies] tokio = { version = "1.24.1", features = ["full"] } ezstripe = "0.2.0" ```
``Rust
// Required to use the
ezbody!` macro
async fn main() { let client = ezstripe::Client { secretkey: "YOURSECRETKEY".tostring() };
// Returns: String("amount=1500;currency=eur;paymentmethodtypes[]=card;capturemethod=manual;") let stripebody = ezbody!( "amount" => 1500, "currency" => "eur", "paymentmethodtypes[]" => "card", "capture_method" => "manual" );
// Now send a request to Stripe's API let striperesponse = client.createpaymentintent(stripebody).send().await;
if let Err(e) = striperesponse { if let Some(r) = e { println!("{} | {} | {}", r.r#type.originalstr(), r.code.original_str(), r.message); } else { // Such an error only occurs when a request to Stripe failed println!("Unknown error!"); } std::process::exit(1); }
// No error, so let's unpack the answer let striperesult = striperesponse.unwrap();
// Print the unique ID from the created PaymentIntent println!("Created: {}", stripe_result.id); } ```