services:
    oro_paypal.paypal.payflow.nvp_encoder:
        class: 'Oro\Bundle\PayPalBundle\PayPal\Payflow\NVP\Encoder'
        public: false

    oro_paypal.event_listener.callback.payflow:
        class: 'Oro\Bundle\PayPalBundle\EventListener\Callback\PayflowListener'
        lazy: true
        arguments:
            - '@session'
            - '@oro_payment.payment_method.registry'
        calls:
            - ['setLogger', ['@logger']]
        tags:
            - { name: kernel.event_listener, event: oro_payment.callback.error.payflow_gateway, method: onError }
            - { name: kernel.event_listener, event: oro_payment.callback.notify.payflow_gateway, method: onNotify }
            - { name: kernel.event_listener, event: oro_payment.callback.error.paypal_payments_pro, method: onError }
            - { name: kernel.event_listener, event: oro_payment.callback.notify.paypal_payments_pro, method: onNotify }

    oro_paypal.event_listener.callback.payflow_express_checkout:
        class: 'Oro\Bundle\PayPalBundle\EventListener\Callback\PayflowExpressCheckoutListener'
        lazy: true
        arguments:
            - '@oro_payment.payment_method.registry'
        calls:
            - ['setLogger', ['@logger']]
        tags:
            - { name: kernel.event_listener, event: oro_payment.callback.error.payflow_express_checkout, method: onError }
            - { name: kernel.event_listener, event: oro_payment.callback.return.payflow_express_checkout, method: onReturn }
            - { name: kernel.event_listener, event: oro_payment.callback.error.paypal_payments_pro_express_checkout, method: onError }
            - { name: kernel.event_listener, event: oro_payment.callback.return.paypal_payments_pro_express_checkout, method: onReturn }

    oro_paypal.event_listener.callback.payflow_express_checkout_redirect:
        class: 'Oro\Bundle\PayPalBundle\EventListener\Callback\PayflowExpressCheckoutRedirectListener'
        lazy: true
        arguments:
            - '@session'
        tags:
            # Priority of this listener should always be less then priority of oro_paypal.event_listener.callback.payflow_express_checkout
            - { name: kernel.event_listener, event: oro_payment.callback.return.payflow_express_checkout, method: onReturn, priority: -100 }
            - { name: kernel.event_listener, event: oro_payment.callback.return.paypal_payments_pro_express_checkout, method: onReturn, priority: -100 }

    oro_paypal.event_listener.ip_check.payflow:
        class: 'Oro\Bundle\PayPalBundle\EventListener\Callback\PayflowIPCheckListener'
        lazy: true
        arguments:
            - '@request_stack'
        tags:
            - { name: kernel.event_listener, event: oro_payment.callback.notify.payflow_gateway, method: onNotify, priority: 255 }
            - { name: kernel.event_listener, event: oro_payment.callback.notify.paypal_payments_pro, method: onNotify, priority: 255 }

    oro_paypal.paypal.payflow_gateway.request.registry:
        class: 'Oro\Bundle\PayPalBundle\PayPal\Payflow\Request\RequestRegistry'
        public: false
        calls:
            - ['addRequest', ['@oro_paypal.paypal.payflow_gateway.request.authorize']]
            - ['addRequest', ['@oro_paypal.paypal.payflow.request.delayed_capture']]
            - ['addRequest', ['@oro_paypal.paypal.payflow_gateway.request.sale']]
            - ['addRequest', ['@oro_paypal.paypal.payflow.request.void']]

    oro_paypal.paypal.payflow_gateway.request.authorize:
        class: 'Oro\Bundle\PayPalBundle\PayPal\Payflow\Gateway\Request\AuthorizationRequest'
        public: false

    oro_paypal.paypal.payflow_gateway.request.sale:
        class: 'Oro\Bundle\PayPalBundle\PayPal\Payflow\Gateway\Request\SaleRequest'
        public: false

    oro_paypal.paypal.payflow.request.delayed_capture:
        class: 'Oro\Bundle\PayPalBundle\PayPal\Payflow\Request\DelayedCaptureRequest'
        public: false

    oro_paypal.paypal.payflow.request.void:
        class: 'Oro\Bundle\PayPalBundle\PayPal\Payflow\Request\VoidRequest'
        public: false

    oro_paypal.paypal.payflow.processor.registry:
        class: 'Oro\Bundle\PayPalBundle\PayPal\Payflow\Processor\ProcessorRegistry'
        public: false
        calls:
            - ['addProcessor', ['@oro_paypal.paypal.payflow.processor.paypal']]

    oro_paypal.paypal.payflow.processor.paypal:
        class: 'Oro\Bundle\PayPalBundle\PayPal\Payflow\Processor\PayPal'
        public: false

    oro_paypal.paypal.payflow_gateway.gateway:
        class: 'Oro\Bundle\PayPalBundle\PayPal\Payflow\Gateway'
        public: false
        scope: prototype
        arguments:
            - '@oro_paypal.paypal.payflow.client.nvp'
            - '@oro_paypal.paypal.payflow_gateway.request.registry'
            - '@oro_paypal.paypal.payflow.processor.registry'

    oro_paypal.paypal.payflow_express_checkout.request.registry:
        class: 'Oro\Bundle\PayPalBundle\PayPal\Payflow\Request\RequestRegistry'
        public: false
        calls:
            - ['addRequest', ['@oro_paypal.paypal.payflow_express_checkout.request.authorize']]
            - ['addRequest', ['@oro_paypal.paypal.payflow_express_checkout.request.sale']]
            - ['addRequest', ['@oro_paypal.paypal.payflow.request.delayed_capture']]

    oro_paypal.paypal.payflow_express_checkout.request.authorize:
        class: 'Oro\Bundle\PayPalBundle\PayPal\Payflow\ExpressCheckout\Request\AuthorizationRequest'
        public: false

    oro_paypal.paypal.payflow_express_checkout.request.sale:
        class: 'Oro\Bundle\PayPalBundle\PayPal\Payflow\ExpressCheckout\Request\SaleRequest'
        public: false

    oro_paypal.paypal.payflow_express_checkout.gateway:
        class: 'Oro\Bundle\PayPalBundle\PayPal\Payflow\Gateway'
        public: false
        scope: prototype
        arguments:
            - '@oro_paypal.paypal.payflow.client.nvp'
            - '@oro_paypal.paypal.payflow_express_checkout.request.registry'
            - '@oro_paypal.paypal.payflow.processor.registry'

    oro_paypal.paypal.payflow.client.nvp:
        class: 'Oro\Bundle\PayPalBundle\PayPal\Payflow\Client\NVPClient'
        public: false
        arguments:
            - '@oro_paypal.paypal.payflow.client.http'
            - '@oro_paypal.paypal.payflow.nvp_encoder'

    oro_paypal.paypal.payflow.client.http:
        class: 'Guzzle\Http\Client'
        public: false
        lazy: true
