checkout static method

Process a payment checkout

Implementation

static Future<SumupPluginCheckoutResponse> checkout(SumupPaymentRequest paymentRequest) async {
  try {
    // Get the native response from SumUp
    final nativeResponse = await sumup_lib.Sumup.checkout(paymentRequest.toSumupPaymentRequest());

    // Extract the properties we need in a type-safe way
    // According to the SumUp package documentation, success is a boolean property
    final bool isSuccess = nativeResponse.success ?? false;
    final String? txnCode = nativeResponse.transactionCode;
    final String? card = nativeResponse.cardType;

    // Create our response with the available properties
    return _createCheckoutResponse(
      isSuccess,
      {'success': isSuccess}, // Create a simple message map with the success status
      txnCode,
      card
    );
  } catch (e) {
    return _createCheckoutResponse(false, {'error': e.toString()});
  }
}