API — Dart
Dart integration
Integrate XPAYE into your Dart and Flutter applications. A native solution to initialize payments from your mobile and web apps.
PaiementPro class
Class definition
paiement-pro.dart
import 'package:http/http.dart' as http;
import 'dart:convert';
class PaiementPro {
String merchantId = '';
int amount = 0; /* Montant à payer */
String description = ''; /* Description pour le paiement obligatoire */
String channel = ''; /* Mode paiement consulter l'espace XPAYE pour les différents providers */
String countryCurrencyCode = '952'; /* Code de la devise: FCFA par défaut */
String referenceNumber = ''; /* Référence de la transaction obligatoire et unique */
String customerEmail = ''; /* Email de l'utilisateur obligatoire */
String customerFirstName = ''; /* Prénom de l'utilisateur obligatoire */
String customerLastname = ''; /* Nom de l'utilisateur obligatoire */
String customerPhoneNumber = ''; /* Contact de l'utilisateur obligatoire */
String notificationURL = ''; /* URL de notification dans le cas où vous enregistrez les données sur votre espace */
String returnURL = ''; /* URL de retour après paiement: Il est conseillé d'utiliser le même que notificationURL */
String returnContext = ''; /* Données présentes dans returnURL Ex: {utilisateur_id:1,data:true} */
String url = ''; /* URL de paiement */
String message = ''; /* Message */
bool success = false; /* Initialisation du paiement */
PaiementPro(this.merchantId);
getUrlPayment() async {
var url = Uri.https('paiementpro.net', 'webservice/onlinepayment/init/curl-init.php');
var response = await http.post(url, body: jsonEncode({
"merchantId": this.merchantId,
"amount": this.amount,
"description": this.description,
"channel": this.channel,
"countryCurrencyCode": this.countryCurrencyCode,
"referenceNumber": this.referenceNumber,
"customerEmail": this.customerEmail,
"customerFirstName": this.customerFirstName,
"customerLastname": this.customerLastname,
"customerPhoneNumber": this.customerPhoneNumber,
"notificationURL": this.notificationURL,
"returnURL": this.returnURL,
"returnContext": this.returnContext,
}));
var data = jsonDecode(response.body);
if(data['url'] != null){
this.url = data['url'];
this.success = data['success'];
} else {
this.message = data['message'];
this.success = data['success'];
}
}
}Integration example
Usage with Flutter
main.dart
import 'package:flutter/material.dart';
import 'package:ppro/class/paiement-pro.dart';
import 'package:url_launcher/url_launcher.dart';
function_paiement() async {
PaiementPro paiement_pro = new PaiementPro('ID MARCHAND');
paiement_pro.amount = 1000;
paiement_pro.channel = 'WAVECI';
paiement_pro.referenceNumber = '0123456789';
paiement_pro.customerEmail = 'client@example.com';
paiement_pro.customerFirstName = 'Jean';
paiement_pro.customerLastname = 'Dupont';
paiement_pro.customerPhoneNumber = '0123456789';
paiement_pro.description = 'Paiement via API Dart';
await paiement_pro.getUrlPayment();
if(paiement_pro.success){
print(paiement_pro.url);
final Uri _url = Uri.parse(paiement_pro.url);
Future<void> _launchUrl() async {
if (!await launchUrl(_url)) {
throw 'Could not launch $_url';
}
}
// Succès: ouvrir dans le navigateur
_launchUrl();
} else {
// Erreur d'initialisation
print(paiement_pro.message);
}
}API responses
PaiementPro object properties
Success
response.dart
paiement_pro.success = true;
paiement_pro.url = "https://sandbox.paiementpro.net/sandbox.php?sessionid=...";Error
response.dart
paiement_pro.success = false;
paiement_pro.message = "Message d'erreur";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, WAVECI, 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é |
