| Crates.io | sumup-rs |
| lib.rs | sumup-rs |
| version | 0.2.0 |
| created_at | 2025-07-31 21:20:10.484222+00 |
| updated_at | 2025-07-31 21:20:10.484222+00 |
| description | A comprehensive, type-safe Rust client for the SumUp API with full async/await support |
| homepage | https://github.com/yourusername/sumup-rs |
| repository | https://github.com/yourusername/sumup-rs |
| max_upload_size | |
| id | 1775763 |
| size | 315,237 |
A comprehensive, type-safe Rust client for the SumUp API. This library provides a complete interface to all SumUp API endpoints with full async/await support.
✅ Production Ready: This library is fully implemented and production-ready for core payment operations. All critical APIs are working with comprehensive error handling and type safety.
For detailed implementation status, see IMPLEMENTATION_STATUS.md.
Add this to your Cargo.toml:
[dependencies]
sumup-rs = "0.2.0"
use sumup_rs::{SumUpClient, CreateCheckoutRequest};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Get API key from environment variable
let api_key = std::env::var("SUMUP_API_SECRET_KEY")
.expect("Please set SUMUP_API_SECRET_KEY environment variable");
// Create a client (use sandbox for testing)
let client = SumUpClient::new(api_key, true)?;
// Get your merchant profile to use the correct merchant code
let merchant_profile = client.get_merchant_profile().await?;
// Create a checkout
let checkout_request = CreateCheckoutRequest {
checkout_reference: "order-123".to_string(),
amount: 29.99,
currency: merchant_profile.currency.clone(),
merchant_code: merchant_profile.merchant_code.clone(),
description: Some("Coffee and pastry".to_string()),
return_url: Some("https://your-site.com/return".to_string()),
customer_id: None,
purpose: None,
redirect_url: None,
};
let checkout = client.create_checkout(&checkout_request).await?;
println!("Created checkout: {:?}", checkout.id);
Ok(())
}
This client supports all SumUp API endpoints:
The client uses a custom Error type that provides structured information about API errors:
use sumup_rs::{Error, Result};
// ... inside an async function
match client.create_checkout(&request).await {
Ok(checkout) => println!("Success: {:?}", checkout),
Err(Error::Http(e)) => eprintln!("HTTP error: {}", e),
Err(Error::Json(e)) => eprintln!("JSON error: {}", e),
Err(Error::ApiError { status, body }) => {
eprintln!("API error (Status {}): {}", status, body.message.as_deref().unwrap_or("No details"));
}
Err(e) => eprintln!("An unexpected error occurred: {}", e),
}
cargo run --example basic_usage
The library includes comprehensive examples for testing 3DS (3D Secure) authentication:
# Setup 3DS testing
cargo run --example setup_3ds_testing
# Basic 3DS demo (automated testing)
cargo run --example 3ds_payment_demo
# Comprehensive 3DS demo with webhook monitoring
cargo run --example 3ds_comprehensive_demo
# Manual 3DS testing (recommended for sandbox)
cargo run --example 3ds_manual_test
The examples use specific test cards designed to trigger 3DS authentication:
4000000000003220 - Visa (3DS Authentication Required)4000000000009995 - Visa (3DS with Insufficient Funds)4000000000000002 - Visa (3DS Declined)4000000000009987 - Visa (3DS Lost Card)4000000000009979 - Visa (3DS Stolen Card)return_url in the examplesNote: Sandbox 3DS behavior may be limited. Real 3DS testing requires a production environment.
For sandbox environments, manual testing is often more reliable:
cargo run --example 3ds_manual_testcargo run --example working_checkout_demo
This project uses automated CI/CD to ensure code quality and reliability:
cargo audit# Run all quality checks locally (recommended)
./scripts/check.sh
# Or run individual checks
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-features
cargo audit
This crate is automatically published to Crates.io when:
For detailed publishing information, see DEPLOYMENT.md.
Contributions are welcome! Please feel free to submit a Pull Request.
The CI/CD pipeline will automatically validate your changes.
This project is licensed under the MIT License - see the LICENSE file for details.
This is not an official SumUp product. This library is provided as-is without any warranty.