implementPayment function
Future<PaymentResultData>
implementPayment({
- required List<
String> brands, - required String checkoutId,
- required String channelName,
- required String shopperResultUrl,
- required String lang,
- required PaymentMode paymentMode,
- required String merchantId,
- required String countryCode,
- String? companyName = "",
- String? themColorHexIOS,
- required bool setStorePaymentDetailsMode,
This function implements the payment with the provided payment details. It takes in parameters like brand, checkoutId, channelName, etc. which are essential for the payment to happen. It returns a PaymentResultData object which is processed and managed by PaymentResultManger. If there is any error, it is caught and a PaymentResultData object with error string is returned.
Implementation
Future<PaymentResultData> implementPayment(
{required List<String> brands,
required String checkoutId,
required String channelName,
required String shopperResultUrl,
required String lang,
required PaymentMode paymentMode,
required String merchantId,
required String countryCode,
String? companyName = "",
String? themColorHexIOS,
required bool setStorePaymentDetailsMode}) async {
String transactionStatus;
var platform = MethodChannel(channelName);
try {
final String? result = await platform.invokeMethod(
PaymentConst.methodCall,
getReadyModelCards(
brands: brands,
checkoutId: checkoutId,
themColorHexIOS: themColorHexIOS,
shopperResultUrl: shopperResultUrl,
paymentMode: paymentMode,
countryCode: countryCode,
merchantId: merchantId,
companyName: companyName,
lang: lang,
setStorePaymentDetailsMode: setStorePaymentDetailsMode,
),
);
transactionStatus = '$result';
return PaymentResultManger.getPaymentResult(transactionStatus);
} on PlatformException catch (e) {
transactionStatus = "${e.message}";
return PaymentResultData(
errorString: e.message, paymentResult: PaymentResult.error);
}
}