<?xml version="1.0" encoding="UTF-8"?>

<!--

 This file is part of the Sylius package.

 (c) Sylius Sp. z o.o.

 For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.

-->

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
    <parameters>
        <parameter key="sylius.order_payment_processor.checkout.unsupported_states" type="collection">
            <parameter type="constant">Sylius\Component\Order\Model\OrderInterface::STATE_CANCELLED</parameter>
            <parameter type="constant">Sylius\Component\Order\Model\OrderInterface::STATE_FULFILLED</parameter>
        </parameter>
        <parameter key="sylius.order_payment_processor.after_checkout.unsupported_states" type="collection">
            <parameter type="constant">Sylius\Component\Order\Model\OrderInterface::STATE_CANCELLED</parameter>
            <parameter type="constant">Sylius\Component\Order\Model\OrderInterface::STATE_FULFILLED</parameter>
        </parameter>
    </parameters>
    <services>
        <defaults public="true" />

        <service id="sylius.order_processing.order_adjustments_clearer" class="Sylius\Component\Core\OrderProcessing\OrderAdjustmentsClearer">
            <argument type="collection">
                <argument type="constant">Sylius\Component\Core\Model\AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT</argument>
                <argument type="constant">Sylius\Component\Core\Model\AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT</argument>
                <argument type="constant">Sylius\Component\Core\Model\AdjustmentInterface::ORDER_SHIPPING_PROMOTION_ADJUSTMENT</argument>
                <argument type="constant">Sylius\Component\Core\Model\AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT</argument>
                <argument type="constant">Sylius\Component\Core\Model\AdjustmentInterface::SHIPPING_ADJUSTMENT</argument>
                <argument type="constant">Sylius\Component\Core\Model\AdjustmentInterface::TAX_ADJUSTMENT</argument>
            </argument>
            <tag name="sylius.order_processor" priority="60"/>
        </service>

        <service id="sylius.order_processing.order_prices_recalculator" class="Sylius\Component\Core\OrderProcessing\OrderPricesRecalculator">
            <argument type="service" id="sylius.calculator.product_variant_price" />
            <tag name="sylius.order_processor" priority="50"/>
        </service>

        <service id="sylius.order_processing.order_shipment_processor" class="Sylius\Component\Core\OrderProcessing\OrderShipmentProcessor">
            <argument type="service" id="sylius.shipping_method_resolver.default" />
            <argument type="service" id="sylius.factory.shipment" />
            <argument type="service" id="sylius.shipping_methods_resolver" />
            <tag name="sylius.order_processor" priority="40"/>
        </service>

        <service id="sylius.order_processing.shipping_charges_processor" class="Sylius\Component\Core\OrderProcessing\ShippingChargesProcessor">
            <argument type="service" id="sylius.factory.adjustment" />
            <argument type="service" id="sylius.shipping_calculator" />
            <tag name="sylius.order_processor" priority="30"/>
        </service>

        <service id="sylius.order_processing.order_promotion_processor" class="Sylius\Component\Core\OrderProcessing\OrderPromotionProcessor">
            <argument type="service" id="sylius.promotion_processor" />
            <tag name="sylius.order_processor" priority="20"/>
        </service>

        <service id="sylius.order_processing.order_taxes_processor" class="Sylius\Component\Core\OrderProcessing\OrderTaxesProcessor">
            <argument type="service" id="sylius.provider.channel_based_default_zone_provider" />
            <argument type="service" id="sylius.zone_matcher" />
            <argument type="service" id="sylius.registry.tax_calculation_strategy" />
            <argument type="service" id="sylius.taxation_address_resolver" />
            <tag name="sylius.order_processor" priority="10"/>
        </service>

        <service id="sylius.order_processing.order_payment_processor.checkout" class="Sylius\Component\Core\OrderProcessing\OrderPaymentProcessor">
            <argument type="service" id="sylius.order_payment_provider" />
            <argument>cart</argument>
            <argument type="service" id="Sylius\Component\Core\Payment\Remover\OrderPaymentsRemoverInterface" />
            <argument>%sylius.order_payment_processor.checkout.unsupported_states%</argument>
            <tag name="sylius.order_processor" priority="0"/>
        </service>
        <service id="sylius.order_processing.order_payment_processor.after_checkout" class="Sylius\Component\Core\OrderProcessing\OrderPaymentProcessor">
            <argument type="service" id="sylius.order_payment_provider" />
            <argument>new</argument>
            <argument type="service" id="Sylius\Component\Core\Payment\Remover\OrderPaymentsRemoverInterface" />
            <argument>%sylius.order_payment_processor.after_checkout.unsupported_states%</argument>
        </service>
    </services>
</container>
