<commit_before><?php
/**
 * Copyright © 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.
 */

namespace Amazon\Pay\Model\Adapter;

use Amazon\Pay\Model\Config\Source\PaymentAction;
use Magento\Quote\Model\Quote;

class AmazonPayAdapter
{
    const PAYMENT_INTENT_CONFIRM = 'Confirm';
    const PAYMENT_INTENT_AUTHORIZE = 'Authorize';
    const PAYMENT_INTENT_AUTHORIZE_WITH_CAPTURE = 'AuthorizeWithCapture';

    /**
     * @var \Amazon\Pay\Client\ClientFactoryInterface
     */
    private $clientFactory;

    /**
     * @var \Amazon\Pay\Model\AmazonConfig
     */
    private $amazonConfig;

    /**
     * @var \Magento\Store\Model\StoreManagerInterface
     */
    private $storeManager;

    /**
     * @var \Magento\Quote\Api\CartRepositoryInterface
     */
    private $quoteRepository;

    /**
     * @var \Amazon\Pay\Helper\Data
     */
    private $amazonHelper;

    /**
     * @var \Amazon\Pay\Logger\Logger
     */
    private $logger;

    /**
     * @var \Magento\Framework\UrlInterface
     */
    private $url;

    /**
     * @var \Magento\Framework\App\Response\RedirectInterface
     */
    private $redirect;

    /**
     * AmazonPayAdapter constructor.
     * @param \Amazon\Pay\Client\ClientFactoryInterface $clientFactory
     * @param \Amazon\Pay\Model\AmazonConfig $amazonConfig
     * @param \Magento\Store\Model\StoreManagerInterface $storeManager
     * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
     * @param \Amazon\Pay\Helper\Data $amazonHelper
     * @param \Amazon\Pay\Logger\Logger $logger
     * @param \Magento\Framework\UrlInterface $url
     * @param \Magento\Framework\App\Response\RedirectInterface $redirect
     */
    public function __construct(
        \Amazon\Pay\Client\ClientFactoryInterface $clientFactory,
        \Amazon\Pay\Model\AmazonConfig $amazonConfig,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
        \Amazon\Pay\Helper\Data $amazonHelper,
        \Amazon\Pay\Logger\Logger $logger,
        \Magento\Framework\UrlInterface $url,
        \Magento\Framework\App\Response\RedirectInterface $redirect
    ) {
        $this->clientFactory = $clientFactory;
        $this->amazonConfig = $amazonConfig;
        $this->storeManager = $storeManager;
        $this->quoteRepository = $quoteRepository;
        $this->amazonHelper = $amazonHelper;
        $this->logger = $logger;
        $this->url = $url;
        $this->redirect = $redirect;
    }

    /**
     * @return string
     */
    protected function getMerchantCustomInformation()
    {
        return sprintf('Magento Version: 2, Plugin Version: %s', $this->amazonHelper->getModuleVersion('Amazon_Pay'));
    }

    /**
     * @param mixed $amount
     * @param string $currencyCode
     * @return array
     */
    protected function createPrice($amount, $currencyCode)
    {
        switch ($currencyCode) {
            case 'JPY':
                $amount = round($amount);
                break;<commit_msg>ASD-751 - add full Magento version to the customInformation field<commit_after><?php
/**
 * Copyright © 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.
 */

namespace Amazon\Pay\Model\Adapter;

use Amazon\Pay\Model\Config\Source\PaymentAction;
use Magento\Quote\Model\Quote;

class AmazonPayAdapter
{
    const PAYMENT_INTENT_CONFIRM = 'Confirm';
    const PAYMENT_INTENT_AUTHORIZE = 'Authorize';
    const PAYMENT_INTENT_AUTHORIZE_WITH_CAPTURE = 'AuthorizeWithCapture';

    /**
     * @var \Amazon\Pay\Client\ClientFactoryInterface
     */
    private $clientFactory;

    /**
     * @var \Amazon\Pay\Model\AmazonConfig
     */
    private $amazonConfig;

    /**
     * @var \Magento\Store\Model\StoreManagerInterface
     */
    private $storeManager;

    /**
     * @var \Magento\Quote\Api\CartRepositoryInterface
     */
    private $quoteRepository;

    /**
     * @var \Amazon\Pay\Helper\Data
     */
    private $amazonHelper;

    /**
     * @var \Magento\Framework\App\ProductMetadataInterface
     */
    private $productMetadata;

    /**
     * @var \Amazon\Pay\Logger\Logger
     */
    private $logger;

    /**
     * @var \Magento\Framework\UrlInterface
     */
    private $url;

    /**
     * @var \Magento\Framework\App\Response\RedirectInterface
     */
    private $redirect;

    /**
     * AmazonPayAdapter constructor.
     * @param \Amazon\Pay\Client\ClientFactoryInterface $clientFactory
     * @param \Amazon\Pay\Model\AmazonConfig $amazonConfig
     * @param \Magento\Store\Model\StoreManagerInterface $storeManager
     * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
     * @param \Amazon\Pay\Helper\Data $amazonHelper
     * @param \Magento\Framework\App\ProductMetadataInterface $productMetadata
     * @param \Amazon\Pay\Logger\Logger $logger
     * @param \Magento\Framework\UrlInterface $url
     * @param \Magento\Framework\App\Response\RedirectInterface $redirect
     */
    public function __construct(
        \Amazon\Pay\Client\ClientFactoryInterface $clientFactory,
        \Amazon\Pay\Model\AmazonConfig $amazonConfig,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
        \Amazon\Pay\Helper\Data $amazonHelper,
        \Magento\Framework\App\ProductMetadataInterface $productMetadata,
        \Amazon\Pay\Logger\Logger $logger,
        \Magento\Framework\UrlInterface $url,
        \Magento\Framework\App\Response\RedirectInterface $redirect
    ) {
        $this->clientFactory = $clientFactory;
        $this->amazonConfig = $amazonConfig;
        $this->storeManager = $storeManager;
        $this->quoteRepository = $quoteRepository;
        $this->amazonHelper = $amazonHelper;
        $this->productMetadata = $productMetadata;
        $this->logger = $logger;
        $this->url = $url;
        $this->redirect = $redirect;
    }

    /**
     * @return string
     */
    protected function getMerchantCustomInformation()
    {
        return sprintf(
            'Magento Version: %s, Plugin Version: %s (v2)',
            $this->productMetadata->getVersion(),
            $this->amazonHelper->getModuleVersion('Amazon_Pay')
        );
    }

    /**
     * @param mixed $amount
     * @param string $currencyCode
     * @return array
     */
    protected function createPrice($amount, $currencyCode)
    {
        switch ($currencyCode) {
            case 'JPY':
                $amount = round($amount);
                break;
{'fraction_non_alphanumeric': 0.11396426207809397, 'fraction_numerical': 0.0017207147584381204, 'mean_word_length': 2.698482623592756, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5430063', 'n_tokens_mistral': 2169, 'n_tokens_neox': 2120, 'n_words': 471}