openPayerMax static method
Future<void>
openPayerMax({
- required num amount,
- num? coins,
- required String coinPlanId,
- String? appId,
- String? merchantNo,
- String? apiUrl,
- String? privateKeyBase64,
- String? upiId,
- String currency = "INR",
- String country = "IN",
- String userId = "USER_DEMO_01",
- String paymentGatewayName = "PayerMax",
- bool testMode = false,
- dynamic onPaymentSuccess()?,
- dynamic onPaymentFailure()?,
- dynamic onShowToast()?,
Opens the PayerMax checkout bottom sheet using GetX
Implementation
static Future<void> openPayerMax({
required num amount,
num? coins,
required String coinPlanId,
String? appId,
String? merchantNo,
String? apiUrl,
String? privateKeyBase64,
String? upiId,
String currency = "INR",
String country = "IN",
String userId = "USER_DEMO_01",
String paymentGatewayName = "PayerMax",
bool testMode = false,
Function()? onPaymentSuccess,
Function()? onPaymentFailure,
Function()? onShowToast,
}) async {
final controller = Get.isRegistered<PayerMaxController>()
? Get.find<PayerMaxController>()
: Get.put(PayerMaxController());
// 1. Show Loading dialog
Get.dialog(
Center(
child: Container(
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
),
child: const Column(
mainAxisSize: MainAxisSize.min,
children: [
CircularProgressIndicator(color: Colors.deepPurple),
SizedBox(height: 16),
Text(
"Creating PayerMax Order...",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14),
),
SizedBox(height: 4),
Text(
"Connecting to Sandbox Gateway",
style: TextStyle(color: Colors.grey, fontSize: 12),
),
],
),
),
),
barrierDismissible: false,
);
final success = await controller.createOrder(
amountVal: amount,
coinsVal: coins,
coinPlanId: coinPlanId,
appId: appId,
merchantNo: merchantNo,
apiUrl: apiUrl,
privateKeyBase64: privateKeyBase64,
upiId: upiId,
currencyCode: currency,
countryCode: country,
userId: userId,
paymentGatewayName: paymentGatewayName,
testMode: testMode,
onSuccess: onPaymentSuccess,
onFailure: onPaymentFailure,
onToast: onShowToast,
);
if (Get.isDialogOpen == true) {
Get.back();
}
if (!success) {
return;
}
// 2. Open PayerMax BottomSheet
await Get.bottomSheet(
PayerMaxBottomSheet(controller: controller),
isScrollControlled: true,
);
}