services:
    oro_payment.payment_methods_configs_rule.manager.api:
        class: 'Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager'
        public: true
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\PaymentBundle\Entity\PaymentMethodsConfigsRule'
            - "@doctrine.orm.entity_manager"

    Oro\Bundle\PaymentBundle\Form\Handler\PaymentMethodsConfigsRuleHandler:
        alias: oro_payment.form.handler.payment_methods_configs_rule

    oro_payment.form.handler.payment_methods_configs_rule:
        class: 'Oro\Bundle\PaymentBundle\Form\Handler\PaymentMethodsConfigsRuleHandler'
        public: true
        arguments:
            - '@request_stack'
            - '@doctrine.orm.entity_manager'

    oro_payment.datagrid.payment_rule_actions_visibility_provider:
        parent: oro_rule.action.visibility_provider
        public: true

    oro_payment.formatter.payment_method_label:
        class: 'Oro\Bundle\PaymentBundle\Formatter\PaymentMethodLabelFormatter'
        arguments:
            - "@oro_payment.payment_method_view.composite_provider"

    oro_payment.formatter.payment_method_options:
        class: 'Oro\Bundle\PaymentBundle\Formatter\PaymentMethodOptionsFormatter'
        arguments:
            - '@oro_payment.payment_method_view.composite_provider'
            - '@event_dispatcher'

    oro_payment.twig.payment_extension:
        class: 'Oro\Bundle\PaymentBundle\Twig\PaymentExtension'
        arguments:
            - "@oro_platform.twig.service_locator"
        tags:
            - { name: twig.extension }

    oro_payment.extension.action.type.payment_delete:
        class: 'Oro\Bundle\PaymentBundle\Extension\Action\Actions\PaymentDeleteAction'
        shared: false
        tags:
            - { name: oro_datagrid.extension.action.type, type: payment-delete }

    oro_payment.provider.surcharge:
        class: 'Oro\Bundle\PaymentBundle\Provider\SurchargeProvider'
        public: false
        arguments:
            - '@event_dispatcher'

    oro_payment.method.provider.applicable_methods_provider:
        class: 'Oro\Bundle\PaymentBundle\Method\Provider\ApplicablePaymentMethodsProvider'
        arguments:
            - '@oro_payment.payment_method.composite_provider'
            - '@oro_payment.provider.methods_configs_rules.by_context.basic'
        calls:
            - [setMemoryCacheProvider, ['@oro_payment.method.provider.applicable_methods_provider.cache']]

    oro_payment.method.provider.applicable_methods_provider.cache:
        parent: oro.cache.provider.memory_cache

    oro_payment.methods_provider.cache:
        parent: oro.cache.adapter.array
        tags:
            - { name: 'cache.pool', namespace: 'payment_methods_provider_cache' }

    oro_payment.provider.methods_provider:
        class: 'Oro\Bundle\PaymentBundle\Layout\DataProvider\PaymentMethodViewsProvider'
        arguments:
            - '@oro_payment.payment_method_view.composite_provider'
            - '@oro_payment.method.provider.applicable_methods_provider'
            - '@oro_payment.provider.payment_transaction'
            - '@oro_payment.methods_provider.cache'
        tags:
            - { name: layout.data_provider, alias: oro_payment_method_views_provider }

    oro_payment.provider.method_widget_provider:
        class: 'Oro\Bundle\PaymentBundle\Layout\DataProvider\PaymentMethodWidgetProvider'
        arguments:
            - '@oro_payment.payment_method_view.composite_provider'
        tags:
            - { name: layout.data_provider, alias: oro_payment_method_widget_provider }

    Oro\Bundle\PaymentBundle\Event\CallbackHandler:
        alias: oro_payment.event.callback_handler

    oro_payment.event.callback_handler:
        class: 'Oro\Bundle\PaymentBundle\Event\CallbackHandler'
        public: true
        lazy: true
        arguments:
            - '@event_dispatcher'
            - '@oro_payment.provider.payment_transaction'

    oro_payment.provider.payment_transaction:
        class: 'Oro\Bundle\PaymentBundle\Provider\PaymentTransactionProvider'
        public: true
        arguments:
            - '@oro_api.doctrine_helper'
            - '@oro_customer.security.customer_user_provider'
            - '@event_dispatcher'
            - 'Oro\Bundle\PaymentBundle\Entity\PaymentTransaction'
        calls:
            - ['setLogger', ['@logger']]

    oro_payment.provider.payment_status:
        class: 'Oro\Bundle\PaymentBundle\Provider\PaymentStatusProvider'
        public: true
        arguments:
            - '@oro_payment.provider.payment_transaction'
            - '@oro_pricing.subtotal_processor.total_processor_provider'

    oro_payment.action.payment_method_action.abstract:
        abstract: true
        arguments:
            - '@oro_action.expression.context_accessor'
            - '@oro_payment.payment_method.composite_provider'
            - '@oro_payment.provider.payment_transaction'
            - '@router'
        calls:
            - ['setLogger', ['@logger']]

    oro_payment.action.capture_payment_transaction:
        class: 'Oro\Bundle\PaymentBundle\Action\PaymentTransactionCaptureAction'
        parent: oro_payment.action.payment_method_action.abstract
        tags:
            - { name: oro_action.action, alias: payment_transaction_capture }

    oro_payment.action.purchase:
        class: 'Oro\Bundle\PaymentBundle\Action\PurchaseAction'
        parent: oro_payment.action.payment_method_action.abstract
        calls:
            - ['setPaymentStatusProvider', ['@oro_payment.provider.payment_status']]
        tags:
            - { name: oro_action.action, alias: payment_purchase }

    oro_payment.action.validate:
        class: 'Oro\Bundle\PaymentBundle\Action\ValidateAction'
        parent: oro_payment.action.payment_method_action.abstract
        tags:
            - { name: oro_action.action, alias: payment_validate }

    oro_payment.event_listener.callback.redirect:
        class: 'Oro\Bundle\PaymentBundle\EventListener\Callback\RedirectListener'
        lazy: true
        arguments:
            - '@session'
            - '@oro_payment.provider.result_messages'
        tags:
            - { name: kernel.event_listener, event: oro_payment.callback.return, method: onReturn, priority: 10 }
            - { name: kernel.event_listener, event: oro_payment.callback.error, method: onError, priority: 10 }

    oro_payment.condition.payment_method_applicable:
        class: 'Oro\Bundle\PaymentBundle\Condition\PaymentMethodApplicable'
        arguments:
            - '@oro_payment.method.provider.applicable_methods_provider'
        tags:
            - { name: oro_action.condition, alias: 'payment_method_applicable' }

    oro_payment.condition.has_applicable_payment_methods:
        class: 'Oro\Bundle\PaymentBundle\Condition\HasApplicablePaymentMethods'
        arguments:
            - '@oro_payment.method.provider.applicable_methods_provider'
        tags:
            - { name: oro_action.condition, alias: 'has_applicable_payment_methods' }

    oro_payment.condition.payment_transaction_was_charged:
        class: 'Oro\Bundle\PaymentBundle\Condition\PaymentTransactionWasCharged'
        arguments:
            - '@oro_payment.repository.payment_transaction'
        tags:
            - { name: oro_action.condition, alias: 'payment_transaction_was_charged' }

    oro_payment.provider.address_extractor:
        class: 'Oro\Bundle\PaymentBundle\Provider\AddressExtractor'
        public: false
        arguments:
            - '@property_accessor'

    oro_payment.condition.payment_method_supports:
        class: 'Oro\Bundle\PaymentBundle\Condition\PaymentMethodSupports'
        arguments:
            - '@oro_payment.payment_method.composite_provider'
        tags:
            - { name: oro_action.condition, alias: 'payment_method_supports' }

    oro_payment.listener.payment_transaction_listener:
        class: 'Oro\Bundle\PaymentBundle\EventListener\PaymentTransactionListener'
        arguments:
            - '@oro_payment.manager.payment_status'
        tags:
            - { name: kernel.event_listener, event: oro_payment.event.transaction_complete, method: onTransactionComplete }

    oro_payment.manager.payment_status:
        class: 'Oro\Bundle\PaymentBundle\Manager\PaymentStatusManager'
        arguments:
            - '@oro_payment.provider.payment_status'
            - '@oro_entity.doctrine_helper'
            - '@oro_payment.provider.payment_transaction'

    oro_payment.formatter.payment_status_label:
        class: 'Oro\Bundle\PaymentBundle\Formatter\PaymentStatusLabelFormatter'
        public: true
        arguments:
            - "@translator"

    oro_payment.condition.require_payment_redirect:
        class: 'Oro\Bundle\PaymentBundle\Condition\RequirePaymentRedirect'
        arguments:
            - '@oro_payment.payment_method.composite_provider'
            - '@event_dispatcher'
        tags:
            - { name: oro_action.condition, alias: 'require_payment_redirect' }

    oro_payment.payment_method.composite_provider:
        class: 'Oro\Bundle\PaymentBundle\Method\Provider\CompositePaymentMethodProvider'
        public: true
        arguments:
            - !tagged_iterator oro_payment.payment_method_provider

    oro_payment.payment_method_view.composite_provider:
        class: 'Oro\Bundle\PaymentBundle\Method\View\CompositePaymentMethodViewProvider'
        public: true
        arguments:
            - !tagged_iterator oro_payment.payment_method_view_provider

    oro_payment.context.doctrine_line_item_collection_factory:
        class: 'Oro\Bundle\PaymentBundle\Context\LineItem\Collection\Doctrine\Factory\DoctrinePaymentLineItemCollectionFactory'
        deprecated: '%service_id% is deprecated since 5.1'

    oro_payment.context.builder_factory_basic:
        class: 'Oro\Bundle\PaymentBundle\Context\Builder\Basic\Factory\BasicPaymentContextBuilderFactory'
        arguments:
            - '@oro_payment.context.doctrine_line_item_collection_factory'

    oro_payment.line_item.builder_factory_basic:
        class: 'Oro\Bundle\PaymentBundle\Context\LineItem\Builder\Basic\Factory\BasicPaymentLineItemBuilderFactory'
        deprecated: '%service_id% is deprecated since 5.1'
        calls:
            - ['setPaymentKitItemLineItemFactory', ['@oro_payment.context.line_item.factory.payment_kit_item_line_item_from_product_kit_item_line_item_factory']]

    oro_payment.context.rules_converter_basic:
        class: 'Oro\Bundle\PaymentBundle\Context\Converter\Basic\BasicPaymentContextToRulesValueConverter'
        arguments:
            - '@oro_payment.expression_language.decorated_product_line_item_factory'

    oro_payment.repository.payment_methods_configs_rule:
        alias: Oro\Bundle\PaymentBundle\Entity\Repository\PaymentMethodsConfigsRuleRepository

    Oro\Bundle\PaymentBundle\Entity\Repository\PaymentMethodsConfigsRuleRepository:
        parent: oro_entity.abstract_repository
        arguments:
            - 'Oro\Bundle\PaymentBundle\Entity\PaymentMethodsConfigsRule'
        calls:
            - [setAclHelper, ['@oro_security.acl_helper']]
        tags:
            - { name: doctrine.repository_service }

    oro_payment.repository.payment_method_config:
        alias: Oro\Bundle\PaymentBundle\Entity\Repository\PaymentMethodConfigRepository

    Oro\Bundle\PaymentBundle\Entity\Repository\PaymentMethodConfigRepository:
        parent: oro_entity.abstract_repository
        arguments:
            - 'Oro\Bundle\PaymentBundle\Entity\PaymentMethodConfig'
        tags:
            - { name: doctrine.repository_service }

    oro_payment.repository.payment_transaction:
        alias: Oro\Bundle\PaymentBundle\Entity\Repository\PaymentTransactionRepository

    Oro\Bundle\PaymentBundle\Entity\Repository\PaymentTransactionRepository:
        parent: oro_entity.abstract_repository
        arguments:
            - 'Oro\Bundle\PaymentBundle\Entity\PaymentTransaction'
        tags:
            - { name: doctrine.repository_service }

    oro_payment.expression_language.decorated_product_line_item_factory:
        class: 'Oro\Bundle\PaymentBundle\ExpressionLanguage\DecoratedProductLineItemFactory'
        arguments:
            - '@oro_product.virtual_fields.decorator_factory'

    oro_payment.method.event_listener.method_renaming:
        class: 'Oro\Bundle\PaymentBundle\Method\EventListener\MethodRenamingListener'
        arguments:
            - '@oro_payment.repository.payment_method_config'
            - '@oro_payment.repository.payment_transaction'
        tags:
            - { name: kernel.event_listener, event: oro_payment.method_renaming, method: onMethodRename}

    oro_payment.method.event.dispatcher.method_renaming:
        class: 'Oro\Bundle\PaymentBundle\Method\Event\BasicMethodRenamingEventDispatcher'
        public: true
        arguments:
            - '@event_dispatcher'

    oro_payment.provider.result_messages:
        class: 'Oro\Bundle\PaymentBundle\Provider\DefaultPaymentResultMessageProvider'
        public: false

    oro_payment.context.factory.composite_supports_entity:
        class: 'Oro\Bundle\PaymentBundle\Context\Factory\CompositeSupportsEntityPaymentContextFactory'
        public: false
        arguments:
            - !tagged_iterator oro_payment.supports_entity_payment_context_factory

    oro_payment.context.factory.transaction_payment_context:
        class: 'Oro\Bundle\PaymentBundle\Context\Factory\TransactionPaymentContextFactory'
        arguments:
            - '@oro_payment.context.factory.composite_supports_entity'

    oro_payment.rule_filtration.basic_service:
        class: 'Oro\Bundle\PaymentBundle\RuleFiltration\Basic\BasicMethodsConfigsRulesFiltrationService'
        arguments:
            - '@oro_rule.rule_filtration.service'
            - '@oro_payment.context.rules_converter_basic'

    oro_payment.provider.methods_configs_rules.by_context.basic:
        class: 'Oro\Bundle\PaymentBundle\Provider\MethodsConfigsRule\Context\Basic\BasicMethodsConfigsRulesByContextProvider'
        public: false
        arguments:
            - '@oro_payment.rule_filtration.basic_service'
            - '@doctrine'

    oro_payment.enabled_rule_filtration.basic_service:
        class: 'Oro\Bundle\PaymentBundle\RuleFiltration\Basic\BasicMethodsConfigsRulesFiltrationService'
        arguments:
            - '@oro_rule.enabled_rule_filtration.service'
            - '@oro_payment.context.rules_converter_basic'

    oro_payment.provider.methods_configs_rules.by_context_required_parameters:
        class: 'Oro\Bundle\PaymentBundle\Provider\MethodsConfigsRule\Context\RegardlessDestination\RegardlessDestinationMethodsConfigsRulesByContextProvider'
        public: false
        arguments:
            - '@oro_payment.enabled_rule_filtration.basic_service'
            - '@doctrine'

    oro_payment.provider.payment_method_object_variables:
        class: 'Oro\Bundle\PaymentBundle\Provider\PaymentMethodObjectVariablesProvider'
        public: false
        tags:
            - { name: oro_email.emailtemplate.variable_provider, scope: entity }

    oro_payment.event_listener.payment_transaction_owner:
        class: 'Oro\Bundle\PaymentBundle\EventListener\PaymentTransactionOwnerListener'
        public: false
        arguments:
            - '@oro_security.token_accessor'
        tags:
            - { name: doctrine.orm.entity_listener, entity: 'Oro\Bundle\PaymentBundle\Entity\PaymentTransaction', event: prePersist }

    oro_payment.provider.payment_order_line_item_options:
        class: 'Oro\Bundle\PaymentBundle\Provider\PaymentOrderLineItemOptionsProvider'
        public: false
        arguments:
            - '@oro_ui.html_tag_helper'
            - '@oro_locale.provider.current_localization'

    oro_payment.provider.payment_order_shipping_address_options:
        class: 'Oro\Bundle\PaymentBundle\Provider\PaymentOrderShippingAddressOptionsProvider'
        public: false

    oro_payment.action.cancel_payment_transaction:
        class: 'Oro\Bundle\PaymentBundle\Action\PaymentTransactionCancelAction'
        parent: oro_payment.action.payment_method_action.abstract
        tags:
            - { name: oro_action.action, alias: payment_transaction_cancel }

    oro_payment.action.refund_payment_transaction:
        class: 'Oro\Bundle\PaymentBundle\Action\PaymentTransactionRefundAction'
        parent: oro_payment.action.payment_method_action.abstract
        tags:
            - { name: oro_action.action, alias: payment_transaction_refund }

    oro_payment.condition.payment_transaction_was_canceled:
        class: 'Oro\Bundle\PaymentBundle\Condition\PaymentTransactionWasCanceled'
        arguments:
            - '@oro_payment.repository.payment_transaction'
        tags:
            - { name: oro_action.condition, alias: 'payment_transaction_was_canceled' }

    oro_payment.condition.payment_transaction_was_refunded:
        class: 'Oro\Bundle\PaymentBundle\Condition\PaymentTransactionWasRefunded'
        arguments:
            - '@oro_payment.repository.payment_transaction'
        tags:
            - { name: oro_action.condition, alias: 'payment_transaction_was_refunded' }

    oro_payment.context.line_item.factory.payment_kit_item_line_item_from_product_kit_item_line_item_factory:
        class: Oro\Bundle\PaymentBundle\Context\LineItem\Factory\PaymentKitItemLineItemFromProductKitItemLineItemFactory
