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.

Maven Central License: MIT


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 curl to fetch the SDK reference:

curl -fsSL https://raw.githubusercontent.com/juspay/hyperswitch-prism/main/llm/llm.txt

This 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

  1. Request Transformation: Converts unified payment requests to connector-specific formats
  2. Response Normalization: Transforms connector responses back to a unified schema
  3. 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

FilePurpose
src/main/kotlin/com/hyperswitch/payments/Public API (clients, types, errors)
src/main/kotlin/com/hyperswitch/payments/ConnectorClient.ktHTTP 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

ClientPurposeKey Methods
PaymentClientCore payment operationsauthorize(), capture(), refund(), void()
CustomerClientCustomer managementcreate()
PaymentMethodClientSecure tokenizationtokenize()
MerchantAuthenticationClientAuth token managementcreateServerAuthenticationToken(), createServerSessionAuthenticationToken(), createClientAuthenticationToken()
EventClientWebhook processinghandleEvent()
RecurringPaymentClientSubscription billingcharge()
PaymentMethodAuthenticationClient3DS authenticationpreAuthenticate(), 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

CodeDescription
CONNECT_TIMEOUTFailed to establish connection
RESPONSE_TIMEOUTNo response received from gateway
TOTAL_TIMEOUTOverall request timeout exceeded
NETWORK_FAILUREGeneral network error
INVALID_CONFIGURATIONConfiguration error
CLIENT_INITIALIZATIONSDK 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

  1. make build-lib โ€” builds crates/ffi/ffi with --features uniffi
  2. make generate-bindings โ€” runs uniffi-bindgen --language kotlin to produce generated/connector_service_ffi.kt
  3. make generate-proto โ€” runs protoc --java_out to produce Java protobuf stubs (callable from Kotlin)
  4. make pack-archive โ€” runs ./gradlew jar and copies the JAR to artifacts/sdk-java/