Call to undefined function oxNew

Hello. I’m trying to use an oxNew() function in the controller of my module, but I always keep getting this error:

Fatal error: Call to undefined function path\path\oxNew() …

How do I include it so that I can use it into my code?

Thank you very much!

Can you provide full code?

    $wpgUrl = $_POST['url'];
    $wpgHttpUser = $_POST['http_user'];
    $wpgHttpPass = $_POST['http_pass'];


            //$config = new Config($wpgUrl, $wpgHttpUser, $wpgHttpPass);
            $config = \oxNew(Config::class, $wpgUrl, $wpgHttpUser, $wpgHttpPass);

            $transactionService = new TransactionService($config);
            if ($transactionService->checkCredentials()) {
                $this->response['status'] = 'ok';
                $this->response['message'] = 'The merchant configuration was successfully tested.';
            }

And in the header part I’m using the libraries that include TransactionService and Config class, but it doesn’t find the oxNew function which is the built in function of oxid esales cms.

I’ve tried using the function also without that slash. I mean:

$config = oxNew(Config::class, $wpgUrl, $wpgHttpUser, $wpgHttpPass);

oxNew is only working for oxid objects imho

I’ve also tried the standard method of creating a new object, but still failed…