User guide
Configure the Tpay integration for the account that will receive payments. Check the connection before sending customers through the payment flow.
This guide explains how to connect Tpay to Open Mercato and accept PLN payments through Tpay's hosted payment page. The payer is redirected to Tpay, chooses a payment method there (online transfer, BLIK, and other methods enabled on your Tpay account), and returns to your checkout page.
gateway_tpay module enabled in your application's modules.ts.integrations.credentials.manage and payment_gateways.manage features enabled for your role.Sandbox for sandbox credentials, Production for live credentials. Open Mercato uses Tpay's fixed sandbox or production API address for the selected environment.OM_INTEGRATION_TPAY_CLIENT_ID=...
OM_INTEGRATION_TPAY_CLIENT_SECRET=...
OM_INTEGRATION_TPAY_ENVIRONMENT=sandbox
OM_INTEGRATION_TPAY_NOTIFICATION_URL=
OM_INTEGRATION_TPAY_NOTIFICATION_SECURITY_CODE=
OM_INTEGRATION_TPAY_ENABLED=true
OM_INTEGRATION_TPAY_FORCE_PRECONFIGURE=false
Client ID and Client Secret are required together. In standalone apps created with create-mercato-app, the module is opt-in: uncomment gateway_tpay in src/modules.ts. New tenants pick the preset up automatically. To apply it to an existing tenant:
yarn mercato gateway_tpay configure-from-env --tenant <tenantId> --org <organizationId> [--force]
Without --force, existing Tpay credentials or integration state are left untouched.
Select Tpay as the payment provider of a checkout link and keep customer details collection enabled: Tpay requires the payer's email address and name, and checkout forwards the values the payer enters. Payments without an email address or name are rejected before anything is sent to Tpay.
The email, first name, and last name customer fields must be marked as required. Until they are, the Payment section of the template or link editor shows a warning and saving is rejected. A link saved before this rule keeps working, but you must fix its customer fields the next time you save it.
After paying, the payer returns to the checkout success page, which reads the transaction status from Tpay. A paid transaction becomes captured.
Tpay confirms each paid transaction with a server-to-server notification. Open Mercato settles the payment from that notification, so a payment is captured even when the payer closes the browser on Tpay's page.
https://<your-domain>/api/payment_gateways/webhook/tpay (or fill Notification URL in the integration, which Tpay uses when overriding is allowed). The address must be public HTTPS on port 443, without redirects.Each notification is checked before anything changes:
tr_crc is the payment id Open Mercato sent to Tpay), its amount, and its currency.| Situation | Response to Tpay | Effect |
|---|---|---|
| Verified and processed | 200 TRUE | Payment captured (or refunded for a chargeback) once, even if Tpay repeats the notification |
| Transaction not found yet, certificate download or validation failed, or processing failed | 503 FALSE | Tpay retries later |
| Invalid checksum or signature, amount/currency mismatch, underpayment | 400 FALSE | Nothing changes; Tpay keeps retrying – check the security code and the integration environment |
An overpayment still captures the expected amount; the paid amount is kept in the transaction details.
When the Tpay integration is enabled for an organization, Open Mercato registers a scheduled job (Tpay payment status reconciliation, every 5 minutes) that asks Tpay for the current status of that organization's Tpay transactions that are still open (pending, authorized, or partially captured). It repairs payments whose notification never arrived, for example because the notification address was misconfigured or Tpay exhausted its retries.
seed:defaults) keeps an existing job as you left it. Enabling or disabling the integration rewrites the job with the default 5-minute interval.Tpay signs every notification with its own certificate, so notifications cannot be simulated locally. To test the whole flow, use a Tpay sandbox account and a public HTTPS address that reaches your local application.
In the Tpay sandbox panel, copy the API Client ID and Secret and the notification security code. Configure the integration with Environment set to Sandbox.
Expose only the notification endpoint, not the whole application. For example, a Cloudflare named tunnel whose ingress allows only the webhook path:
ingress:
- hostname: <your-test-host>
path: ^/api/payment_gateways/webhook/tpay$
service: http://127.0.0.1:<app-port>
- service: http_status:404
Set Notification URL to https://<your-test-host>/api/payment_gateways/webhook/tpay.
Create a published PLN checkout link with Tpay and pay on the sandbox page. To test notifications, close the Tpay tab after paying instead of returning to the checkout page: the success page reads the status from Tpay and would capture the payment before the notification arrives.
To test the scheduled status check, make the endpoint unreachable (for example, stop the tunnel) before paying. The payment stays pending until the next run of Tpay payment status reconciliation captures it. The scheduler must be running.
Tpay e-mails the merchant when the endpoint does not answer TRUE. These e-mails are expected while you test a missing notification. The sandbox payment page may block automated (headless) browsers, so complete test payments in a regular browser. Remove the tunnel and its DNS record when you finish.
Previous: Teams and team members · Next: Extend users with custom fields