implementPaymentCustomUI function

Future<PaymentResultData> implementPaymentCustomUI({
  1. required PaymentMode paymentMode,
  2. required String brand,
  3. required String checkoutId,
  4. required String channelName,
  5. required String shopperResultUrl,
  6. required String lang,
  7. required String cardNumber,
  8. required String holderName,
  9. required int month,
  10. required int year,
  11. required int cvv,
  12. required bool enabledTokenization,
})

This is an asynchronous function that implements a custom UI payment. It takes parameters such as paymentMode, brand, checkoutId, channelName, shopperResultUrl, lang, cardNumber, holderName, month, year, cvv and enabledTokenization. It uses the MethodChannel class to invoke a payment method call with a custom UI payment model. The function returns a PaymentResultData object with information on the payment transaction status. If successful, it returns the payment result. If unsuccessful, it returns the error string and payment result.

Implementation

Future<PaymentResultData> implementPaymentCustomUI({
  required PaymentMode paymentMode,
  required String brand,
  required String checkoutId,
  required String channelName,
  required String shopperResultUrl,
  required String lang,
  required String cardNumber,
  required String holderName,
  required int month,
  required int year,
  required int cvv,
  required bool enabledTokenization,
}) async {
  String transactionStatus;
  var platform = MethodChannel(channelName);
  try {
    final String? result = await platform.invokeMethod(
      PaymentConst.methodCall,
      getCustomUiModelCards(
        brand: brand,
        checkoutId: checkoutId,
        shopperResultUrl: shopperResultUrl,
        paymentMode: paymentMode,
        cardNumber: cardNumber,
        holderName: holderName,
        month: month,
        year: year,
        cvv: cvv,
        lang: lang,
        enabledTokenization: enabledTokenization,
      ),
    );
    transactionStatus = '$result';
    return PaymentResultManger.getPaymentResult(transactionStatus);
  } on PlatformException catch (e) {
    transactionStatus = "${e.message}";
    return PaymentResultData(
        errorString: e.message, paymentResult: PaymentResult.error);
  }
}