Skip to content
Docs
FR Create an account

Integrations

Lovable and Replit

Built your app with Lovable or Replit? Store your keys in its secrets, copy one prompt: the Tchin payment is created server-side, the sheet opens on your page, and the order is paid once Tchin confirms it.

Before you start

  • A Tchin app (tchin.tech/api › New app) and its two keys (View keys).
  • Never paste your keys in the AI chat or in a project file: only in the secrets.

Lovable

  1. Enable Lovable Cloud if needed (Lovable offers it when required).
  2. Cloud › Secrets: add TCHIN_PUBLIC_KEY and TCHIN_PRIVATE_KEY.
  3. Paste this prompt into your project chat:
The Lovable prompt
Add Tchin payments to my app: my customers pay by Mobile Money (Togo, Benin, Burkina Faso) or crypto, in CFA francs.
My Tchin keys are in Cloud › Secrets: TCHIN_PUBLIC_KEY and TCHIN_PRIVATE_KEY. Never put them in browser code, a .env file or a VITE_ variable.
1. Create an Edge function "tchin-paiement": POST https://tchin.tech/api/v1/payments, headers TCHIN-PUBLIC-KEY and TCHIN-PRIVATE-KEY (Deno.env.get), JSON body {"amount": <price in CFA francs, integer, at least 100>, "description": "<what the customer pays for>", "callback_url": "<public URL of the tchin-webhook function>"}. The price comes from my database, never from the browser. Return only the token. Do not add "env": we stay in test until I say to go live ("env": "live").
2. On the payment page, load https://tchin.tech/js/tchin-pay.js, call tchin-paiement, then TchinPay.open({ token, onSuccess, onPending, onFailed, onClose }). onSuccess is for display only.
3. Create a PUBLIC Edge function "tchin-webhook" (verify_jwt = false in supabase/config.toml). It receives a form with data[reference], data[token], data[status], data[amount], data[net], data[mode], data[timestamp], data[signature]. Verify the signature: hex HMAC-SHA256 with TCHIN_PRIVATE_KEY of timestamp.reference.token.status.amount.net.mode (missing field = empty), constant-time compare; reject a timestamp older than 10 minutes. Mark the order paid only if status is "completed", once per reference, and reply 200 right away.
4. If a webhook does not arrive, read the status: GET https://tchin.tech/api/v1/payments/{token}/status, same headers.
Docs: https://doc.tchin.tech/en/demarrer/ and https://doc.tchin.tech/en/webhooks/
Good to know
The webhook function must be public: Tchin calls it without a sign-in token. If payments stay “pending”, check this first.

Replit

  1. Open your app’s Secrets tool and add TCHIN_PUBLIC_KEY and TCHIN_PRIVATE_KEY.
  2. Paste this prompt into the Agent:
The Replit prompt
Add Tchin payments to my app: my customers pay by Mobile Money (Togo, Benin, Burkina Faso) or crypto, in CFA francs.
My Tchin keys are in Replit Secrets: TCHIN_PUBLIC_KEY and TCHIN_PRIVATE_KEY (environment variables). If one is missing, ask me to add it through the Secrets form: I will never type it in the chat. Never put them in browser code.
1. Create a server route POST /api/tchin/paiement: POST https://tchin.tech/api/v1/payments, headers TCHIN-PUBLIC-KEY and TCHIN-PRIVATE-KEY, JSON body {"amount": <price in CFA francs, integer, at least 100>, "description": "<what the customer pays for>", "callback_url": "<public HTTPS URL of /api/tchin/webhook>"}. The price comes from the server. Return only the token. Do not add "env": we stay in test until I say to go live.
2. On the payment page, load https://tchin.tech/js/tchin-pay.js, call /api/tchin/paiement, then TchinPay.open({ token, onSuccess, onPending, onFailed, onClose }). onSuccess is for display only.
3. Create the route POST /api/tchin/webhook (form with data[reference], data[token], data[status], data[amount], data[net], data[mode], data[timestamp], data[signature]). Verify the signature: hex HMAC-SHA256 with TCHIN_PRIVATE_KEY of timestamp.reference.token.status.amount.net.mode, constant-time; reject a timestamp older than 10 minutes. Order paid only on "completed", once per reference; reply 200 right away.
4. If a webhook does not arrive, read the status: GET https://tchin.tech/api/v1/payments/{token}/status.
Docs: https://doc.tchin.tech/en/demarrer/ and https://doc.tchin.tech/en/webhooks/
Good to know
Once deployed, the callback_url must be the deployment URL (…replit.app or your domain), otherwise webhooks go to the development URL.

Test, then go live

  1. Start a payment in the preview: the sheet opens, marked Test mode; tap “Simulate payment”.
  2. The order turns “paid” on its own: that is the webhook.
  3. When everything works, ask the AI: “Switch Tchin payments to live: add "env": "live" when creating the payment.”
What you seeCommon causeWhat to do
The sheet does not openthe script is not loaded, or the create call returned no tokenask the AI to show the create call error
401 responsea key is missing or mistypedcopy both keys again, without spaces
Order stays “pending”webhook not public, or signature built wrongsee the signature