Update your Cargo.toml file to use full features in tokio.
Copy
Ask AI
[package]name = "zbd-rust"version = "0.1.0"edition = "2021"# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html[dependencies]tokio = { version = "1.29.1", features = ['full']}zebedee-rust = "0.4.4"
Open your project’s main.rs file and add the following code:
Copy
Ask AI
use std::env;use zebedee_rust::{charges::*, ZebedeeClient};#[tokio::main]async fn main(){ let apikey: String = env::var("ZBD_API_KEY").unwrap(); let zbd_client = ZebedeeClient::new().apikey(apikey).build(); let charge = Charge{ amount: String::from("5000"), ..Default::default() }; let charges_res = zbd_client.create_charge(&charge).await.unwrap(); println!("{:?}", charge_res);}
Make sure to create an environment variable called ZBD_API_KEY in your Rust project. This is the API key you get from your ZBD Project.
Run the following command to create your charge:
Copy
Ask AI
cargo run
You can now create charges using the ZBD and Rust!
Charges and payment requests are usually shown to users as QR codes that can be scanned by mobile apps (e.g. ZBD). Read Callbacks to understand how to receive updates about your payment asynchronously.