| Crates.io | dintero |
| lib.rs | dintero |
| version | 0.2.0 |
| created_at | 2025-11-05 21:06:14.150811+00 |
| updated_at | 2025-12-29 16:53:37.744974+00 |
| description | Rust SDK for Dintero APIs |
| homepage | |
| repository | https://github.com/budna-marketplace/dintero-rust-sdk |
| max_upload_size | |
| id | 1918635 |
| size | 166,061 |
A comprehensive Rust SDK for the Dintero API, providing convenient and type-safe access to all Dintero services.
tokio and reqwest for async operationsAdd this to your Cargo.toml:
[dependencies]
dintero = "0.1"
By default, all features are enabled. You can selectively enable only what you need:
[dependencies]
dintero = { version = "0.1", default-features = false, features = ["checkout", "orders"] }
Available features:
checkout - Checkout API supportorders - Orders API supportpayments - Payments API supportaccounts - Accounts API supportloyalty - Loyalty API supportinsights - Insights API supportuse dintero::{DinteroClient, DinteroConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client
let config = DinteroConfig::new(
"your-account-id",
"your-client-id",
"your-client-secret"
);
let client = DinteroClient::new(config);
Ok(())
}
use dintero::DinteroClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Reads from DINTERO_ACCOUNT_ID, DINTERO_CLIENT_ID, DINTERO_CLIENT_SECRET
let client = DinteroClient::from_env()?;
Ok(())
}
use dintero::{DinteroClient, DinteroConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = DinteroClient::from_env()?;
#[cfg(feature = "checkout")]
{
use dintero_checkout::{SessionCreateRequest, Order, OrderLine, Money};
let request = SessionCreateRequest::builder()
.url("https://example.com/return".to_string())
.order(
Order::builder()
.amount(Money::new(10000, "NOK"))
.add_item(
OrderLine::builder()
.id("item-1".to_string())
.description("Test Item".to_string())
.quantity(1)
.amount(10000)
.build()
)
.build()
)
.build();
let session = client.checkout().create_session(request).await?;
println!("Checkout URL: {}", session.url);
}
Ok(())
}
use dintero::{DinteroClient, DinteroConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = DinteroClient::from_env()?;
#[cfg(feature = "orders")]
{
// Get an order
let order = client.orders().get_order("order-id").await?;
println!("Order status: {:?}", order.status);
// List orders
let orders = client.orders().list_orders().await?;
println!("Found {} orders", orders.len());
}
Ok(())
}
use dintero::{DinteroClient, DinteroConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = DinteroClient::from_env()?;
#[cfg(feature = "payments")]
{
use dintero_payments::CaptureRequest;
// Capture a payment
let capture = CaptureRequest::builder()
.amount(5000)
.build();
let result = client.payments()
.capture_payment("transaction-id", capture)
.await?;
println!("Captured: {}", result.amount);
}
Ok(())
}
The repository includes comprehensive examples in the dintero/examples/ directory:
basic.rs - Basic client setup and configurationcheckout_session.rs - Creating checkout sessionsorders.rs - Order management operationspayments.rs - Payment and capture operationsaccounts.rs - Account managementloyalty.rs - Loyalty program integrationinsights.rs - Analytics and reportingRun an example:
cargo run --example basic --features checkout
The SDK supports multiple authentication methods:
export DINTERO_ACCOUNT_ID="your-account-id"
export DINTERO_CLIENT_ID="your-client-id"
export DINTERO_CLIENT_SECRET="your-client-secret"
use dintero::DinteroConfig;
let config = DinteroConfig::new(
"account-id",
"client-id",
"client-secret"
);
use dintero::DinteroConfig;
let config = DinteroConfig::builder()
.account_id("account-id")
.client_id("client-id")
.client_secret("client-secret")
.base_url("https://api.dintero.com") // optional
.build();
The SDK uses a custom error type that wraps all possible errors:
use dintero::{DinteroClient, DinteroError};
async fn example() -> Result<(), DinteroError> {
let client = DinteroClient::from_env()?;
match client.checkout().get_session("session-id").await {
Ok(session) => println!("Session found: {}", session.id),
Err(DinteroError::NotFound) => println!("Session not found"),
Err(DinteroError::Authentication) => println!("Authentication failed"),
Err(e) => println!("Error: {}", e),
}
Ok(())
}
Run all tests:
cargo test --all-features
Run tests for a specific feature:
cargo test --features checkout
Full API documentation is available at docs.rs/dintero.
Build documentation locally:
cargo doc --all-features --open
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright © 2024 Budna Marketplace AB. All rights reserved.
Author: Marcus Cvjeticanin