Clients
Gérez les profils clients et consultez leur historique de paiement.
L’API Customers permet de créer, consulter, mettre à jour et gérer les profils clients liés à votre compte marchand.
Créer un client
Référence API (schéma complet) : Créer un client
L’essentiel : name est obligatoire. Passez email, phone_number, whatsapp_number, l’adresse, is_business et metadata pour le préremplissage checkout et votre CRM.
import { LomiSDK } from '@lomi./sdk';
const lomi = new LomiSDK({
apiKey: process.env.LOMI_SECRET_KEY!,
environment: 'live',
});
const customer = await lomi.customers.create({
name: 'Amadou Ba',
email: 'amadou.ba@example.com',
phone_number: '+221771234567',
country: 'Senegal',
city: 'Dakar',
is_business: false,
metadata: {
internal_id: 'USER_123',
},
});
console.log(`Customer created: ${customer.id}`);from lomi import LomiClient
import os
client = LomiClient(
api_key=os.environ["LOMI_SECRET_KEY"],
environment="test"
)
customer = client.customers.create({
"name": "Amadou Ba",
"email": "amadou.ba@example.com",
"phone_number": "+221771234567",
"country": "Senegal",
"city": "Dakar",
"is_business": False,
"metadata": {"internal_id": "USER_123"}
})
print(f"Customer created: {customer['id']}")curl -X POST "https://api.lomi.africa/customers" \
-H "X-API-KEY: $LOMI_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Amadou Ba",
"email": "amadou.ba@example.com",
"phone_number": "+221771234567",
"country": "Senegal",
"city": "Dakar",
"is_business": false,
"metadata": {"internal_id": "USER_123"}
}'Lister les clients
Référence API : Lister les clients, search, type, status, page et pageSize.
const customers = await lomi.customers.list({
search: 'amadou',
type: 'individual',
status: 'active',
page: 1,
pageSize: 20,
});customers = client.customers.list(
search="amadou",
type="individual",
status="active",
page=1,
pageSize=20
)curl -X GET "https://api.lomi.africa/customers?search=amadou&type=individual&page=1&pageSize=20" \
-H "X-API-KEY: $LOMI_SECRET_KEY"Réponse
{
"customers": [...],
"pagination": {
"page": 1,
"pageSize": 20,
"totalCount": 150,
"totalPages": 8
}
}Obtenir un client
Référence API : Obtenir un client
const customer = await lomi.customers.get('cus_abc123...');customer = client.customers.get('cus_abc123...')curl -X GET "https://api.lomi.africa/customers/cus_abc123..." \
-H "X-API-KEY: $LOMI_SECRET_KEY"Mettre à jour un client
Référence API : Mettre à jour un client, tous les champs du corps sont facultatifs.
const updated = await lomi.customers.update('cus_abc123...', {
email: 'new.email@example.com',
metadata: { vip: true },
});updated = client.customers.update('cus_abc123...', {
"email": "new.email@example.com",
"metadata": {"vip": True}
})curl -X PATCH "https://api.lomi.africa/customers/cus_abc123..." \
-H "X-API-KEY: $LOMI_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "new.email@example.com"}'Supprimer un client
Référence API : Supprimer un client
await lomi.customers.delete('cus_abc123...');client.customers.delete('cus_abc123...')curl -X DELETE "https://api.lomi.africa/customers/cus_abc123..." \
-H "X-API-KEY: $LOMI_SECRET_KEY"Transactions d’un client
Référence API : Transactions client
const transactions = await lomi.customers.getTransactions('cus_abc123...');
transactions.forEach(tx => {
console.log(`${tx.description}: ${tx.gross_amount} ${tx.currency_code}`);
});transactions = client.customers.get_transactions('cus_abc123...')
for tx in transactions:
print(f"{tx['description']}: {tx['gross_amount']} {tx['currency_code']}")curl -X GET "https://api.lomi.africa/customers/cus_abc123.../transactions" \
-H "X-API-KEY: $LOMI_SECRET_KEY"Réponse
[
{
"transaction_id": "tx_def456...",
"description": "Payment for Product A",
"gross_amount": 10000,
"currency_code": "XOF",
"status": "completed",
"created_at": "2024-01-15T10:30:00Z"
}
]Créer une session de lancement portail client
Référence API : Session de lancement portail
Génère une URL portail hébergée à usage unique depuis votre backend. Retourne launch_url pour la redirection. Voir Portail client pour les flux, la sécurité et la checklist production.
import axios from 'axios';
const { data: launch } = await axios.post(
'https://api.lomi.africa/customers/cus_abc123.../portal-launch-session',
{
return_url: 'https://merchant.example.com/account',
flow_type: 'subscription_cancel',
flow_subscription_id: 'sub_abc123...',
flow_after_completion_url:
'https://merchant.example.com/account/subscription-cancelled',
},
{
headers: {
'X-API-KEY': process.env.LOMI_SECRET_KEY!,
'Content-Type': 'application/json',
},
},
);
window.location.href = launch.launch_url;curl -X POST "https://api.lomi.africa/customers/cus_abc123.../portal-launch-session" \
-H "X-API-KEY: $LOMI_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"return_url": "https://merchant.example.com/account",
"flow_type": "subscription_cancel",
"flow_subscription_id": "sub_abc123...",
"flow_after_completion_url": "https://merchant.example.com/account/subscription-cancelled"
}'