Server SDKs
Zoho Payments provides official server-side SDKs that enable you to integrate payment processing directly into your backend application. These SDKs offer type-safe, idiomatic interfaces to the Zoho Payments REST API, handling authentication, request construction, error mapping, and serialization so you can focus on building your application.
Select your language below and follow the instructions to install, initialize, and start using the SDK.
Prerequisites:
- Create a Zoho Payments account and complete the verification process. Learn how to get started.
- Generate an OAuth token to authenticate your API calls.
| Language | Minimum Version | Source Code |
|---|---|---|
| Java | Java 17+ | GitHub |
| Python | Python 3.11+ | GitHub |
Get Started
To accept payments using the SDK, you need to install it in your project, initialize a client with your account credentials, and then use the client to create payment sessions and process transactions. Here’s how:
1. Install the SDK
// Gradle (build.gradle)
repositories {
maven {
url "https://static.zohocdn.com/zpayments/"
}
mavenCentral()
}
dependencies {
implementation "com.zohopayments.java:sdk:1.0.0"
}
pip install zoho-payments
Java: The SDK uses the JDK built-in java.net.http.HttpClient for HTTP communication and Gson for JSON serialization/deserialization. If you are not using Gradle or Maven, download the SDK JAR and Gson 2.10.1 and add both to your classpath.
Python: The SDK uses the requests library as its only runtime dependency for HTTP communication and the standard library json module for JSON serialization. Response models are built using @dataclass(frozen=True) for immutability.
The SDK is now installed and ready to use in your project.
2. Initialize the Client
Use the builder pattern to create a client instance. The builder validates the accountId, edition, and oauthToken at build time and raises an error if any are missing or invalid.
ZohoPayments client = ZohoPayments.builder()
.accountId("23137556")
.edition(Edition.IN)
.oauthToken("1000.access_token_here")
.build();
client = (
ZohoPayments.builder()
.account_id("23137556")
.edition(Edition.IN)
.oauth_token("1000.access_token_here")
.build()
)
| Parameter | Required | Description |
|---|---|---|
accountId |
Yes | Your Zoho Payments Account ID. |
edition |
Yes | The edition to use: Edition.US, Edition.IN, or Edition.IN_SANDBOX. |
oauthToken |
Yes | A valid OAuth access token. Refer to the OAuth setup documentation to generate tokens. |
Note: The client is thread-safe. You can create a single instance and share it across your application.
Your client is now initialized and ready to make API calls.
3. Integrate your Application
Once the SDK is installed and the client is initialized, you can use it to make API calls for your payment integration. The integration flow depends on your chosen method:
Checkout Widget Integration
Use the SDK to create a payment session on your server, then pass the payment_session_id to the checkout widget on the client side. Follow the step-by-step guide in the Integrating Checkout Widget documentation.
Hosted Checkout Integration
Use the SDK to create a payment session with hosted checkout parameters, then redirect the customer to the hosted checkout page using the access_key. Follow the step-by-step guide in the Hosted Checkout documentation.
For both methods, refer to the Payment Session Create API for the complete list of request parameters.
After the customer completes the payment, verify the payment status using the Payment Retrieve API, Payment Session Retrieve API, or your configured webhooks.
Your application is now integrated with Zoho Payments and can accept payments from customers.
Manage Tokens
The SDK does not automatically refresh tokens. When your OAuth token expires, refresh it explicitly and update the client.
// Generate a new access token
OAuthToken freshToken = ZohoPayments.generateAccessToken(
refreshToken, clientId, clientSecret, redirectUri, Edition.IN);
// Update the client with the new token
client.updateToken(freshToken);
fresh = ZohoPayments.generate_access_token(
refresh_token="...",
client_id="...",
client_secret="...",
redirect_uri="...",
edition=Edition.IN,
)
client.update_token(fresh.access_token)
Insight: Token refresh is intentionally explicit. The SDK does not silently retry with refresh tokens. This keeps behavior predictable and gives you full control over the authentication flow.
The client is now updated with the new token and can continue making API calls.
Close the Client
When your application no longer needs the SDK client, close it to release resources held by the underlying HTTP transport. This ensures that connections and session state are cleaned up properly.
You should close the client in the following scenarios:
- At application shutdown.
- After completing a short-lived batch job or standalone script.
- Before re-initializing the client with new credentials or configuration.
Explicit Close
ZohoPayments client = ZohoPayments.builder()
.accountId("23137556")
.edition(Edition.IN)
.oauthToken("1000.access_token_here")
.build();
try {
// make API calls using client
} finally {
client.close();
}
client = (
ZohoPayments.builder()
.account_id("23137556")
.edition(Edition.IN)
.oauth_token("1000.access_token_here")
.build()
)
try:
# make API calls using client
...
finally:
client.close()
Auto-Close
// Try-with-resources — close() is called automatically
try (ZohoPayments client = ZohoPayments.builder()
.accountId("23137556")
.edition(Edition.IN)
.oauthToken("1000.access_token_here")
.build()) {
// make API calls using client
}
with (
ZohoPayments.builder()
.account_id("23137556")
.edition(Edition.IN)
.oauth_token("1000.access_token_here")
.build()
) as client:
# make API calls using client
...
# client.close() runs automatically here, including on exceptions
Note: Once closed, the client can no longer be used. Any subsequent API call will result in an error.
The client is now closed and all underlying resources are released.
Supported Operations
Both SDKs support the full range of Zoho Payments API operations. Refer to the API documentation for detailed endpoints.
| Service | Description |
|---|---|
| Payment Session | Create and manage payment sessions. |
| Payments | Accept and manage payments. |
| Refunds | Process and track refunds. |
| Customers | Create and manage customer records. |
| Payment Links | Generate shareable payment links. |
| Mandates | Set up recurring payment mandates. |
| Collect (Virtual Accounts) | Create and manage virtual accounts. |
Note: Some services are edition-specific. Attempting to use a US-only service with an IN edition client (or vice versa) will result in an error. Ensure your client is configured with the correct edition.