Trying to decorate a PayPal service:
<service id="TestPlugin\Service\Client\PayPalClientFactory" decorates="Swag\PayPal\RestApi\Client\PayPalClientFactory">
<argument type="service" id="Swag\PayPal\RestApi\Client\CredentialsClientFactory.inner" />
</service>
but i get the following error notification when installing the TestPlugin:
The service "TestPlugin\Service\Client\PayPalClientFactory" has a dependency on a non-existent service "Swag\PayPal\RestApi\Client\CredentialsClientFactory.inner".
Did you mean one of these:
"Swag\PayPal\RestApi\Client\CredentialsClientFactory", "Swag\PayPal\RestApi\Client\TokenClientFactory"
Below is the decorating class:
<?php
namespace TestPlugin\Service\Client;
use Swag\PayPal\RestApi\Client\PayPalClientFactoryInterface;
use Swag\PayPal\RestApi\Client\PayPalClientInterface;
use Swag\PayPal\RestApi\PartnerAttributionId;
class PayPalClientFactory implements PayPalClientFactoryInterface
{
/**
* @var PayPalClientFactoryInterface
*/
private PayPalClientFactoryInterface $decoratedService;
/**
* @param PayPalClientFactoryInterface $decoratedService
*/
public function __construct(PayPalClientFactoryInterface $decoratedService)
{
$this->decoratedService = $decoratedService;
}
public function getDecorated(): PayPalClientFactoryInterface
{
return $this->decoratedService;
}
public function getPayPalClient(?string $salesChannelId, string $partnerAttributionId = PartnerAttributionId::PAYPAL_CLASSIC): PayPalClientInterface
{
return $this->getDecorated()->getPayPalClient($salesChannelId, $partnerAttributionId);
}
//...
}