import os

import cfgtools

can_cancel_payment_on_error = None


def can_cancel_tef_payment_on_error():
    # type: (...) -> str

    global can_cancel_payment_on_error

    if can_cancel_payment_on_error is None:
        config = cfgtools.read(os.environ["LOADERCFG"])
        can_cancel = config.find_value("Customizations.CanCancelTEFPaymentOnError", "false").lower()
        can_cancel_payment_on_error = can_cancel == "true"

    return can_cancel_payment_on_error
