Dodo Payments Rust SDK
Rust sdk to interact with dodopayments REST API.
The REST API documentation can be found on docs.dodopayments.com.
Installation
cargo add dodopayments_rust
Usage
use dodopayments_rust::{DodoPaymentsClient, DodoPaymentsClientBuilder, ResponseData};
use std::collections::HashMap;
#[tokio::main]
async fn main() {
let client: DodoPaymentsClient = DodoPaymentsClientBuilder::new()
.bearer_token("")
.enviroment("test_mode")
.build()
.unwrap();
let mut query_params = HashMap::new();
query_params.insert("status", "succeeded");
let body = None;
let ext_path = None;
match client
.payments()
.list(Some(query_params), body, ext_path)
.await
{
Ok(resp) => match resp {
ResponseData::Text(text) => {
println!("Text response: {}", text);
}
ResponseData::Blob(bytes) => {
std::fs::write("invoice.pdf", &bytes).expect("Failed to write file");
}
},
Err(err) => eprintln!("Error: {}", err),
}
}
Examples
You can checkout examples folder to view the usage of all the endpoints.
To run any example run the following command in your root
cargo run --example <file_name>