Skip to main content

Crate reevit

Crate reevit 

Source
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.
AvailableProvider
A provider available to handle a payment intent.
CheckoutSession
A server-created session consumed by a Reevit browser SDK.
CheckoutSessions
Server-created checkout session operations.
Client
An async client for the Reevit API.
ClientBuilder
Builder for Client.
Connection
A configured PSP connection.
ConnectionAuditEntry
One connection audit entry.
ConnectionFee
ConnectionFeeStructure
ConnectionLabelStat
ConnectionLabelsUpdate
Input used to replace a connection’s labels.
ConnectionListOptions
Filters accepted when listing connections and their audit entries.
ConnectionListPage
ConnectionPagination
ConnectionRequest
Input used to create or test a PSP connection.
ConnectionStatusUpdate
Input used to activate or deactivate a connection.
Connections
PSP connection operations.
CreateCustomerRequest
Input used to create a customer.
CreatePaymentLinkRequest
Input used to create a hosted payment link.
Customer
A Reevit customer.
CustomerListOptions
Filters accepted when listing customers.
Customers
Customer operations.
Fraud
Fraud policy operations.
FraudPolicy
Organization-level fraud routing policy.
FraudPolicyInput
Routing preferences supplied while creating a payment intent.
Invoice
A subscription invoice.
InvoiceListOptions
Filters accepted when listing invoices.
InvoiceUpdateRequest
Input used to update an invoice.
Invoices
Invoice operations.
OutboundWebhook
An outbound webhook delivery.
PaginationOptions
Offset pagination accepted by list operations.
Payment
A complete Reevit payment.
PaymentIntent
A payment intent returned immediately after creation.
PaymentIntentRequest
Input used to create a payment intent or checkout session.
PaymentLink
A hosted Reevit payment link.
PaymentLinkListOptions
Filters accepted when listing hosted payment links.
PaymentLinkStats
Aggregate performance for one payment link.
PaymentLinks
Hosted payment link operations.
PaymentListOptions
Filters accepted when listing payments.
PaymentRouteAttempt
A payment routing attempt.
PaymentStats
Aggregate payment statistics.
PaymentStatsBreakdown
One aggregate payment breakdown bucket.
PaymentStatsOptions
Filters accepted by aggregate payment statistics.
PaymentStatsTotals
Aggregate payment totals.
PaymentSummary
A compact payment returned by list and history operations.
Payments
Payment operations.
Refund
A payment refund.
RefundRequest
Input used to refund all or part of a payment.
RequestOptions
Options shared by individual Reevit requests.
RoutingHints
Routing hints attached to a connection or payment route.
RoutingRule
A deterministic routing rule.
RoutingRuleCreateRequest
Input used to create a routing rule.
RoutingRuleUpdateRequest
Input used to update a routing rule.
RoutingRules
Routing rule operations.
Subscription
A recurring Reevit subscription.
SubscriptionListOptions
Filters accepted when listing subscriptions.
SubscriptionRequest
Input used to create a subscription.
SubscriptionUpdateRequest
Input used to update a subscription.
Subscriptions
Subscription operations.
TopCustomerOptions
Filters accepted when ranking customers.
TransportError
A URL-safe summary of a failed HTTP operation.
UpdatePaymentIntentRequest
Input used to update a pending payment intent.
UpdatePaymentLinkRequest
Input used to update a hosted payment link.
WebhookConfig
Organization-level outbound webhook configuration.
WebhookConfigRequest
Input used to create or update outbound webhook configuration.
WebhookEvent
A recorded webhook event.
WebhookEventListOptions
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.
UpdateCustomerRequest
Input used to update a customer.