Skip to content
Docs
FR Create an account

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

  1. Creation (POST /api/v1/payments): the payment exists, pending, with a token and a payment_url.
  2. Opening: your page opens the sheet with the token. The customer can close and reopen it: the same token resumes the same payment.
  3. Payment: with Mobile Money, a request reaches their phone and they approve it; with crypto, they send from their wallet.
  4. Outcome: completed (paid) or failed (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

POST/api/v1/paymentscreates a payment and returns its token
FieldTypeDescription
amountintegerrequired. Your price in CFA francs, from 100 to 100,000,000.
descriptionstringwhat the customer pays for, shown in the sheet and on the receipt (255 characters). Default: “Paiement”.
callback_urlURLyour webhook for THIS payment. Default: the app’s one.
return_urlURLwhere to send the customer after paying on the full page (payment_url).
cancel_urlURLwhere to send them if they give up on the payment page.
fees_on_customerbooleanwho pays the fees for THIS payment: true the customer, false you. Default: the app setting.
envstringtest or live. Default: test.
Good to know
An optional field that is empty, only spaces, or still a placeholder (<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"]
Response
{
  "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>
OptionDescription
tokenrequired. 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).
apparenceoptional: your colours and the logo, see below.
FunctionRole
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.

KeyValueWhat changes
couleur#RRGGBBbuttons and menus (Tchin black by default).
accent#RRGGBBamounts, badges and indicators (Tchin orange by default).
panneau#RRGGBBthe card showing what the customer pays for (default: couleur).
logoorange · noir · accent · aucunthe Tchin logo at the bottom of the sheet: orange (default), black, your accent colour, or hidden.
Tip
Already integrated? Nothing changes: without 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.

Warning
A return URL can be copied: never deliver just because the customer landed on your return_url. Read the status from your server, or wait for the webhook.

Check the status

GET/api/v1/payments/{token}/statusa payment’s status, read at the source
curl 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  # livrez
e, err := c.EtatPaiement("jtkkbphr7azsn3")
Response
{
  "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"
}
StatusMeaningWhat to do
pendingnot paid yet, or request in progress on the customer’s phonewait; reopen the sheet if the customer comes back
completedpaiddeliver, once
faileddeclined (wrong PIN, insufficient funds, request expired)offer to retry
cancelledcancelledcreate 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 feesYou pay fees
Price created (amount)25 000 F25 000 F
Customer pays26 042 F25 000 F
Tchin fee1 042 F1 000 F
You receive25 000 F24 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

ResponseCauseFix
401 “Missing API keys”a missing header (often an empty environment variable)check both headers
422 on amountamount missing, decimal, text or out of rangesend an integer in CFA francs
404 “Payment not found”token from another app, or mistypeduse the keys of the app that created it
“Test mode” in liveenv missing: the default is testadd "env": "live"
No webhookno URL, or an HTTP, local or unreachable URLuse a public HTTPS URL