<?xml version="1.0" ?>

<container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		   xmlns="http://symfony.com/schema/dic/services"
		   xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

	<services>
		<!-- Commands -->
		<service id="VRPaymentPayment\Core\Api\WebHooks\Command\WebHooksCommand">
			<argument type="service" id="VRPaymentPayment\Core\Api\WebHooks\Service\WebHooksService"/>
			<tag name="console.command"/>
		</service>

		<!-- Controllers -->
		<service id="VRPaymentPayment\Core\Api\WebHooks\Controller\WebHookController" public="true">
			<argument type="service" id="Doctrine\DBAL\Connection"/>
			<argument type="service" id="Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStateHandler"/>
			<argument type="service" id="Shopware\Core\Checkout\Order\SalesChannel\OrderService"/>
			<argument type="service" id="VRPaymentPayment\Core\Api\PaymentMethodConfiguration\Service\PaymentMethodConfigurationService"/>
			<argument type="service" id="VRPaymentPayment\Core\Api\Refund\Service\RefundService"/>
			<argument type="service" id="VRPaymentPayment\Core\Api\Transaction\Service\OrderMailService"/>
			<argument type="service" id="VRPaymentPayment\Core\Api\Transaction\Service\TransactionService"/>
			<argument type="service" id="VRPaymentPayment\Core\Settings\Service\SettingsService"/>
			<argument type="service" id="VRPaymentPayment\Core\Api\WebHooks\Strategy\WebHookStrategyManager"/>
			<call method="setLogger">
				<argument type="service" id="monolog.logger.vrpayment_payment"/>
			</call>
			<call method="setContainer">
				<argument type="service" id="service_container"/>
			</call>
		</service>

		<!-- Services -->
		<service id="VRPaymentPayment\Core\Api\WebHooks\Service\WebHooksService" public="true">
			<argument type="service" id="VRPaymentPayment\Core\Settings\Service\SettingsService"/>
			<argument type="service" id="router.default"/>
			<call method="setLogger">
				<argument type="service" id="monolog.logger.vrpayment_payment"/>
			</call>
		</service>

        <!-- Strategies
        Initializes the list of strategies for handling different types of webhook events.
        Each strategy corresponds to a specific type of webhook event, ensuring that the appropriate
        processing logic is applied based on the type of the incoming webhook request.
        -->
        <service id="VRPaymentPayment\Core\Api\WebHooks\Strategy\WebHookStrategyManager" public="true">
            <argument type="tagged_iterator" tag="vrpayment.webhook.strategy" />
            <argument type="service" id="monolog.logger.vrpayment_payment"/>
        </service>

        <service id="VRPaymentPayment\Core\Api\WebHooks\Strategy\WebHookStrategyBase" abstract="true">
            <argument type="service" id="Doctrine\DBAL\Connection"/>
            <argument type="service" id="Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStateHandler"/>
            <argument type="service" id="Shopware\Core\Checkout\Order\SalesChannel\OrderService"/>
            <argument type="service" id="VRPaymentPayment\Core\Api\PaymentMethodConfiguration\Service\PaymentMethodConfigurationService"/>
            <argument type="service" id="VRPaymentPayment\Core\Api\Refund\Service\RefundService"/>
            <argument type="service" id="VRPaymentPayment\Core\Api\Transaction\Service\OrderMailService"/>
            <argument type="service" id="VRPaymentPayment\Core\Api\Transaction\Service\TransactionService"/>
            <argument type="service" id="VRPaymentPayment\Core\Settings\Service\SettingsService"/>
            <argument type="service" id="service_container"/>
            <argument type="service" id="monolog.logger.vrpayment_payment"/>
        </service>

        <!-- extends the VRPaymentPayment\Core\Api\WebHooks\Strategy\WebHookStrategyBase strategy -->
        <service id="VRPaymentPayment\Core\Api\WebHooks\Strategy\WebHookTransactionStrategy"
                 parent="VRPaymentPayment\Core\Api\WebHooks\Strategy\WebHookStrategyBase" public="true">
            <tag name="vrpayment.webhook.strategy"/>
        </service>
        <service id="VRPaymentPayment\Core\Api\WebHooks\Strategy\WebHookTransactionInvoiceStrategy"
                 parent="VRPaymentPayment\Core\Api\WebHooks\Strategy\WebHookStrategyBase" public="true">
            <tag name="vrpayment.webhook.strategy"/>
        </service>
        <service id="VRPaymentPayment\Core\Api\WebHooks\Strategy\WebHookRefundStrategy"
                 parent="VRPaymentPayment\Core\Api\WebHooks\Strategy\WebHookStrategyBase" public="true">
            <tag name="vrpayment.webhook.strategy"/>
        </service>
        <service id="VRPaymentPayment\Core\Api\WebHooks\Strategy\WebHookPaymentMethodConfigurationStrategy"
                 parent="VRPaymentPayment\Core\Api\WebHooks\Strategy\WebHookStrategyBase" public="true">
            <tag name="vrpayment.webhook.strategy"/>
        </service>
    </services>

</container>
