<?php
/**
 *                       ######
 *                       ######
 * ############    ####( ######  #####. ######  ############   ############
 * #############  #####( ######  #####. ######  #############  #############
 *        ######  #####( ######  #####. ######  #####  ######  #####  ######
 * ###### ######  #####( ######  #####. ######  #####  #####   #####  ######
 * ###### ######  #####( ######  #####. ######  #####          #####  ######
 * #############  #############  #############  #############  #####  ######
 *  ############   ############  #############   ############  #####  ######
 *                                      ######
 *                               #############
 *                               ############
 *
 * Adyen Payment module (https://www.adyen.com/)
 *
 * Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
 * See LICENSE.txt for license details.
 *
 * Author: Adyen <magento@adyen.com>
 */

// @codingStandardsIgnoreFile

?>
<?php
/**
 * @see \Magento\Payment\Block\Info
 */

?>
<?= $block->escapeHtml($block->getMethod()->getTitle()); ?>

<?php
$_info = $block->getInfo();
$_isDemoMode = $block->isDemoMode();
?>
<?php if ($_pspReference = $_info->getAdditionalInformation('pspReference')): ?>
    <div>
        <?php if ($_isDemoMode): ?>
            <?= $block->escapeHtml(__('Adyen PSP Reference: ')); ?>
            <a href="https://ca-test.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=<?= $block->escapeHtml(
                $_pspReference
            ); ?>&txType=Payment" target="_blank"><?= $block->escapeHtml($_pspReference); ?></a>
        <?php else: ?>
            <?= $block->escapeHtml(__('Adyen PSP Reference: ')); ?>
            <a href="https://ca-live.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=<?= $block->escapeHtml(
                $_pspReference
            ); ?>&txType=Payment" target="_blank"><?= $block->escapeHtml($_pspReference); ?></a>
        <?php endif; ?>
    </div>
<?php endif; ?>

<?php if ($_brandCode = $_info->getAdditionalInformation('brand_code')): ?>
    <div><?= $block->escapeHtml(__('Payment Method: %1', $_brandCode)); ?></div>
<?php endif; ?>

<?php if (!empty($block->getBankTransferData())): ?>

    <?php
    $banktranferData = $block->getBankTransferData();
    $order = $block->getOrder();
    $orderAmountCurrency = $block->getOrderAmountCurrency();
    ?>

    <div>
        <table class="edit-order-table" style="text-align:left; margin-top:5px; margin-bottom:0;">
            <tbody>
            <?php if (!empty($orderAmountCurrency->getAmount())): ?>
                <tr>
                    <th scope="row"><?= $block->escapeHtml(__('Amount')); ?></th>
                    <td><?= /* @noEscape */ $order->formatPrice($orderAmountCurrency->getAmount()); ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($banktranferData['bankTransfer.reference'])): ?>
                <tr>
                    <th scope="row"><?= $block->escapeHtml(__('With reference')); ?></th>
                    <td><?= $block->escapeHtml($banktranferData['bankTransfer.reference']); ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($banktranferData['bankTransfer.owner'])): ?>
                <tr>
                    <th scope="row"><?= $block->escapeHtml(__('Beneficiary Name')); ?></th>
                    <td><?= $block->escapeHtml($banktranferData['bankTransfer.owner']); ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($banktranferData['bankTransfer.bankName'])): ?>
                <tr>
                    <th scope="row"><?= $block->escapeHtml(__('Bank')); ?></th>
                    <td><?= $block->escapeHtml($banktranferData['bankTransfer.bankName']); ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($banktranferData['bankTransfer.iban'])): ?>
                <tr>
                    <th scope="row"><?= $block->escapeHtml(__('IBAN')); ?></th>
                    <td><?= $block->escapeHtml($banktranferData['bankTransfer.iban']); ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($banktranferData['bankTransfer.accountCode'])): ?>
                <tr>
                    <th scope="row"><?= $block->escapeHtml(__('Bankaccount')); ?></th>
                    <td><?= $block->escapeHtml($banktranferData['bankTransfer.accountCode']); ?></td>
                </tr>
            <?php endif; ?>
            </tbody>
        </table>
    </div>
<?php elseif (!empty($block->getMultibancoData())): ?>
    <?php
    $multibancoData = $block->getMultibancoData();
    ?>

    <div>
        <table class="edit-order-table" style="text-align:left; margin-top:5px; margin-bottom:0;">
            <tbody>
            <?php if (!empty($multibancoData['comprafacil.entity'])): ?>
                <tr>
                    <th scope="row"><?= $block->escapeHtml(__('Entity')); ?></th>
                    <td><?= $block->escapeHtml($multibancoData['comprafacil.entity']); ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($multibancoData['comprafacil.reference'])): ?>
                <tr>
                    <th scope="row"><?= $block->escapeHtml(__('Reference')); ?></th>
                    <td><?= $block->escapeHtml($multibancoData['comprafacil.reference']); ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($multibancoData['comprafacil.amount'])): ?>
                <tr>
                    <th scope="row"><?= $block->escapeHtml(__('Amount')); ?></th>
                    <td><?= $block->escapeHtml($multibancoData['comprafacil.amount']); ?></td>
                </tr>
            <?php endif; ?>

            <?php if (!empty($multibancoData['comprafacil.deadline'])): ?>
                <tr>
                    <th scope="row"><?= $block->escapeHtml(__('Deadline')); ?></th>
                    <td><?= $block->escapeHtml($multibancoData['comprafacil.deadline']); ?><?= $block->escapeHtml(
                        __('Days')
                    ); ?></td>
                </tr>
            <?php endif; ?>
            </tbody>
        </table>
    </div>
<?php endif; ?>

<?php if ($_info->getAdditionalInformation('adyen_total_fraud_score') != ""): ?>
    <?= $block->escapeHtml(__('Total fraud score: ')); ?>
    <?= $block->escapeHtml($_info->getAdditionalInformation('adyen_total_fraud_score')); ?>
    <br/>
<?php endif; ?>


<?php if ($block->getSplitPayments()): ?>
    <table class="edit-order-table">
        <tr>
            <th scope="col">PspReference</th>
            <th scope="col">Payment Method</th>
            <th scope="col">Amount</th>
            <th scope="col">Refunded</th>
        </tr>
        <?php foreach ($block->getSplitPayments() as $payment): ?>
            <tr>
                <td><?= $block->escapeHtml($payment->getPspreference()); ?></td>
                <td><?= $block->escapeHtml($payment->getPaymentMethod()); ?></td>
                <td><?= $block->escapeHtml($payment->getAmount()); ?></td>
                <td><?= $block->escapeHtml($payment->getTotalRefunded()); ?></td>
            </tr>
        <?php endforeach; ?>
    </table>
<?php endif; ?>

<?php if ($_specificInfo = $block->getSpecificInformation()): ?>
    <table class="data-table admin__table-secondary">
        <?php foreach ($_specificInfo as $_label => $_value): ?>
            <tr>
                <th scope="row"><?= $block->escapeHtml($_label) ?>:</th>
                <td><?= $block->escapeHtml(nl2br(implode("\n", $block->getValueAsArray($_value, true)))); ?></td>
            </tr>
        <?php endforeach; ?>
    </table>
<?php endif; ?>

<?php if ($ratepayDescriptor = $_info->getAdditionalInformation('adyen_ratepay_descriptor')): ?>
    <div><?= $block->escapeHtml(__('Invoice Descriptor: %1', $ratepayDescriptor)); ?>
    </div>
<?php endif; ?>

<?= $block->escapeHtml($block->getChildHtml()); ?>
