implementPayment function

Future<PaymentResultData> implementPayment({
  1. required List<String> brands,
  2. required String checkoutId,
  3. required String channelName,
  4. required String shopperResultUrl,
  5. required String lang,
  6. required PaymentMode paymentMode,
  7. required String merchantId,
  8. required String countryCode,
  9. String? companyName = "",
  10. String? themColorHexIOS,
  11. 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);
  }
}