Get started
Quickstart
Create your app, get your keys, then take a first payment in test mode, from your server all the way to the webhook. Nothing is charged.
Before you start
- A Tchin account with a verified identity (Profile, from your phone: your ID and a selfie). It unlocks app creation; verification usually takes a few minutes.
- A server that can make an HTTPS call (PHP, Node.js, Python, Java, Go… or plain
curl). Your keys live there. - For webhooks, a public HTTPS URL on that server. On your own computer, a tunnel (ngrok, Cloudflare Tunnel…) is enough.
- To accept crypto: your account’s crypto chosen and your wallet connected, from your Tchin dashboard.
1. Create your app
An app is your website or service as Tchin sees it. Create one per site: each has its own keys, settings and stats.
- On tchin.tech/api, tap New app.
- Methods: Mobile Money, crypto, or both. Crypto requires your connected wallet.
- App: a square image (your logo), the name your customers will see, a short description and, if you like, your webhook URL.
- Fees: who pays them, on payments and on payouts. The page shows the effect on a worked example.
2. Get your keys
Tap your app, then View keys. Tchin asks for your Tchin PIN (or biometrics), every time. Put both keys in your server’s environment variables:
# .env (jamais dans Git, jamais dans une page)
TCHIN_PUBLIC_KEY=tchin_pk_...
TCHIN_PRIVATE_KEY=tchin_sk_...3. Create a payment (server)
When your customer clicks “Pay”, your page asks your server to create the payment. With "env": "test", nothing is charged.
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": "test"
}'require 'tchin-php/src/Tchin.php';
$tchin = new Tchin\Client(getenv('TCHIN_PUBLIC_KEY'), getenv('TCHIN_PRIVATE_KEY'));
$p = $tchin->creerPaiement(25000, 'Wintg Cloud - pack Pro', 'https://wintg.group/webhook-tchin', ['env' => 'test']);
enregistrerCommande($commandeId, $p['token']); // le token revient dans le webhook (reference)
echo json_encode(['token' => $p['token']]); // pour votre pageconst { Tchin } = require('./tchin-node');
const tchin = new Tchin(process.env.TCHIN_PUBLIC_KEY, process.env.TCHIN_PRIVATE_KEY);
app.post('/creer-paiement', async (req, res) => {
const p = await tchin.creerPaiement(25000, 'Wintg Cloud - pack Pro', 'https://wintg.group/webhook-tchin', { env: 'test' });
await enregistrerCommande(req.body.commande, p.token); // le token revient dans le webhook
res.json({ token: p.token });
});import os
from tchin import Tchin
tchin = Tchin(os.environ['TCHIN_PUBLIC_KEY'], os.environ['TCHIN_PRIVATE_KEY'])
@app.post('/creer-paiement')
def creer_paiement():
p = tchin.creer_paiement(25000, 'Wintg Cloud - pack Pro', 'https://wintg.group/webhook-tchin', env='test')
enregistrer_commande(request.json['commande'], p['token'])
return {'token': p['token']}Tchin tchin = new Tchin(System.getenv("TCHIN_PUBLIC_KEY"), System.getenv("TCHIN_PRIVATE_KEY"));
String json = tchin.creerPaiement(25000, "Wintg Cloud - pack Pro", "https://wintg.group/webhook-tchin", Map.of("env", "test"));
// lisez « token » (Jackson, Gson), gardez-le avec la commande et rendez-le à votre pagec := tchin.Nouveau(os.Getenv("TCHIN_PUBLIC_KEY"), os.Getenv("TCHIN_PRIVATE_KEY"))
http.HandleFunc("/creer-paiement", func(w http.ResponseWriter, r *http.Request) {
p, err := c.CreerPaiement(25000, "Wintg Cloud - pack Pro", "https://wintg.group/webhook-tchin", map[string]any{"env": "test"})
if err != nil { http.Error(w, err.Error(), 502); return }
json.NewEncoder(w).Encode(map[string]any{"token": p["token"]})
}){
"success": true,
"token": "jtkkbphr7azsn3",
"payment_url": "https://tchin.tech/pay/jtkkbphr7azsn3",
"env": "test"
}token with the order.4. Open the sheet (page)
Add the web kit (one script served by Tchin), then open the sheet with the token returned by your server:
<button id="payer">Payer avec Tchin</button>
<script src="https://tchin.tech/js/tchin-pay.js"></script>
<script>
document.getElementById('payer').onclick = async function () {
const r = await fetch('/creer-paiement', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ commande: 'WG-1042' })
}).then((x) => x.json());
TchinPay.open({
token: r.token,
onSuccess: function () { location.href = '/merci?commande=WG-1042'; }, // affichage seulement
onPending: function () { /* le client valide sur son téléphone */ },
onFailed: function () { /* refusé : il peut réessayer dans la feuille */ },
onClose: function (e) { /* e.reason : closed | success | replaced */ }
});
};
</script>For a sheet in your colours, add apparence: see Match your brand.
5. Receive the result (webhook)
Tchin calls your callback_url on every status change, as a form POST with a data field. Verify the signature, find the order by reference, then deliver if status is completed:
$d = $tchin->verifierWebhook($_POST['data'] ?? []);
if (! $d) { http_response_code(401); exit; } // signature fausse ou trop ancienne
$commande = trouverCommandeParToken($d['reference']);
if ($commande && $d['status'] === 'completed' && ! $commande->payee) {
$commande->marquerPayee(); // une seule fois
}
http_response_code(200);app.post('/webhook-tchin', express.urlencoded({ extended: true }), async (req, res) => {
const d = tchin.verifierWebhook(req.body.data);
if (!d) return res.sendStatus(401);
const commande = await trouverCommandeParToken(d.reference);
if (commande && d.status === 'completed' && !commande.payee) await commande.marquerPayee();
res.sendStatus(200);
});@app.post('/webhook-tchin')
def webhook_tchin():
data = {k[5:-1]: v for k, v in request.form.items() if k.startswith('data[')}
d = tchin.verifier_webhook(data)
if not d:
abort(401)
commande = trouver_commande_par_token(d['reference'])
if commande and d['status'] == 'completed' and not commande.payee:
commande.marquer_payee()
return '', 200r.ParseForm()
if !c.VerifierWebhook(r.PostForm) { http.Error(w, "signature", 401); return }
if r.PostForm.Get("data[status]") == "completed" { livrerUneFois(r.PostForm.Get("data[reference]")) }
w.WriteHeader(200)onSuccess): anyone can fake it. Only the signed webhook, or GET /api/v1/payments/{token}/status called from your server, counts.6. Test
In test mode, the sheet shows Test mode and offers Simulate payment: nothing to type, no money. The webhook arrives with "mode": "test", signed just like in live mode.
The fastest way to try without code: the playground. Try at least three cases: a successful payment (completed), a declined one (failed), and a sheet closed without paying (nothing arrives, the payment stays pending).
7. Go live
When everything works, replace "env": "test" with "env": "live": the same keys, the same code, real payments. First, go through Going live.