Flutter Moncash Payment Plugin
A flutter plugin for moncash integration for Android and Ios.
If you use this library in your app, please let me know and I'll add it to the list.
Installing
Add this in pubspec.yaml
moncash_flutter:
Using
import 'package:moncash_flutter/moncash_flutter.dart';
WidgetsBinding.instance!.addPostFrameCallback((_) async {
PaymentResponse? data = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MonCashPayment(
isStaging: true,
amount: Amount,
clientId: "Id",
clientSecret: clientSecret,
loadingWidget: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
LoadingScreen(color: Colors.white),
Text("Redirecting to payment gateway..."),
],
),
)),
);
if (data != null && data.status == paymentStatus.success && data.transanctionId != null) {
setState(() {
paymentSuccess = true;
});
placeOrder(transanctionId: data.transanctionId, orderId: data.orderId);
} else {
if (data == null) {
showErrorDialog(context, "ERROR: Payment Failed");
} else {
showErrorDialog(context, "ERROR: ${data.message}");
}
setState(() {
isLoading = false;
paymentSuccess = false;
});
}
});
If payment is successful PaymentResponse will contain the transanctionId from moncash.