com.mavunta:mavunta-java

Official Java client for the Mavunta Pay API.


License
MIT

Documentation

mavunta-java

Official Java client for the Mavunta Pay API. Java 11+ (uses the JDK HTTP client; Gson for JSON).

<dependency>
  <groupId>com.mavunta</groupId>
  <artifactId>mavunta-java</artifactId>
  <version>0.1.0</version>
</dependency>

Quickstart

import com.mavunta.Mavunta;
import java.util.Map;

Mavunta mavunta = new Mavunta(System.getenv("MAVUNTA_SECRET_KEY"));

Map<String, Object> intent = mavunta.createPaymentIntent(Map.of(
    "amount", "2500",
    "currency", "KES",
    "settlement_currency", "USDT",
    "payment_methods", java.util.List.of("mpesa", "card", "mavunta_balance")
));
// redirect the customer to intent.get("checkout_url")

A cwk_test_… key runs in sandbox; a cwk_live_… key is live. Every POST sends an Idempotency-Key automatically, so the built-in 429/5xx retry never double-charges. Errors are MavuntaException (.code, .getMessage(), .requestId).

Methods

mavunta.verifyKey();
mavunta.rates();
mavunta.createQuote(params);
mavunta.createPaymentIntent(params);
mavunta.getPaymentIntent(id);
mavunta.cancelPaymentIntent(id);
mavunta.refundRequest(id, reason);
mavunta.createPaymentLink(params);
mavunta.getPaymentLink(id);

Verify webhooks

import com.mavunta.Webhooks;

Map<String, Object> event = Webhooks.verify(
    rawBody,
    request.getHeader("Mavunta-Signature"),
    request.getHeader("Mavunta-Timestamp"),
    System.getenv("MAVUNTA_WEBHOOK_SECRET")
);
if ("payment_intent.paid".equals(event.get("type"))) {
    // fulfil the order; dedupe on event.get("id")
}

License

MIT