lengopay_flutter 0.0.1
lengopay_flutter: ^0.0.1 copied to clipboard
Un package Flutter pour l'intégration de l'API de paiement Lengopay.
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 {
final lengopay = LengopayFlutter(
licenseKey:
'clc3M2hYeGdKSXBrM3Z5Y3VjOEtqdEl1ZWJleVJiN1RrT3paSjVLZGhPckd1czdKVTJEUlVoWFpVc3ByREpLdg==',
// Optionnel: utilisez l'URL de production
// baseUrl:
);
try {
// Initier un paiement
final paymentResponse = await lengopay.initiatePayment(
PaymentRequest(
websiteId: '5d5nhLzjUeZb4dfM',
amount: 1000,
currency: 'GNF', // "GNF", "XOF" ou "USD"
returnUrl: '',
callbackUrl: '',
),
);
// 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'),
),
),
),
);
}
}