A flutter plugin for moncash integration for Android and Ios.
Add this in pubspec.yaml
moncash_flutter:
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.