reevit 0.2.0

Official Rust SDK for the Reevit payments API
Documentation
use reevit::{Client, PaymentIntentRequest, RequestOptions};
use serde_json::json;
use wiremock::matchers::{method, path};
use wiremock::{Mock, MockServer, ResponseTemplate};

#[tokio::test]
async fn server_created_checkout_session_can_be_handed_to_browser_sdks() {
    let server = MockServer::start().await;
    Mock::given(method("POST"))
        .and(path("/v1/checkout/sessions"))
        .respond_with(ResponseTemplate::new(201).set_body_json(json!({
            "id": "cs_123",
            "client_secret": "client_secret_123",
            "session_secret": "session_secret_123",
            "payment_intent": {
                "id": "pay_123",
                "connection_id": "conn_123",
                "provider": "paystack",
                "status": "pending",
                "amount": 5000,
                "currency": "GHS",
                "fee_amount": 100,
                "fee_currency": "GHS",
                "net_amount": 4900
            },
            "expires_at": "2026-07-18T20:00:00Z"
        })))
        .mount(&server)
        .await;

    let client = Client::builder("pfk_test_example.secret", "org_123")
        .base_url(server.uri())
        .build()
        .unwrap();
    let request = PaymentIntentRequest {
        amount: 5000,
        currency: "GHS".into(),
        country: "GH".into(),
        ..PaymentIntentRequest::default()
    };

    let session = client
        .checkout_sessions()
        .create(&request, RequestOptions::default())
        .await
        .unwrap();

    assert_eq!(session.session_secret, "session_secret_123");
    assert_eq!(session.payment_intent.id, "pay_123");
}