startPayment static method
Initiates a UPI payment transaction.
Parameters:
paymentApp
: The UPI payment app to be used for the transaction.payeeVpa
: The VPA (Virtual Payment Address) of the payee.payeeName
: The name of the payee.transactionId
: The unique ID for the transaction.transactionRefId
: The reference ID for the transaction (optional).payeeMerchantCode
: The merchant code of the payee.description
: The description of the transaction.amount
: The amount to be transferred.currency
: The currency for the transaction (default is "INR").response
: A callback function to handle the UPI response.error
: A callback function to handle errors during the transaction.
Implementation
static Future<UpiResponse> startPayment({
required String paymentApp,
required String upiUrl,
}) async {
try {
if (Platform.isAndroid) {
if (kDebugMode) {
print('enimbbl_mobile_kit_flutter_webview_sdk');
}
return await FlutterNativeUpi(
const MethodChannel('nimbbl_mobile_kit_flutter_webview_sdk'))
.initiateTransaction(upiUrl, paymentApp);
// _showTransactionDetailsDialog(upiInstance);
} else {
// String url = appendAndMakeUrl(upiRequestParams);
return await FlutterNativeUpi(
const MethodChannel('nimbbl_mobile_kit_flutter_webview_sdk'))
.initiateTransactioniOS(upiUrl);
}
} on PlatformException catch (e) {
if (kDebugMode) {
print('error-->$e');
}
return UpiResponse(status: 'fail');
} catch (e) {
if (e is UpiException) {
return UpiResponse(status: 'fail');
} else {
return UpiResponse(status: 'fail');
}
}
}