Accept payments
Payments
A one-off payment: your server creates it, your page opens the Tchin sheet, the customer pays without leaving your site, and your server is notified by a signed webhook.
Payment lifecycle
- Creation (
POST /api/v1/payments): the payment exists,pending, with atokenand apayment_url. - Opening: your page opens the sheet with the token. The customer can close and reopen it: the same token resumes the same payment.
- Payment: with Mobile Money, a request reaches their phone and they approve it; with crypto, they send from their wallet.
- Outcome:
completed(paid) orfailed(declined; they can retry with the same token). Every change sends a webhook.
Once paid, a token is done: for a new purchase, create a new payment.
Create a payment
/api/v1/paymentscreates a payment and returns its token| Field | Type | Description |
|---|---|---|
amount | integer | required. Your price in CFA francs, from 100 to 100,000,000. |
description | string | what the customer pays for, shown in the sheet and on the receipt (255 characters). Default: “Paiement”. |
callback_url | URL | your webhook for THIS payment. Default: the app’s one. |
return_url | URL | where to send the customer after paying on the full page (payment_url). |
cancel_url | URL | where to send them if they give up on the payment page. |
fees_on_customer | boolean | who pays the fees for THIS payment: true the customer, false you. Default: the app setting. |
env | string | test or live. Default: test. |
<return_url>, as some no-code tools send) is ignored, and so is an invalid URL: creation does not fail because of it.curl -X POST https://tchin.tech/api/v1/payments \
-H "TCHIN-PUBLIC-KEY: $TCHIN_PUBLIC_KEY" -H "TCHIN-PRIVATE-KEY: $TCHIN_PRIVATE_KEY" \
-H "Content-Type: application/json" -H "Accept: application/json" \
-d '{"amount": 25000, "description": "Wintg Cloud - pack Pro",
"callback_url": "https://wintg.group/webhook-tchin", "env": "live"}'$p = $tchin->creerPaiement(25000, 'Wintg Cloud - pack Pro', 'https://wintg.group/webhook-tchin', ['env' => 'live']);
$token = $p['token'];const p = await tchin.creerPaiement(25000, 'Wintg Cloud - pack Pro', 'https://wintg.group/webhook-tchin', { env: 'live' });
const token = p.token;p = tchin.creer_paiement(25000, 'Wintg Cloud - pack Pro', 'https://wintg.group/webhook-tchin', env='live')
token = p['token']p, err := c.CreerPaiement(25000, "Wintg Cloud - pack Pro", "https://wintg.group/webhook-tchin", map[string]any{"env": "live"})
token := p["token"]{
"success": true,
"token": "jtkkbphr7azsn3",
"payment_url": "https://tchin.tech/pay/jtkkbphr7azsn3",
"env": "live"
}Open the sheet
<script src="https://tchin.tech/js/tchin-pay.js"></script>
<script>
TchinPay.open({
token: 'jtkkbphr7azsn3', // rendu par votre serveur (la payment_url marche aussi)
onSuccess: function (r) { /* r.token, r.status = 'success' */ },
onPending: function (r) { /* la demande est partie sur le téléphone du client */ },
onFailed: function (r) { /* refusé : le client peut réessayer dans la feuille */ },
onClose: function (r) { /* r.reason : closed | success | replaced */ },
apparence: { couleur: '#0B6E4F', accent: '#F2B950', logo: 'accent' } // facultatif
});
</script>| Option | Description |
|---|---|
token | required. The token returned by POST /payments (the full payment_url also works). |
onSuccess(r) | the customer paid. The sheet shows “Payment successful”, then closes. |
onPending(r) | the payment is waiting for the customer to act outside the sheet (approve on their phone). |
onFailed(r) | declined. The sheet stays open: the customer can retry or switch method. |
onClose(r) | the sheet closed: closed (by the customer), success (after a successful payment), replaced (another sheet was opened). |
apparence | optional: your colours and the logo, see below. |
| Function | Role |
|---|---|
TchinPay.open(options) | opens the payment sheet (alias TchinPay.ouvrir). |
TchinPay.receive(options) | opens the “Receive” sheet (alias TchinPay.recevoir): see Receive. |
TchinPay.close() | closes the open sheet (alias TchinPay.fermer). |
- The sheet slides up from the bottom, sized to its content, never taller than the screen.
- It is served by Tchin in an isolated frame: your page never sees the customer’s number or PIN. The customer sees your app’s name and image.
- One sheet at a time: opening another closes the first (
replaced). - A confirmed payment is final: Tchin does not refund, and the sheet tells the customer.
Match your brand
Pass apparence to TchinPay.open (and TchinPay.receive): the sheet takes your colours. Text on top is picked automatically, light or dark, to stay readable.
| Key | Value | What changes |
|---|---|---|
couleur | #RRGGBB | buttons and menus (Tchin black by default). |
accent | #RRGGBB | amounts, badges and indicators (Tchin orange by default). |
panneau | #RRGGBB | the card showing what the customer pays for (default: couleur). |
logo | orange · noir · accent · aucun | the Tchin logo at the bottom of the sheet: orange (default), black, your accent colour, or hidden. |
apparence, the sheet keeps Tchin’s colours. A value that is not a #RRGGBB colour is ignored. On the payment page, add the same settings to the URL: payment_url?couleur=0B6E4F&accent=F2B950&logo=noir.In a mobile app
TchinPay.open(this, token, object : TchinPay.Ecouteur {
override fun onSuccess(token: String) { /* demandez la confirmation à votre serveur */ }
override fun onClose(token: String, raison: String) {}
})TchinPay.open(depuis: self, token: token,
onSuccess: { token in /* demandez la confirmation à votre serveur */ },
onClose: { token, raison in })final r = await TchinPay.open(context, token); // 'success' | 'closed'// React Native
<TchinPay token={token} onSuccess={() => {}} onClose={() => setToken(null)} />
// Cordova, Capacitor, Ionic
TchinCordova.payer({ token: token, onSuccess: function () {}, onClose: function () {} });The mobile kits open the same sheet in a web view; crypto wallets and payment apps open in the system. See Downloadable kits.
Without JavaScript: the payment page
For a link in an email, SMS or WhatsApp message, share the payment_url. After paying, the page sends the customer back to your return_url with ?status=success&token=… (without a return_url: the page they came from). If they give up, they go to cancel_url.
return_url. Read the status from your server, or wait for the webhook.Check the status
/api/v1/payments/{token}/statusa payment’s status, read at the sourcecurl https://tchin.tech/api/v1/payments/jtkkbphr7azsn3/status \
-H "TCHIN-PUBLIC-KEY: $TCHIN_PUBLIC_KEY" -H "TCHIN-PRIVATE-KEY: $TCHIN_PRIVATE_KEY" -H "Accept: application/json"$e = $tchin->etatPaiement('jtkkbphr7azsn3');
if ($e['status'] === 'completed') { /* livrez */ }const e = await tchin.etatPaiement('jtkkbphr7azsn3');
if (e.status === 'completed') { /* livrez */ }e = tchin.etat_paiement('jtkkbphr7azsn3')
if e['status'] == 'completed':
pass # livreze, err := c.EtatPaiement("jtkkbphr7azsn3"){
"success": true,
"token": "jtkkbphr7azsn3",
"status": "completed",
"amount": 25000,
"currency": "XOF",
"env": "live",
"customer": { "name": "Koffi", "email": "koffi@example.com", "phone": "+22890112233" },
"method": "t-money-togo"
}| Status | Meaning | What to do |
|---|---|---|
pending | not paid yet, or request in progress on the customer’s phone | wait; reopen the sheet if the customer comes back |
completed | paid | deliver, once |
failed | declined (wrong PIN, insufficient funds, request expired) | offer to retry |
cancelled | cancelled | create a new payment if needed |
amount is your price as created; currency is always XOF, even when paid in crypto; method appears once there is a payment; crypto appears for a crypto payment (the coin, the quantity and the transfer status).
Fees and amount received
Fees depend on the method the customer picks and on who pays them. Example with a 4% rate:
| Customer pays fees | You pay fees | |
|---|---|---|
Price created (amount) | 25 000 F | 25 000 F |
| Customer pays | 26 042 F | 25 000 F |
| Tchin fee | 1 042 F | 1 000 F |
| You receive | 25 000 F | 24 000 F |
Customer pays: paid = price ÷ (1 − rate), rounded up to the next franc. You pay: received = price − price × rate. The webhook gives all three numbers: amount (paid), fee and net (received). Your account’s rates: GET /methods.
The money lands on your balance for the country where the customer paid (Mobile Money), or on your crypto balance, in your account’s crypto. You then withdraw it from your dashboard, or through the API.
Common errors
| Response | Cause | Fix |
|---|---|---|
| 401 “Missing API keys” | a missing header (often an empty environment variable) | check both headers |
422 on amount | amount missing, decimal, text or out of range | send an integer in CFA francs |
| 404 “Payment not found” | token from another app, or mistyped | use the keys of the app that created it |
| “Test mode” in live | env missing: the default is test | add "env": "live" |
| No webhook | no URL, or an HTTP, local or unreachable URL | use a public HTTPS URL |