API — JavaScript
JavaScript integration
Integrate XPAYE into your web applications with our JavaScript library. A simple, fast solution to initialize payments directly from the browser.
Installation
Include the library
index.html
<script src="https://www.paiementpro.net/webservice/onlinepayment/js/paiementpro.v1.0.2.js"></script>Integration example
JavaScript code
payment.js
<script src="https://www.paiementpro.net/webservice/onlinepayment/js/paiementpro.v1.0.2.js"></script>
<script>
let paiementPro = new PaiementPro('ID MARCHAND');
paiementPro.amount = 1000;
paiementPro.channel = 'CARD';
paiementPro.referenceNumber = '0123456789';
paiementPro.customerEmail = 'client@example.com';
paiementPro.customerFirstName = 'Jean';
paiementPro.customerLastname = 'Dupont';
paiementPro.customerPhoneNumber = '0102030405';
paiementPro.description = 'Paiement via API JavaScript';
const Paiement_Pro = async() => {
await paiementPro.getUrlPayment();
if (paiementPro.success) {
// console.log(paiementPro.success); /* true si l'initialisation c'est bien passée */
// console.log(paiementPro.url); /* URL de paiement */
window.location = paiementPro.url; /* Redirection vers la passerelle de paiement */
} else {
// console.log(paiementPro.success);
// console.log(paiementPro.error);
console.log('Erreur: ' + paiementPro.error);
}
};
Paiement_Pro();
</script>API responses
PaiementPro object properties
Success
response.js
paiementPro.success = true;
paiementPro.url = "https://sandbox.paiementpro.net/sandbox.php?sessionid=...";Error
response.js
paiementPro.success = false;
paiementPro.error = "Message d'erreur";Documentation
Paramètres de l'API
Paramètres d'envoi
| Paramètre | Type | Description |
|---|---|---|
amount | int | Montant de la transaction |
description | string | Description du paiement (obligatoire) |
channel | string | Mode de paiement (CARD, OMCIV2, MOMOCI, etc.) |
countryCurrencyCode | int | Code de la devise |
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é |
