Skip to main content

Java SDK

The Zentra Java SDK provides convenient access to the Zentra API from Java applications. The checked-in Java wrapper currently exposes transfers, payments, virtual accounts, logs, and webhook verification. For cards, tenant-enabled identity, or broader compatibility helpers, prefer another checked-in SDK or direct HTTP until the Java wrapper catches up.
<dependency>
    <groupId>io.zentra</groupId>
    <artifactId>zentra-java</artifactId>
    <version>1.0.0</version>
</dependency>

Configuration

Initialize the client with your API key and base URL:
import io.zentra.ZentraClient;
import java.time.Duration;

ZentraClient client = new ZentraClient(
    System.getenv("ZENTRA_SECRET_KEY"),
    "https://api.usezentra.com",
    Duration.ofSeconds(30)
);

Resources

The checked-in Java package currently exposes:
  • client.payments: Reviewed public charges, refunds, and saved payment tokens
  • client.transfers: Bank transfers
  • client.virtualAccounts: Virtual bank accounts
  • client.logs: API request logs
  • client.webhooks: Webhook signature verification

Examples

Create a Transfer

import java.util.Map;

try {
    var transfer = client.transfers.create(Map.of(
        "amount", 500000L,
        "recipient_bank_code", "058",
        "recipient_account_number", "0123456789",
        "recipient_account_name", "Vendor Settlement Account",
        "narration", "Vendor payout",
        "reference", "TRF_12345",
        "currency", "NGN"
    ));
    System.out.println("Queued: " + transfer.getReference());
} catch (ZentraException e) {
    System.err.println("Error: " + e.getMessage());
}

Create Charge

import java.util.Map;

Map<String, Object> charge = client.payments.charge(
    Map.of(
        "amount_minor", 500000L, // ₦5,000.00
        "currency", "NGN",
        "email", "user@example.com",
        "reference", "ORD_12345",
        "capture_mode", "customer_action_required"
    ),
    "idem_charge_123"
);

Map<String, Object> verified = client.payments.verify((String) charge.get("reference"));
System.out.println("Status: " + verified.get("status"));

Verify Webhook Signature

boolean valid = client.webhooks.verifySignature(payload, signature, webhookSecret);
if (!valid) {
    throw new IllegalArgumentException("Invalid webhook signature");
}

Error Handling

The SDK throws typed exceptions for API errors:
import io.zentra.exception.ApiException;
import io.zentra.exception.AuthenticationException;
import io.zentra.exception.ZentraException;

try {
    client.payments.verify("INVALID_REF");
} catch (AuthenticationException e) {
    System.err.println("Check your API key");
} catch (ApiException e) {
    System.err.println("API error: " + e.getMessage());
} catch (ZentraException e) {
    System.err.println("Unexpected SDK error: " + e.getMessage());
}

Source Code

GitHub Repo

View source code

Maven Central

Download package