<?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 \Adyen\Payment\Block\Checkout\Success $block
 */
?>
<?php if ($block->isBoletoPayment()) : ?>
    <p>
        <?php echo $block->escapeHtml(__('Boleto PDF: ')); ?>
        <a href="<?php echo $block->escapeUrl($block->getBoletoPdfUrl()); ?>">
            <?php echo $block->escapeHtml(__('Click here to download the Boleto PDF')); ?>
        </a>
    </p>
<?php endif; ?>

<?php if (!empty($block->getBankTransferData())) : ?>
    <?php
    $banktranferData = $block->getBankTransferData();
    $order = $block->getOrder();
    ?>
    <h2><?php echo $block->escapeHtml(__('Pay using Bank transfer')); ?></h2>
    <p><?php echo $block->escapeHtml(__('Please transfer the amount using the reference below to the following bank account')); ?></p>
    <table>
        <tbody>
        <?php if (!empty($order->getGrandTotal())) : ?>
            <tr>
                <th><?php echo $block->escapeHtml(__('Amount')); ?></th>
                <td><?php echo $order->formatPrice($order->getGrandTotal()); ?></td>
            </tr>
        <?php endif; ?>

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

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

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

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

        <?php if (!empty($banktranferData['bankTransfer.accountCode'])) : ?>
            <tr>
                <th><?php echo $block->escapeHtml(__('Bankaccount')); ?></th>
                <td><?php echo $banktranferData['bankTransfer.accountCode'] ?></td>
            </tr>
        <?php endif; ?>
        </tbody>
    </table>


<?php elseif (!empty($block->getMultibancoData())) : ?>
    <?php
    $multibancoData = $block->getMultibancoData();
    ?>
    <h2><?php echo $block->escapeHtml(__('Pay using Multibanco')); ?></h2>
    <p><?php echo $block->escapeHtml(__('Please pay with the provided Multibanco reference and entity before payment deadline in order to complete our payment')); ?></p>
    <table>
        <tbody>

        <?php if (!empty($multibancoData['comprafacil.entity'])) : ?>
            <tr>
                <th><?php echo $block->escapeHtml(__('Entity')); ?></th>
                <td><?php echo $multibancoData['comprafacil.entity'] ?></td>
            </tr>
        <?php endif; ?>

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

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

        <?php if (!empty($multibancoData['comprafacil.deadline'])) : ?>
            <tr>
                <th><?php echo $block->escapeHtml(__('Payment deadline')); ?></th>
                <td><?php echo $multibancoData['comprafacil.deadline'] ?> <?php echo $block->escapeHtml(__('Days')); ?></td>
            </tr>
        <?php endif; ?>
        </tbody>
    </table>


<?php endif; ?>