Zoho
Zoho Payments payment provider for Medusa v2 — India-first, with embedded Checkout Widget, hosted checkout, signed webhooks, refunds, and a browser checkout helper.
medusa-payment-zoho
Zoho Payments provider for Medusa v2 — India-first, with embedded checkout, hosted checkout, signed webhooks, and refunds.
connects a Medusa v2 store to Zoho Payments in India (, the default) or the United States (). It creates Zoho payment sessions, opens the Zoho Checkout Widget or Hosted Checkout, verifies payments server-side, accepts signed webhooks, and supports full and partial refunds.
This is an independent community integration. It is not affiliated with, endorsed by, or maintained by Zoho Corporation or Medusa.
Features
- Embedded Zoho Checkout Widget for card, UPI, and other methods enabled on your Zoho account.
- Zoho Hosted Checkout for strict-CSP, no-JS, or redirect-based storefronts.
- Signed webhooks over the exact raw body, with account and live/test-mode checks.
- Correct money handling — ISO-4217 fraction digits, decimal major-unit strings, arithmetic, no binary floating point.
- Full and partial refunds against captured payments, with a local replay guard.
- Automatic capture, stated honestly — successful Zoho payments are already captured; verifies instead of pretending to capture.
- Safe authorization polling for widget results that arrive before Zoho's session status is final.
- Framework-agnostic browser helper with a typed, discriminated result and no Node.js or Medusa imports in the client bundle.
- Typed errors for configuration, authentication, API, validation, state, and webhook-verification failures.
- 100% test coverage enforced for lines, branches, functions, and statements.
Requirements
| Requirement | Details |
|---|---|
| Medusa | ; developed and verified against 2.22.0 |
| Node.js | (this package); Node is the effective floor when running Medusa 2.22 |
| Zoho Payments | An active India or US merchant account |
| Zoho OAuth | An ORG client with the scopes below, created in the same data centre as the account |
| Zoho widget (widget mode) | A publishable API key from Zoho Settings → Developer Space |
| Webhooks | A publicly reachable HTTPS URL for your Medusa backend |
| Database / Redis | Whatever your Medusa deployment already uses; this package adds no storage or cache dependency |
Required Zoho OAuth scopes:
Webhook-management scopes are not required: Zoho webhooks are registered manually in the dashboard.
Installation
Install the package in your Medusa application:
npm i medusa-payment-zohoRelease status: is published on npm. Install the latest release with the command above. The repository also contains the full test suite, source, and release verification so you can audit the exact tarball you install.
Using pnpm or yarn works too; the package ships ESM and CommonJS builds with TypeScript declarations.
Zoho setup
-
Create or confirm your Zoho Payments account in the correct data centre: India () or US (). The account, OAuth client, and configured region must all match.
-
Create an OAuth client in the Zoho API console:
- client type: ORG;
- redirect URI: for example (match the value used by the helper script);
- scopes: the four scopes listed above.
-
Generate a refresh token with the repository helper: . Configure the account ID, client ID, client secret, region, and redirect URI first, then run:
The helper performs the one-time authorization-code exchange and prints a long-lived refresh token. It uses Node.js built-ins only and reads credentials from the environment. Treat the output as a secret: do not paste it into issues, logs, or commits.
-
Collect the credentials from Zoho:
- Account ID — Payments account identifier, sent on every API call.
- API key — Developer Space browser key, required only for widget mode. This key is publishable by design; it is not the OAuth client secret or signing key.
- Signing key — Developer Space signing key used for webhooks and checkout signatures. Server-only.
-
Store every secret in environment variables on the Medusa server. See for the variable names.
Only a Zoho Account Owner or Admin can generate an org-level refresh token. A user can hold at most 20 refresh tokens; generating more removes the oldest.
Backend configuration
Register the provider under the Payment Module in . The default region is India and the default checkout mode is the embedded widget:
The provider identifier is and the configured id is , so Medusa stores the provider as . Keep that ID stable: it appears in payment sessions, the Admin, and the webhook URL. Use the subpath exactly; the package root is not a module-provider default.
For hosted checkout, set and provide both URLs:
All options, validation rules, and defaults are documented in Configuration.
Webhooks
Register this URL in Zoho Payments under Settings → Developer Space → Webhooks:
https://<your-medusa-backend>/hooks/payment/zoho_zohoEnable at least:
The provider verifies over the exact raw body and parses the event from those same verified bytes. It requires , checks when configured, and validates the payment amount/currency. A missing fails closed.
is emitted per failed attempt. The provider reconciles it against the Zoho session when Zoho supplies a session ID, so a later successful attempt in the same session still completes the order. Medusa 2.22's stock webhook subscriber ignores , , and actions; a terminal failure remains available for reconciliation rather than silently becoming paid. Refund events are acknowledged but map to ; reconcile refunds with or your own job.
Medusa's payment webhook route returns HTTP 200 before the provider finishes handling the event. A rejected signature therefore does not trigger a Zoho retry: monitor and reconcile. See Webhooks for the full setup, retry behaviour, and a signed test.
Enable the provider in Medusa Admin
- Start the Medusa backend after adding the module.
- Open Settings → Regions and edit the region that uses the matching currency.
- Under Payment Providers, enable Zoho ().
- Save the region and refresh the storefront.
If Zoho does not appear, confirm the module resolves, the backend restarted without configuration errors, and the region is saved. See Troubleshooting.
Storefront quickstart: embedded widget
The checkout flow is:
- Create or refresh the Medusa payment session for Zoho.
- Re-read the cart and pass the session's public to .
- Let the customer pay in the Zoho widget.
- Call . Medusa asks the provider to verify the payment with Zoho; client-reported success is never trusted.
The widget result is a hint; is the authoritative step. If Zoho is still processing an asynchronous method, the order may be created with the payment pending until a signed webhook or status poll confirms capture.
The provider stores only publishable checkout data in the Medusa payment session: , , , , , , , , , and (widget mode) or (hosted mode). OAuth secrets and the signing key are never included.
Full guide, session-expiry handling, CSP, and server-side widget signature verification: Storefront widget.
Storefront quickstart: hosted checkout
Set and configure and . Then redirect the browser:
On the return URL, verify Zoho's hosted-checkout signature on your server, then call . A redirect is not proof of settlement: ACH can return , and the webhook is the backstop if the customer closes the browser. Success/failure route examples: Storefront hosted checkout.
Configuration options
| Option | Default | Required | Description |
|---|---|---|---|
| — | Yes | Zoho Payments account ID. | |
| — | Yes | OAuth ORG client ID. | |
| — | Yes | OAuth client secret. Server-only. | |
| — | Yes | Long-lived offline refresh token. Server-only. | |
| No | (India) or . Account and OAuth client must match. | ||
| No | or (India only). | ||
| No | or . | ||
| — | Widget mode | Publishable Zoho widget API key. Safe to expose to the browser. | |
| — | Strongly recommended | Developer Space signing key for webhooks, widget, and hosted-return signatures. | |
| — | Hosted mode | Hosted checkout success URL. HTTPS in production. | |
| — | Hosted mode | Hosted checkout failure URL. HTTPS in production. | |
| No | When set, reject webhooks whose differs. | ||
| No | Customer-facing description, max 500 characters. | ||
| No | Displayed in the embedded widget header when set. | ||
| No | Pass-through allow-list, for example . | ||
| No | Display-symbol overrides keyed by uppercase ISO code, e.g. . | ||
| No | Up to 3 extra non-sensitive Zoho metadata entries. | ||
| No | Per-request HTTP timeout, 1–120000 ms. | ||
| No | Retries for safe calls and OAuth, 0–10. | ||
| No | Exponential-backoff base, 0–60000 ms. | ||
| No | Authorization status polling attempts, 0–10. | ||
| No | Delay between authorization polls, 0–10000 ms. | ||
| No | Timestamp tolerance; disables the check. A positive value must cover Zoho's retry window. | ||
| Region default | No | Advanced override of the Zoho Payments API base URL. | |
| Region default | No | Advanced override of the OAuth accounts base URL. | |
| Region default | No | Advanced override of the hosted-checkout base URL. | |
| Global | No | Custom fetch implementation for proxies or instrumentation. | |
| Medusa logger | No | Structured logger with , , and . |
Environment variable names used in the examples:
These variables are read by your , not automatically by the provider. See Configuration for the full reference.
What is supported
| Capability | Supported | Notes |
|---|---|---|
| Embedded Zoho Checkout Widget | Yes | Default mode; requires . |
| Zoho Hosted Checkout | Yes | Opt-in; requires and . |
| Payment session create/update | Yes | Reuses a session only when amount, currency, mode, and expiry match. |
| Authorization and capture | Yes | Zoho auto-captures; the provider verifies the captured payment. |
| Full and partial refunds | Yes | Against a captured payment; asynchronous Zoho status. |
| Signed webhooks | Yes | , , . |
| India and US data centres | Yes | One provider instance per Zoho account. |
| Zoho Sandbox | Yes | India-only; separate sandbox credentials and . |
| Multi-currency | Yes | Subject to your Zoho account's supported currencies. |
| Saved payment methods | No | Account-holder and saved-method APIs are not implemented in v1. |
| Manual or partial capture | No | Zoho does not offer it. |
| Cancel a pending payment | No | No Zoho API; the session expires (15 minutes by default). |
| Cancel a captured payment | No | Refund instead. |
| Refund webhook → Medusa | No | Acknowledged as ; reconcile with . |
| Payment links, payouts | No | Outside this provider's scope. |
| Automatic webhook creation | No | Register webhooks manually in Zoho. |
| Automatic reconciliation | No | Use the exported in your own job. |
| Multi-account routing | No | One provider instance maps to one Zoho account. |
| Built-in storefront UI | No | Use the documented helpers or hosted checkout. |
A successful Zoho payment is already captured. There is no separate capture step, no partial capture, and no cancel API. re-reads the payment and confirms the capture; it never creates a second charge. Refund settlement can be asynchronous; the provider records Zoho's refund status and logs pending/initiated refunds for reconciliation.
Security
- Secrets stay server-side. , , , and access tokens are never placed in payment-session , logs, errors, or browser bundles. The widget is publishable by design.
- Webhooks fail closed. The signature is verified over the exact raw body before any field is trusted. There is no development mode that skips verification.
- Account and mode are checked. A valid signature from another Zoho account or from test mode does not complete a live payment.
- Payment ownership is verified. Storefront-supplied session data cannot inject a prior payment or Zoho session ID; authorization checks the Zoho payment's reference and metadata against the current Medusa payment session.
- Amount and currency are reconciled. Zoho amounts are compared with the Medusa session before an order is treated as captured, and positive amounts that round below the currency's precision are rejected.
- The storefront never decides success. It may display a hint, but Medusa asks the provider to retrieve the Zoho session/payment before creating a payment.
- Hosted checkout URLs are capabilities. They contain Zoho's ; do not log them, send them to analytics, or expose them in referrer URLs.
- No card data touches your server. Using Zoho's widget or hosted page keeps card entry on Zoho's infrastructure. This reduces, but does not eliminate, PCI DSS scope; confirm your obligations with your acquirer and a qualified assessor.
Report vulnerabilities privately via the process in SECURITY.md.
Testing
enforces 100% lines, branches, functions, and statements. The suite covers amount formatting, status mapping, all three signature schemes, OAuth caching and retries, HTTP retry policy, both checkout modes, webhook authorization, failed-attempt reconciliation, refunds, and browser-helper behaviour.
Documentation
- Configuration
- Storefront: embedded widget
- Storefront: hosted checkout
- Webhooks
- Signature verification
- Troubleshooting
- Architecture
- Compatibility and limitations
- Contributing
- Security policy
License
MIT © Jayashakthi Vishnu.
Zoho, Zoho Payments, and related marks are trademarks of Zoho Corporation. Medusa is a trademark of Medusa, Inc. This project is an independent community integration and is not affiliated with either company.

