<?xml version="1.0"?>
<!--
/**
 * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Amazon\Core\Client\ClientFactoryInterface" type="Amazon\Core\Client\ClientFactory" />
    <preference for="Amazon\Core\Api\Data\AmazonNameInterface" type="Amazon\Core\Domain\AmazonName" />
    <preference for="Amazon\Core\Api\Data\AmazonCustomerInterface" type="Amazon\Core\Domain\AmazonCustomer" />
    <preference for="Amazon\Core\Api\Data\AmazonAddressInterface" type="Amazon\Core\Domain\AmazonAddress" />
    <preference for="AmazonPay\ClientInterface" type="Amazon\Core\Client\Client" />
    <type name="Amazon\Core\Client\Client">
        <arguments>
            <argument name="config" xsi:type="array" />
        </arguments>
    </type>
    <type name="Amazon\Core\Helper\Data">
        <arguments>
            <argument name="storeManager" xsi:type="object">Magento\Store\Model\StoreManagerInterface\Proxy</argument>
            <argument name="clientIpHelper" xsi:type="object">Amazon\Core\Helper\ClientIp\Proxy</argument>
        </arguments>
    </type>
    <type name="Amazon\Core\Domain\AmazonNameFactory">
        <arguments>
            <argument name="nameDecoratorPool" xsi:type="array">
                <item name="JP" xsi:type="string">Amazon\Core\Domain\AmazonNameDecoratorJp</item>
            </argument>
        </arguments>
    </type>
    <type name="Amazon\Core\Domain\AmazonAddressFactory">
        <arguments>
            <argument name="addressDecoratorPool" xsi:type="array">
                <item name="DE" xsi:type="string">Amazon\Core\Domain\AmazonAddressDecoratorDe</item>
                <item name="AT" xsi:type="string">Amazon\Core\Domain\AmazonAddressDecoratorDe</item>
                <item name="JP" xsi:type="string">Amazon\Core\Domain\AmazonAddressDecoratorJp</item>
            </argument>
        </arguments>
    </type>
    <virtualType name="Amazon_Core_RemoteAddressWithAdditionalIpHeaders" type="Magento\Framework\HTTP\PhpEnvironment\RemoteAddress">
        <arguments>
            <argument name="alternativeHeaders" xsi:type="array">
                <item name="x-forwarded-for" xsi:type="string">HTTP_X_FORWARDED_FOR</item>
                <item name="x-real-ip" xsi:type="string">HTTP_X_REAL_IP</item>
            </argument>
        </arguments>
    </virtualType>
    <type name="Amazon\Core\Helper\ClientIp">
        <arguments>
            <argument name="remoteAddress" xsi:type="object">Amazon_Core_RemoteAddressWithAdditionalIpHeaders</argument>
        </arguments>
    </type>
    <type name="Amazon\Core\Logger\Logger">
        <arguments>
            <argument name="name" xsi:type="string">amazonClientLogger</argument>
            <argument name="handlers" xsi:type="array">
                <item name="debug" xsi:type="object">Amazon\Core\Logger\Handler\Client</item>
            </argument>
        </arguments>
    </type>
    <type name="Amazon\Core\Client\ClientFactory">
        <arguments>
            <argument name="logger" xsi:type="object">Amazon\Core\Logger\Logger</argument>
        </arguments>
    </type>
    <type name="Amazon\Core\Helper\CategoryExclusion">
        <arguments>
            <argument name="checkoutSession" xsi:type="object">Magento\Checkout\Model\Session\Proxy</argument>
        </arguments>
    </type>
    <type name="Magento\Checkout\CustomerData\Cart">
        <plugin name="amazon_core_cart_section" type="Amazon\Core\Plugin\CartSection" />
    </type>
    <type name="Magento\Config\Model\Config\TypePool">
        <arguments>
            <argument name="sensitive" xsi:type="array">
                <item name="payment/amazon_payments/simplepath/privatekey" xsi:type="string">1</item>
                <item name="payment/amazon_payment/client_secret" xsi:type="string">1</item>
                <item name="payment/amazon_payment/secret_key" xsi:type="string">1</item>
                <item name="payment/amazon_payment/credentials_json" xsi:type="string">1</item>
            </argument>
            <argument name="environment" xsi:type="array">
                <item name="payment/amazon_payments/simplepath/publickey" xsi:type="string">1</item>
                <item name="payment/amazon_payments/simplepath/privatekey" xsi:type="string">1</item>
                <item name="payment/amazon_payment/merchant_id" xsi:type="string">1</item>
                <item name="payment/amazon_payment/client_id" xsi:type="string">1</item>
                <item name="payment/amazon_payment/client_secret" xsi:type="string">1</item>
                <item name="payment/amazon_payment/access_key" xsi:type="string">1</item>
                <item name="payment/amazon_payment/secret_key" xsi:type="string">1</item>
                <item name="payment/amazon_payment/sandbox" xsi:type="string">1</item>
            </argument>
        </arguments>
    </type>
</config>
