Collection Postman
Importer et tester l'API Neka Paie sans coder une ligne.
Démarrage rapide
- Téléchargez Postman Desktop : postman.com/downloads
- Cliquez sur Import dans Postman
- Collez le JSON ci-dessous (Collection v2.1)
- Configurez les variables
api_key,api_secret,base_url - Lancez les requêtes — la signature HMAC est calculée automatiquement
Variables de collection
Trois variables à définir au niveau de la collection :
| Variable | Valeur (sandbox) |
|---|---|
base_url | https://nekapaie.com/api/v1 |
api_key | Votre nk_test_xxx... |
api_secret | Votre secret 64 caractères hex |
Pre-request Script (calcul HMAC automatique)
À coller dans l'onglet Pre-request Script au niveau de la collection. La signature est recalculée à chaque requête.
JSconst apiSecret = pm.collectionVariables.get('api_secret');
const apiKey = pm.collectionVariables.get('api_key');
const ts = Math.floor(Date.now() / 1000).toString();
// Récupérer le body brut s'il existe
let body = '';
if (pm.request.body && pm.request.body.raw) {
body = pm.request.body.raw;
}
// Calculer la signature HMAC-SHA256
const signature = CryptoJS.HmacSHA256(ts + body, apiSecret).toString(CryptoJS.enc.Hex);
// Injecter les en-têtes
pm.request.headers.add({key: 'X-NekaPay-Key', value: apiKey});
pm.request.headers.add({key: 'X-NekaPay-Timestamp', value: ts});
pm.request.headers.add({key: 'X-NekaPay-Signature', value: signature});
Collection JSON complète
Enregistrez ce JSON dans un fichier nekapay.postman_collection.json puis importez-le.
JSON{
"info": {
"name": "Neka Paie API",
"description": "Collection officielle Neka Paie - API Orange Money",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"auth": {"type": "noauth"},
"event": [{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
"const apiSecret = pm.collectionVariables.get('api_secret');",
"const apiKey = pm.collectionVariables.get('api_key');",
"const ts = Math.floor(Date.now() / 1000).toString();",
"let body = '';",
"if (pm.request.body && pm.request.body.raw) body = pm.request.body.raw;",
"const signature = CryptoJS.HmacSHA256(ts + body, apiSecret).toString(CryptoJS.enc.Hex);",
"pm.request.headers.add({key: 'X-NekaPay-Key', value: apiKey});",
"pm.request.headers.add({key: 'X-NekaPay-Timestamp', value: ts});",
"pm.request.headers.add({key: 'X-NekaPay-Signature', value: signature});"
]
}
}],
"variable": [
{"key": "base_url", "value": "{{ nekapay_sandbox_base_url }}"},
{"key": "api_key", "value": "nk_test_REPLACE_ME"},
{"key": "api_secret", "value": "REPLACE_ME"}
],
"item": [
{
"name": "Cash-In",
"request": {
"method": "POST",
"header": [{"key": "Content-Type", "value": "application/json"}],
"url": {"raw": "{{base_url}}/payments/cashin", "host": ["{{base_url}}"], "path": ["payments", "cashin"]},
"body": {
"mode": "raw",
"raw": "{\n \"merchant_order_id\": \"order_{{$timestamp}}\",\n \"amount\": 50000,\n \"currency\": \"XOF\",\n \"customer_msisdn\": \"+22376123456\",\n \"country_code\": \"ML\"\n}"
}
}
},
{
"name": "Cash-Out",
"request": {
"method": "POST",
"header": [{"key": "Content-Type", "value": "application/json"}],
"url": {"raw": "{{base_url}}/payments/cashout", "host": ["{{base_url}}"], "path": ["payments", "cashout"]},
"body": {
"mode": "raw",
"raw": "{\n \"merchant_order_id\": \"payout_{{$timestamp}}\",\n \"amount\": 100000,\n \"beneficiary_msisdn\": \"+22376987654\",\n \"currency\": \"XOF\",\n \"reason\": \"Test sandbox\"\n}"
}
}
},
{
"name": "Get Transaction Status",
"request": {
"method": "GET",
"url": {"raw": "{{base_url}}/payments/{{transaction_id}}", "host": ["{{base_url}}"], "path": ["payments", "{{transaction_id}}"]}
}
},
{
"name": "Refund",
"request": {
"method": "POST",
"header": [{"key": "Content-Type", "value": "application/json"}],
"url": {"raw": "{{base_url}}/refunds", "host": ["{{base_url}}"], "path": ["refunds"]},
"body": {
"mode": "raw",
"raw": "{\n \"transaction_id\": \"{{transaction_id}}\",\n \"reason\": \"Annulation client\"\n}"
}
}
},
{
"name": "Get Balances",
"request": {
"method": "GET",
"url": {"raw": "{{base_url}}/balances", "host": ["{{base_url}}"], "path": ["balances"]}
}
},
{
"name": "Export Transactions (CSV)",
"request": {
"method": "GET",
"url": {
"raw": "{{base_url}}/transactions/export?date_from=2026-04-01&date_to=2026-04-30&format=csv",
"host": ["{{base_url}}"],
"path": ["transactions", "export"],
"query": [
{"key": "date_from", "value": "2026-04-01"},
{"key": "date_to", "value": "2026-04-30"},
{"key": "format", "value": "csv"}
]
}
}
}
]
}
Astuces Postman
- Utilisez
{{$timestamp}}dans le body pour générer un order_id unique à chaque appel. - Pour récupérer automatiquement le
transaction_idretourné, ajoutez dans Tests :JSconst data = pm.response.json(); if (data.data && data.data.transaction_id) { pm.collectionVariables.set('transaction_id', data.data.transaction_id); } - Pour la production, dupliquez la collection et changez
base_urlenhttps://nekapaie.com/api/v1etapi_keyennk_live_*.