Comgate payment provider for Medusa v2
Comgate payment provider for Medusa v2. Comgate is a Czech payment gateway (cards, Apple Pay / Google Pay, Czech & Slovak bank buttons, Twisto, etc).
Disclaimer: This is an unofficial, community-built integration. It is not affiliated with, endorsed by, or maintained by Comgate Payments, a.s. "Comgate" and the Comgate logo are trademarks of their respective owner, used here only to identify the payment gateway this plugin integrates with.
Comgate API docs | Medusa Payment Module
bun add medusa-payment-comgate-v2
Add the provider to the Payment Module in :
1module.exports = defineConfig({2 // ...3 modules: [4 {5 resolve: "@medusajs/medusa/payment",6 options: {7 providers: [8 {9 resolve: "medusa-payment-comgate-v2/providers/comgate",10 id: "comgate",11 options: {12 merchant: process.env.COMGATE_MERCHANT,13 secret: process.env.COMGATE_SECRET,14 test: process.env.COMGATE_TEST === "true",15 // optional:16 // preauth: false,17 // lang: "cs",18 // country: "CZ",19 // label: "My Store",20 // method: "ALL",21 },22 },23 ],24 },25 },26 ],27})
| Option | Required | Default | Description |
|---|---|---|---|
| yes | — | Comgate e-shop identifier. | |
| yes | — | Password for background communication. | |
| no | Test mode. | ||
| no | Create pre-authorizations; capture later. | ||
| no | Gateway / e-mail language (ISO 639-1). | ||
| no | Payer country (ISO 3166-1). | ||
| no | Statement label, 1–16 chars. | ||
| no | Payment method, or to let the payer choose. | ||
| / / | no | — | Return URLs. See note below — bake your own order id into them. |
| no | API base url (the version prefix is part of each path). |
To run both a direct-capture and a pre-auth provider, register the module twice with different s and :
1providers: [2 { resolve: "medusa-payment-comgate-v2/providers/comgate", id: "comgate", options: { /* preauth: false */ } },3 { resolve: "medusa-payment-comgate-v2/providers/comgate", id: "comgate-preauth", options: { preauth: true } },4]
The provider id used in the storefront / API is (and ).
Uses the Comgate REST v2.0 JSON API (, HTTP Basic auth).
Per Comgate's spec, order fulfillment must be driven by the background notification, not the payer's browser redirect, since redirect params are user-controlled. Comgate retries the PUSH up to 1000× until it gets a 2xx — Medusa's webhook handling is idempotent.
Comgate authenticates the PUSH by echoing the merchant in the body (no HMAC header). Restrict the webhook to Comgate's IP ranges () as a first layer; the secret check is the second.
In the Client Portal → Integrace → Nastavení obchodů → Přidat propojení obchodu:
| Field (CS) | Field (EN) | Value |
|---|---|---|
| Heslo | Password | → your |
| Povolený způsob založení platby | Payment creation method | HTTP POST protokol - backend (recommended) |
| Url pro předání výsledku platby | Background result URL (PUSH) | |
| Url zaplacený | Paid redirect | storefront order-confirmation page |
| Url zrušený | Cancelled redirect | storefront cart / retry page |
| Url nevyřízený | Pending redirect | storefront "payment processing" page |
| Povolené IP adresy / Povolit všechny IP | Allowed IPs | your backend's egress IP, or allow-all |
The PUSH URL is mandatory — without it payments never confirm in Medusa. The three redirect URLs are browser-facing only and non-authoritative (the payer can forge their params); never mark an order paid from them. Order state is driven solely by the PUSH webhook.
The return page must know which order it is. Comgate supports (Comgate transId) and (your reference) placeholders, case-sensitive — but only in the Comgate client-portal return-URL fields, where Comgate substitutes them at redirect time. The API / / request fields are used verbatim (no substitution, no params appended), so if you set the URLs via the API you must bake the identifier in yourself.
Portal (recommended — Comgate substitutes the placeholders):
API options (verbatim — bake in your own id):
is the Medusa payment session id. The return page reads it and looks the order up. The redirect is non-authoritative regardless — the storefront must re-query order/payment status server-side before showing "paid".
Web/Mobile Checkout SDK checkboxes: leave off. This provider uses Comgate's hosted redirect flow, not the embedded checkout SDKs.
In the Comgate portal set the background-notification URL ("Url pro předání výsledku platby") to:
1bun install2bun run build # tsc -> dist3bun run test # jest unit tests (mocked fetch)
Live smoke test against the Comgate v2.0 test API (no Medusa backend needed):
COMGATE_MERCHANT=xxxx COMGATE_SECRET=xxxx bun run smoke
It creates a test payment and prints the URL — open it and pay with a Comgate test card to see the status flip to . Your IP must be allowed on the shop link (portal → Povolené IP adresy / Povolit všechny IP).
This is packaged as a Medusa v2 plugin. To list it for free on the Medusa integrations page, the already includes the required keywords (, , ).
1bun run plugin:build # medusa plugin:build -> .medusa/server2npm publish # public package
Once published with those keywords, the plugin is picked up automatically by the Medusa integrations listing.
MIT
This project is an independent, unofficial integration and is not affiliated with or endorsed by Comgate Payments, a.s. All Comgate trademarks and logos are the property of their respective owner.