The license key should be added successfully.
/opt/matomo/console marketplace:set-license-key --license-key=xxxx
ERROR [2022-05-16 12:17:22] 1842135 Uncaught exception: Error: Class 'Piwik\Plugins\Marketplace\Api' not found in /opt/matomo/plugins/Marketplace/Commands/SetLicenseKey.php:40
Stack trace:
<a href='/0'>#0</a> /opt/matomo/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(257): Piwik\Plugins\Marketplace\Commands\SetLicenseKey->execute()
<a href='/1'>#1</a> /opt/matomo/vendor/symfony/console/Symfony/Component/Console/Application.php(874): Symfony\Component\Console\Command\Command->run()
<a href='/2'>#2</a> /opt/matomo/vendor/symfony/console/Symfony/Component/Console/Application.php(195): Symfony\Component\Console\Application->doRunCommand()
<a href='/3'>#3</a> [internal function]: Symfony\Component\Console\Application->doRun()
<a href='/4'>#4</a> /opt/matomo/core/Console.php(135): call_user_func()
<a href='/5'>#5</a> /opt/matomo/core/Access.php(670): Piwik\Console->Piwik\{closure}()
<a href='/6'>#6</a> /opt/matomo/core/Console.php(136): Piwik\Access::doAsSuperUser()
<a href='/7'>#7</a> /opt/matomo/core/Console.php(87): Piwik\Console->doRunImpl()
<a href='/8'>#8</a> /opt/matomo/vendor/symfony/console/Symfony/Component/Console/Application.php(126): Piwik\Console->doRun()
<a href='/9'>#9</a> /opt/matomo/console(32): Symfony\Component\Console\Application->run()
<a href='/10'>#10</a> {main}
Uncaught exception in /opt/matomo/plugins/Marketplace/Commands/SetLicenseKey.php line 40:
Class 'Piwik\Plugins\Marketplace\Api' not found
/path/to/console marketplace:set-license-key --license-key=xxxx
Unable to add license key, so cannot add addons that we've paid for.
Looks like it was fixed in 4.10 https://github.com/matomo-org/matomo/pull/19118, we'll just upgrade.