lengopay_flutter 1.0.0
lengopay_flutter: ^1.0.0 copied to clipboard
Un package Flutter pour l'intégration de l'API de paiement Lengo Pay.
example/lib/main.dart
import 'dart:developer';
import 'package:lengopay_flutter/lengopay_flutter.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
Future<void> testPayment() async {
// Initialisation du service Lengopay avec votre clé de licence
final lengopay = LengopayFlutter(
licenseKey: '',
// Par defaut le package utilise l'url de test: 'https://sandbox.lengopay.com/api/v1'
// vous pouvez utiliser l'URL de production
// ici 👇👇
// baseUrl:
);
try {
// Initier un paiement
final paymentResponse = await lengopay.initiatePayment(
PaymentRequest(
websiteId: '',
// L'identifiant unique de votre site
amount: 1500,
// Montant du paiement
currency: 'GNF',
// Devise utilisée "GNF", "XOF" ou "USD"
returnUrl: '',
// (Optionnel) URL de retour
callbackUrl: '',
// (Optionnel) URL de callback
),
);
// Vous pouvez remplacer log par print selon vos bésoins.
log('Status: ${paymentResponse.status}');
log('Pay ID: ${paymentResponse.payId}');
log('URL de paiement: ${paymentResponse.paymentUrl}');
} on LengopayException catch (e) {
log('Erreur Lengopay: ${e.toString()}');
} catch (e) {
log('Erreur inattendue: ${e.toString()}');
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Material App',
home: Scaffold(
appBar: AppBar(
title: const Text('Material App Bar'),
),
body: Center(
child: MaterialButton(
color: Colors.blue,
textColor: Colors.white,
onPressed: testPayment,
child: Text('Tester le payement'),
),
),
),
);
}
}