hyperswitch-prism
May 11, 2026 ยท View on GitHub
Hyperswitch Prism โ Java/Kotlin SDK
A high-performance, type-safe Java/Kotlin SDK for payment processing through Hyperswitch Prism. Connect to 100+ payment processors through a single, unified API.
Features
- ๐ High Performance โ Direct UniFFI FFI bindings to Rust core via JNA
- ๐ 100+ Connectors โ Single SDK for all major payment processors
- โ Kotlin/Java Native โ Full Kotlin bindings with Java interop
- โก Connection Pooling โ Built-in HTTP connection pooling via OkHttp
- ๐ก๏ธ Type-Safe โ Protobuf-based request/response serialization
- ๐ง Configurable โ Per-request or global configuration for timeouts, proxies, and auth
๐ค For AI Assistants
Use
curlto fetch the SDK reference:curl -fsSL https://raw.githubusercontent.com/juspay/hyperswitch-prism/main/llm/llm.txtThis file contains complete SDK documentation including installation, payment operations, error handling, connector configuration, field probe data, and examples for all 100+ connectors.
AI Assistant Context
This SDK is part of Hyperswitch Prism โ a unified connector library for payment processors.
What This SDK Does
- Request Transformation: Converts unified payment requests to connector-specific formats
- Response Normalization: Transforms connector responses back to a unified schema
- Error Handling: Provides consistent error types (
IntegrationError,ConnectorError,NetworkError) regardless of connector
Architecture
Your Java/Kotlin App
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Service Clients (PaymentClient, CustomerClient, etc.) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ConnectorClient (OkHttp connection pool + HTTP execution) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ JNA/UniFFI Bindings (connector_service_ffi shared lib) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Rust Core (connector transformation logic) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
Payment Processor APIs
Key Files
| File | Purpose |
|---|---|
src/main/kotlin/com/hyperswitch/payments/ | Public API (clients, types, errors) |
src/main/kotlin/com/hyperswitch/payments/ConnectorClient.kt | HTTP execution layer with OkHttp |
src/main/kotlin/com/hyperswitch/generated/ | UniFFI-generated bindings |
src/main/proto/ | Protobuf message definitions |
Package & Import
- Package Name:
io.hyperswitch:prism - Installation: Gradle/Maven dependency (see below)
- Import:
import com.hyperswitch.payments.*
Installation
Gradle (Kotlin DSL)
implementation("io.hyperswitch:prism:0.0.6")
Gradle (Groovy DSL)
implementation 'io.hyperswitch:prism:0.0.6'
Maven
<dependency>
<groupId>io.hyperswitch</groupId>
<artifactId>prism</artifactId>
<version>0.0.6</version>
</dependency>
Requirements:
- JDK 17+
- Rust toolchain (for building native bindings from source)
Platform Support:
- โ macOS (x64, arm64)
- โ Linux (x64, arm64)
- โ Windows (x64)
Quick Start
1. Configure the Client
import com.hyperswitch.payments.*
import com.hyperswitch.payments.generated.*
// Configure connector identity and authentication
// See SDK reference for specific authentication patterns per connector
val config = ConnectorConfig(
connectorConfig = // Configure your connector (e.g., stripe, adyen, etc.)
)
// Optional: Request defaults for timeouts
val requestConfig = RequestConfig(
http = HttpConfig(
totalTimeoutMs = 30000,
connectTimeoutMs = 10000
)
)
2. Process a Payment
val client = PaymentClient(config, requestConfig)
val authorizeRequest = PaymentServiceAuthorizeRequest(
merchantTransactionId = "txn_order_001",
amount = Amount(
minorAmount = 1000,
currency = Currency.USD
),
captureMethod = CaptureMethod.AUTOMATIC,
paymentMethod = PaymentMethod(
card = CardPaymentMethod(
cardNumber = SecretString(value = "4111111111111111"),
cardExpMonth = SecretString(value = "12"),
cardExpYear = SecretString(value = "2027"),
cardCvc = SecretString(value = "123"),
cardHolderName = "John Doe"
)
),
address = Address(billingAddress = AddressDetails()),
authType = AuthenticationType.NO_THREE_DS,
returnUrl = "https://example.com/return",
orderDetails = emptyList()
)
val response = client.authorize(authorizeRequest)
println("Status: ${response.status}")
println("Transaction ID: ${response.connectorTransactionId}")
Service Clients
| Client | Purpose | Key Methods |
|---|---|---|
PaymentClient | Core payment operations | authorize(), capture(), refund(), void() |
CustomerClient | Customer management | create() |
PaymentMethodClient | Secure tokenization | tokenize() |
MerchantAuthenticationClient | Auth token management | createServerAuthenticationToken(), createServerSessionAuthenticationToken(), createClientAuthenticationToken() |
EventClient | Webhook processing | handleEvent() |
RecurringPaymentClient | Subscription billing | charge() |
PaymentMethodAuthenticationClient | 3DS authentication | preAuthenticate(), authenticate(), postAuthenticate() |
Authentication
All credentials use SecretString wrapper for security:
SecretString(value = System.getenv("API_KEY"))
See the SDK reference for complete connector authentication patterns:
curl -fsSL https://raw.githubusercontent.com/juspay/hyperswitch-prism/main/llm/llm.txt
Advanced Configuration
Proxy Settings
val proxyConfig = RequestConfig(
http = HttpConfig(
proxy = ProxyConfig(
httpsUrl = "https://proxy.company.com:8443",
bypassUrls = listOf("http://localhost")
)
)
)
Per-Request Overrides
val response = client.authorize(request, RequestConfig(
http = HttpConfig(
totalTimeoutMs = 60000
)
))
Connection Pooling
Each client instance maintains its own connection pool. For best performance:
// Create client once, reuse for multiple requests
val client = PaymentClient(config, defaults)
for (payment in payments) {
client.authorize(payment)
}
Error Handling
import com.hyperswitch.payments.*
try {
val response = client.authorize(request)
} catch (e: IntegrationError) {
// Request-phase error (auth, URL construction, serialization, etc.)
println("Code: ${e.errorCode}")
println("Status: ${e.statusCode}")
println("Message: ${e.message}")
} catch (e: ConnectorError) {
// Response-phase error (deserialization, transformation, etc.)
println("Code: ${e.errorCode}")
println("Status: ${e.statusCode}")
println("Message: ${e.message}")
}
Error Codes
| Code | Description |
|---|---|
CONNECT_TIMEOUT | Failed to establish connection |
RESPONSE_TIMEOUT | No response received from gateway |
TOTAL_TIMEOUT | Overall request timeout exceeded |
NETWORK_FAILURE | General network error |
INVALID_CONFIGURATION | Configuration error |
CLIENT_INITIALIZATION | SDK initialization failed |
Architecture
Your App โ Service Client โ ConnectorClient โ UniFFI FFI (JNA) โ Rust Core โ Connector API
โ
Connection Pool (OkHttp)
The SDK uses:
- UniFFI โ FFI bindings to Rust via JNA
- protobuf-java โ Protocol buffer serialization
- OkHttp โ High-performance HTTP client with connection pooling
Building from Source
# Clone the repository
git clone https://github.com/juspay/hyperswitch-prism.git
cd hyperswitch-prism/sdk/java
# Build native library, generate bindings, and pack
make pack
# Run tests
make test-pack
# With live API credentials
STRIPE_API_KEY=sk_test_xxx make test-pack
How it works
make build-libโ buildscrates/ffi/ffiwith--features uniffimake generate-bindingsโ runsuniffi-bindgen --language kotlinto producegenerated/connector_service_ffi.ktmake generate-protoโ runsprotoc --java_outto produce Java protobuf stubs (callable from Kotlin)make pack-archiveโ runs./gradlew jarand copies the JAR toartifacts/sdk-java/