I'm stuck on an error that I can't solve, I need help please.
Attempted to load class "MockStorageStrategy" from namespace "MangoPay\Tests\Mocks". Did you forget a "use" statement for another namespace?

my code:
<?php
namespace App\Service;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use App\Entity\User;
use MangoPay;
use MangoPay\Tests\Mocks\MockStorageStrategy;
class CallApiService
{
private $mangoPayApi;
private $client;
public function __construct(HttpClientInterface $httpClient)
{
$this->client = $httpClient;
$this->mangoPayApi = new MangoPay\MangoPayApi();
$this->mangoPayApi->Config->ClientId = $_ENV['CLIENT_ID'];
$this->mangoPayApi->Config->ClientPassword = $_ENV['API_KEY'];
// $this->mangoPayApi->Config->TemporaryFolder = '/some/path/';
$this->mangoPayApi->OAuthTokenManager->RegisterCustomStorageStrategy(new MockStorageStrategy());
//$this->mangoPayApi->Config->BaseUrl = 'https://api.sandbox.mangopay.com';
}
public function createProfilMango($form)
{
$userMango = $this->client->request(
'POST',
'https://api.sandbox.mangopay.com/v2.01/' . '%env(CLIENT_ID)%' . '/users/natural',
[
$UserNatural = new MangoPay\UserNatural(),
$UserNatural->FirstName = $form['firstname']->getData(),
$UserNatural->LastName = $form['lastname']->getData(),
$UserNatural->Email = $form['email']->getData(),
$UserNatural->Address = new \MangoPay\Address(),
$UserNatural->Address->AddressLine1 = $form['streetNumber']->getData() . $form['address']->getData(),
$UserNatural->Address->AddressLine2 = "",
$UserNatural->Address->City = $form['city']->getData(),
$UserNatural->Address->Region = "",
$UserNatural->Address->PostalCode = $form['zipCode']->getData(),
$UserNatural->Address->Country = "FR",
$UserNatural->Birthday = $form['birthday']->getData(),
$UserNatural->Nationality = $form['nationality']->getData(),
$UserNatural->CountryOfResidence = "FR",
$Result = $this->mangoPayApi->Users->Create($UserNatural),
]
);
return $userMango;
}
}
The namespace has been checked and it is correct, concerning the dependencies the http-client and mangopay/php-sdk-v2 have been installed.
Using classes from a
Testnamespace are sometimes not added to the autoloader - as you should not use them in your application. A look at that package'scomposer.jsonshows this: the namespaceMangoPayis routed to the folderMangoPay(seeautoloadfor this), while the class you want to use is stored in another folder and loaded only throughautoload-dev. This section is not evaluated in case you are solely using this package in your own application.If you really want to use that class
MockStorageStrategy(which is only provided for the package's internal test suite, not for being used by the application!), you should copy it to your own application namespace.