Paiements
Initiation de paiement, wallet, payouts et historique via @ziwako/client.
La ressource Payments gère le cycle de paiement de la plateforme : initiation d'un
paiement, notification (callback du fournisseur), paiement par wallet, vérification de
statut, retraits (payouts) et historique.
- Factory :
getPayments()(@ziwako/client/axios) - Types :
InitPaymentBody,PayWithWalletBody,VerifyPaymentStatusBody,PostPayoutsInitBody,TransactionResponse,TransactionPaginationResponse,ListPayoutHistoryParams - Endpoints :
POST /payments/init,POST /payments/notify,GET /payments,GET /payments/{id},POST /payments/wallet,PUT /payments/{transactionId}/status,POST /payouts/init,GET /payouts/history/{proProfilId}
import { configure, getPayments } from '@ziwako/client/axios';
configure({ accessToken: '...' });
const payments = getPayments();initPayment
Initialise un paiement (création de la transaction côté fournisseur de paiement).
Signature : initPayment(initPaymentBody: InitPaymentBody) → Promise<InitPayment200>
const response = await payments.initPayment({
orderId: '64b8f2...',
amount: 85000,
currency: 'XOF',
returnUrl: 'https://ziwako.com/paiement/confirmation',
});
console.log(response.data?.paymentUrl);import { useInitPayment } from '@ziwako/client/react-query';
const mutation = useInitPayment({
mutation: {
onSuccess: (response) => {
window.location.href = response.data?.paymentUrl ?? '/';
},
},
});
mutation.mutate({ data: { orderId: '64b8f2...', amount: 85000, currency: 'XOF' } });postPaymentsNotify
Point d'entrée de notification utilisé par le fournisseur de paiement (webhook/callback) pour signaler l'issue d'un paiement. À exposer tel quel, sans modification.
Signature : postPaymentsNotify() → Promise<PostPaymentsNotify200>
// Route API Next.js (app/api/payments/notify/route.ts)
import { postPaymentsNotify } from '@ziwako/client/axios';
export async function POST() {
const response = await postPaymentsNotify();
return Response.json(response);
}import { usePostPaymentsNotify } from '@ziwako/client/react-query';
const mutation = usePostPaymentsNotify();
mutation.mutate({});getPayments
Liste des paiements.
Signature : getPayments() → Promise<GetPayments200>
const list = await payments.getPayments();
console.log(list.data?.docs);import { useGetPayments } from '@ziwako/client/react-query';
const { data } = useGetPayments();getPaymentsId
Récupère un paiement par son id.
Signature : getPaymentsId(id: string) → Promise<GetPaymentsId200>
const response = await payments.getPaymentsId('64b8f2...');
console.log(response.data?.status);import { useGetPaymentsId } from '@ziwako/client/react-query';
const { data } = useGetPaymentsId(paymentId);payWithWallet
Règle un montant avec le wallet (solde de crédits) du profil. Le corps est requis.
Signature : payWithWallet(payWithWalletBody: PayWithWalletBody) → Promise<PayWithWallet200>
const response = await payments.payWithWallet({
orderId: '64b8f2...',
amount: 15000,
});
console.log(response.data?.status);import { usePayWithWallet } from '@ziwako/client/react-query';
const mutation = usePayWithWallet();
mutation.mutate({ data: { orderId: '64b8f2...', amount: 15000 } });verifyPaymentStatus
Vérifie (et met à jour) le statut d'un paiement. Les deux paramètres sont requis.
Signature : verifyPaymentStatus(transactionId: string, verifyPaymentStatusBody: VerifyPaymentStatusBody) → Promise<TransactionResponse>
const response = await payments.verifyPaymentStatus(transactionId, {
reference: 'REF-2026-0001',
});
console.log(response.data?.status);import { useVerifyPaymentStatus } from '@ziwako/client/react-query';
const mutation = useVerifyPaymentStatus();
mutation.mutate({ transactionId, data: { reference: 'REF-2026-0001' } });postPayoutsInit
Initie un retrait (payout) vers le compte d'un ProProfil. Le corps est requis.
Signature : postPayoutsInit(postPayoutsInitBody: PostPayoutsInitBody) → Promise<PostPayoutsInit200>
const response = await payments.postPayoutsInit({
proProfilId: '64b8f2...',
amount: 250000,
method: 'mobile_money',
});import { usePostPayoutsInit } from '@ziwako/client/react-query';
const mutation = usePostPayoutsInit();
mutation.mutate({ data: { proProfilId: '64b8f2...', amount: 250000, method: 'mobile_money' } });listPayoutHistory
Historique paginé des retraits d'un ProProfil.
Signature : listPayoutHistory(proProfilId: string, params?: ListPayoutHistoryParams) → Promise<TransactionPaginationResponse>
const list = await payments.listPayoutHistory('64b8f2...', { page: 1, limit: 20 });
console.log(list.data?.docs);import { useListPayoutHistory } from '@ziwako/client/react-query';
const { data } = useListPayoutHistory(proProfilId, { page: 1, limit: 20 });