API — PHP
Intégration PHP
Intégrez XPAYE dans vos applications PHP en quelques lignes de code. Notre API REST simple et sécurisée vous permet d'initialiser des paiements en toute simplicité.
Exemple d'intégration
Code PHP
payment.php
<?php
$data = array(
'merchantId' => "MARCHAND ID",
'amount' => 1000,
'description' => "Paiement via API PHP",
'channel' => "CARD",
'countryCurrencyCode' => "952",
'referenceNumber' => "REF-" . time(),
'customerEmail' => "client@example.com",
'customerFirstName' => "Jean",
'customerLastname' => "Dupont",
'customerPhoneNumber' => "01234567",
'notificationURL' => "https://votre-site.com/webhook",
'returnURL' => "https://votre-site.com/retour",
'returnContext' => '{"order_id":"123","user":"88"}',
);
$data = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://sandbox.paiementpro.net/webservice/onlinepayment/init/curl-init.php");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if ($result['success']) {
header("Location: " . $result['url']);
} else {
echo "Erreur: " . $result['message'];
}
?>Réponses de l'API
Exemples de réponses JSON
Réponse succès
response.json
{
"success": true,
"message": "Initialisation effectuée avec succès",
"url": "https://sandbox.paiementpro.net/sandbox.php?sessionid=1234567890"
}Réponse erreur
response.json
{
"success": false,
"message": "Echec de l'initialisation"
}Documentation
Paramètres de l'API
Paramètres d'envoi
| Paramètre | Type | Description |
|---|---|---|
merchantId | string | Votre ID Marchand (ex: PP-F324) |
amount | int | Montant de la transaction |
description | string | Description du paiement (obligatoire) |
channel | string | Mode de paiement (CARD, OMCIV2, MOMOCI, etc.) |
countryCurrencyCode | string | Code devise (ex: 952 pour XOF) |
referenceNumber | string | Référence unique de la transaction (obligatoire) |
customerEmail | string | Email du client (obligatoire) |
customerFirstName | string | Prénom du client (obligatoire) |
customerLastname | string | Nom du client (obligatoire) |
customerPhoneNumber | string | Téléphone du client (obligatoire) |
notificationURL | string | URL de webhook pour notifications |
returnURL | string | URL de redirection après paiement |
returnContext | string | Données additionnelles (JSON) |
Paramètres de réponse
| Paramètre | Type | Description |
|---|---|---|
merchantId | string | Identifiant unique du partenaire |
referenceNumber | string | Référence de la transaction |
amount | int | Montant de la transaction |
transactiondt | string | Date et heure de la transaction |
customerId | string | Identifiant du client |
returnContext | string | Données transmises au partenaire |
hashcode | string | Chaîne cryptée pour sécurité |
responsecode | string | 0 = Réussi, -1 = Échoué |
