Expand description
§Reevit Rust SDK
The official async Rust client for the Reevit payments API.
§Installation
[dependencies]
reevit = "0.1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }§Quick start
Amounts use the smallest currency unit. For example, 5000 means GHS 50.00.
use reevit::{Client, PaymentIntentRequest, RequestOptions};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::builder("pfk_test_xxx.secret", "org_123").build()?;
let payment = client
.payments()
.create_intent(
&PaymentIntentRequest {
amount: 5_000,
currency: "GHS".into(),
method: Some("mobile_money".into()),
country: "GH".into(),
reference: Some("ORD-12345".into()),
..PaymentIntentRequest::default()
},
RequestOptions::default().idempotency_key("ORD-12345"),
)
.await?;
println!("created payment {}", payment.id);
Ok(())
}The client sends X-Reevit-Key and X-Org-Id on every request, defaults to
https://api.reevit.io, and uses a 30-second timeout. Override the URL or timeout
through Client::builder for tests and specialized deployments.
§Server-created checkout sessions
Create a session on your server and pass only its session_secret to a Reevit
React, Vue, or Svelte checkout SDK.
let session = client
.checkout_sessions()
.create(
&PaymentIntentRequest {
amount: 5_000,
currency: "GHS".into(),
country: "GH".into(),
..PaymentIntentRequest::default()
},
RequestOptions::default().idempotency_key("ORD-12345"),
)
.await?;
println!("session secret: {}", session.session_secret);§Webhook verification
Verify the exact bytes received from Reevit. Parsing and re-serializing JSON can change whitespace or key order and invalidate a correct signature.
use reevit::verify_webhook_signature;
let raw_body = br#"{"id":"evt_123","type":"payment.succeeded"}"#;
let signature = "sha256=2f70e6b9d3f5f7dd-placeholder";
if verify_webhook_signature(raw_body, signature, "whsec_xxx") {
// Process the verified event.
}§Resource modules
client.payments()client.checkout_sessions()client.connections()client.subscriptions()client.fraud()client.customers()client.payment_links()client.webhooks()client.routing_rules()client.invoices()
All mutating methods accept RequestOptions. Reuse the same idempotency key when
retrying the same logical mutation. The SDK does not automatically retry payment
mutations.
Connection listing is explicit about pagination: connections().list(...)
returns one page, connections().list_page(...) retains the server’s
pagination metadata, and connections().list_all(...) fetches every matching
PSP connection.
§Errors
reevit::Error::Api preserves the HTTP status, Reevit error code, details, and
request ID. is_recoverable() identifies transport failures and HTTP statuses
that may succeed when retried; callers still decide whether retrying a specific
operation is safe.
§Development
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-features
cargo test --doc
cargo publish --dry-run --locked§License
MIT
Structs§
- ApiError
- An error returned by the Reevit API.
- Available
Provider - A provider available to handle a payment intent.
- Checkout
Session - A server-created session consumed by a Reevit browser SDK.
- Checkout
Sessions - Server-created checkout session operations.
- Client
- An async client for the Reevit API.
- Client
Builder - Builder for
Client. - Connection
- A configured PSP connection.
- Connection
Audit Entry - One connection audit entry.
- Connection
Fee - Connection
FeeStructure - Connection
Label Stat - Connection
Labels Update - Input used to replace a connection’s labels.
- Connection
List Options - Filters accepted when listing connections and their audit entries.
- Connection
List Page - Connection
Pagination - Connection
Request - Input used to create or test a PSP connection.
- Connection
Status Update - Input used to activate or deactivate a connection.
- Connections
- PSP connection operations.
- Create
Customer Request - Input used to create a customer.
- Create
Payment Link Request - Input used to create a hosted payment link.
- Customer
- A Reevit customer.
- Customer
List Options - Filters accepted when listing customers.
- Customers
- Customer operations.
- Fraud
- Fraud policy operations.
- Fraud
Policy - Organization-level fraud routing policy.
- Fraud
Policy Input - Routing preferences supplied while creating a payment intent.
- Invoice
- A subscription invoice.
- Invoice
List Options - Filters accepted when listing invoices.
- Invoice
Update Request - Input used to update an invoice.
- Invoices
- Invoice operations.
- Outbound
Webhook - An outbound webhook delivery.
- Pagination
Options - Offset pagination accepted by list operations.
- Payment
- A complete Reevit payment.
- Payment
Intent - A payment intent returned immediately after creation.
- Payment
Intent Request - Input used to create a payment intent or checkout session.
- Payment
Link - A hosted Reevit payment link.
- Payment
Link List Options - Filters accepted when listing hosted payment links.
- Payment
Link Stats - Aggregate performance for one payment link.
- Payment
Links - Hosted payment link operations.
- Payment
List Options - Filters accepted when listing payments.
- Payment
Route Attempt - A payment routing attempt.
- Payment
Stats - Aggregate payment statistics.
- Payment
Stats Breakdown - One aggregate payment breakdown bucket.
- Payment
Stats Options - Filters accepted by aggregate payment statistics.
- Payment
Stats Totals - Aggregate payment totals.
- Payment
Summary - A compact payment returned by list and history operations.
- Payments
- Payment operations.
- Refund
- A payment refund.
- Refund
Request - Input used to refund all or part of a payment.
- Request
Options - Options shared by individual Reevit requests.
- Routing
Hints - Routing hints attached to a connection or payment route.
- Routing
Rule - A deterministic routing rule.
- Routing
Rule Create Request - Input used to create a routing rule.
- Routing
Rule Update Request - Input used to update a routing rule.
- Routing
Rules - Routing rule operations.
- Subscription
- A recurring Reevit subscription.
- Subscription
List Options - Filters accepted when listing subscriptions.
- Subscription
Request - Input used to create a subscription.
- Subscription
Update Request - Input used to update a subscription.
- Subscriptions
- Subscription operations.
- TopCustomer
Options - Filters accepted when ranking customers.
- Transport
Error - A URL-safe summary of a failed HTTP operation.
- Update
Payment Intent Request - Input used to update a pending payment intent.
- Update
Payment Link Request - Input used to update a hosted payment link.
- Webhook
Config - Organization-level outbound webhook configuration.
- Webhook
Config Request - Input used to create or update outbound webhook configuration.
- Webhook
Event - A recorded webhook event.
- Webhook
Event List Options - Filters accepted when listing webhook events.
- Webhooks
- Webhook configuration, event, and delivery operations.
Enums§
- Error
- Errors produced while configuring or calling Reevit.
Functions§
- verify_
webhook_ signature - Verifies a Reevit webhook signature without leaking the expected digest.
Type Aliases§
- Metadata
- Arbitrary structured metadata attached to a Reevit resource.
- Result
- A result returned by the Reevit SDK.
- Update
Customer Request - Input used to update a customer.