<?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>
 */

/**
 * @var Boleto $block
 */

use Adyen\Payment\Block\Info\Boleto;

$_info = $block->getInfo();
$_isDemoMode = $block->isDemoMode();

?>

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

<?php if ($_pspReference = $_info->getAdditionalInformation('pspReference')): ?>
    <div>
        <?= $block->escapeHtml(__('Adyen PSP Reference: ')); ?>
        <?php if ($_isDemoMode): ?>
            <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: ?>
            <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 (!empty($block->getPaymentActionData('expiresAt'))): ?>
    <div>
        <?= $block->escapeHtml(__('Expiration Date: %1', $block->getPaymentActionData('expiresAt'))); ?>
    </div>
<?php endif; ?>

<?php if ($_info->getAdditionalInformation('dueDate') != ""): ?>
    <div>
        <?= $block->escapeHtml(__('Due Date: %1', $_info->getAdditionalInformation('dueDate'))); ?>
    </div>
<?php endif; ?>

<?php if (!empty($block->getPaymentActionData('downloadUrl'))): ?>
    <div>
        <a target="_blank"
           href="<?= $block->escapeHtml($block->getPaymentActionData('downloadUrl')); ?>"><?= $block->escapeHtml(
               __('PDF Url')
            ); ?></a>
    </div>
<?php endif; ?>

<?php if ($_info->getAdditionalInformation('adyen_total_fraud_score') != ""): ?>
    <div>
        <?= $block->escapeHtml(
            __('Total fraud score: %1', $_info->getAdditionalInformation('adyen_total_fraud_score'))
        ); ?>
    </div>
<?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 ($block->getPartialPayments()->getSize() > 1) {
        echo $block->renderPartialPaymentsHtml();
    }
?>

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