Payments
Liens de paiement
Créez des liens de paiement partageables pour des produits ou des montants sur mesure.
L’API Payment Links permet de créer des liens réutilisables et partageables pour encaisser. Les liens peuvent être rattachés à un produit ou porter un montant personnalisé.
Règles de bout en bout (devise, codes promo, sessions) : Comportement du tunnel.
Types de lien
| Type | Description |
|---|---|
product | Lie un produit précis. Le montant est calculé à partir du tarif produit. |
instant | Montant libre. Le champ amount est obligatoire. |
Créer un lien de paiement
Corps de la requête
| Champ | Type | Obligatoire | Description |
|---|---|---|---|
link_type | string | Oui | product ou instant |
title | string | Oui | Titre du lien |
currency_code | string | Oui | Devise (XOF, USD, EUR) |
description | string | Non | Description du lien |
amount | number | Instantané uniquement | Montant pour les liens instantanés |
product_id | string | Produit uniquement | ID produit pour les liens produit |
price_id | string | Non | Tarif précis (si le produit en a plusieurs) |
allow_coupon_code | boolean | Non | Autoriser les codes de réduction (défaut : false) |
allow_quantity | boolean | Non | Autoriser le changement de quantité (défaut : false) |
require_billing_address | boolean | Non | Exiger l’adresse de facturation (défaut : true) |
expires_at | string | Non | Date d’expiration (ISO 8601) |
success_url | string | Non | URL de redirection après succès |
cancel_url | string | Non | URL de redirection en cas d’annulation |
metadata | object | Non | Paires clé-valeur personnalisées |
import { LomiSDK } from '@lomi./sdk';
const lomi = new LomiSDK({
apiKey: process.env.LOMI_API_KEY!,
environment: 'live',
});
// Lien produit
const productLink = await lomi.paymentLinks.create({
link_type: 'product',
title: 'Premium Subscription',
currency_code: 'XOF',
product_id: 'prod_abc123...',
allow_coupon_code: true,
success_url: 'https://your-site.com/success',
});
// Lien instantané (montant libre)
const instantLink = await lomi.paymentLinks.create({
link_type: 'instant',
title: 'Donation',
currency_code: 'XOF',
amount: 5000,
description: 'Soutenir notre mission',
success_url: 'https://your-site.com/thank-you',
});
console.log(`Share this link: ${productLink.url}`);from lomi import LomiClient
import os
client = LomiClient(
api_key=os.environ["LOMI_API_KEY"],
environment="test"
)
# Lien produit
product_link = client.payment_links.create({
"link_type": "product",
"title": "Premium Subscription",
"currency_code": "XOF",
"product_id": "prod_abc123...",
"allow_coupon_code": True,
"success_url": "https://your-site.com/success"
})
# Lien instantané
instant_link = client.payment_links.create({
"link_type": "instant",
"title": "Donation",
"currency_code": "XOF",
"amount": 5000,
"description": "Soutenir notre mission"
})
print(f"Share this link: {product_link['url']}")curl -X POST "https://api.lomi.africa/payment-links" \
-H "X-API-KEY: $LOMI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"link_type": "product",
"title": "Premium Subscription",
"currency_code": "XOF",
"product_id": "prod_abc123...",
"allow_coupon_code": true,
"success_url": "https://your-site.com/success"
}'Lister les liens de paiement
Récupère tous les liens avec filtrage optionnel.
Paramètres de requête
| Paramètre | Type | Description |
|---|---|---|
linkType | string | Filtrer par type : product, instant |
isActive | boolean | Filtrer par statut actif |
limit | number | Résultats par page (défaut : 20) |
offset | number | Décalage pagination (défaut : 0) |
const links = await lomi.paymentLinks.list({
linkType: 'product',
isActive: true,
limit: 20,
});links = client.payment_links.list(
linkType="product",
isActive=True,
limit=20
)curl -X GET "https://api.lomi.africa/payment-links?linkType=product&isActive=true&limit=20" \
-H "X-API-KEY: $LOMI_API_KEY"Obtenir un lien de paiement
Récupère le détail d’un lien précis.
const link = await lomi.paymentLinks.get('pl_abc123...');
console.log(`URL: ${link.url}`);link = client.payment_links.get('pl_abc123...')curl -X GET "https://api.lomi.africa/payment-links/pl_abc123..." \
-H "X-API-KEY: $LOMI_API_KEY"Objet lien de paiement
| Champ | Type | Description |
|---|---|---|
id | string | Identifiant unique |
url | string | URL de paiement partageable |
link_type | string | product ou instant |
title | string | Titre du lien |
description | string | Description du lien |
amount | number | Montant (liens instantanés) |
currency_code | string | Code devise |
product_id | string | Produit associé (liens produit) |
is_active | boolean | Statut actif |
expires_at | string | Horodatage d’expiration |
metadata | object | Métadonnées personnalisées |
created_at | string | Horodatage de création |
Réponses d’erreur
| Statut | Description |
|---|---|
400 | Entrée invalide (ex. montant sur un lien produit) |
401 | Clé API invalide ou manquante |
404 | Lien introuvable ou accès refusé |