Use ezstripe to easily communicate with Stripe's API.
Warning
Up to version1.0.0
a lot of the structure can change with each new version!
Therefore, with every new version, pay attention to the changes in the changelogs on Github!
```toml
[dependencies]
ezstripe = "0.2.2"
``
or
cargo add ezstripe`
```toml
[dependencies] tokio = { version = "1.24.1", features = ["full"] } ezstripe = "0.2.2" ```
``Rust
// Required to use the
ezbody!` macro
async fn main() { // Enable debug to show possible errors in our console unsafe { ezstripe::set_debug(true); };
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((emsg, einfo)) = striperesponse { if let Some(r) = einfo { println!("{}: {} | {} | {}", emsg, r.r#type.originalstr(), r.code.originalstr(), r.message); } else { // Such an error only occurs when a request to Stripe failed println!("{}", emsg); } 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); } ```