<?php
/*
check admin details
*/
$adminDetails = $block->checkAdminDetails();
if (!$adminDetails) {
    ?>
    <div class="pp-buttons-container">
        <?= /*@noEscape*/ __('Admin has not configured this Payment Method yet.'); ?>
    </div>
    <?php
} else {
    $referalUrl = '';
    $statusData = $block->getMerchantStatus();
    if (!$statusData) {
        $referalUrl = $block->getPartnerRefferalUrl();
        $isRegistered = false;
    } else {
        $isRegistered = true;
    }
    ?>
    <div class="pp-buttons-container">
        <?php
        if (!$isRegistered) {
            ?>
            <div dir="ltr" style="text-align: left;" trbidi="on">
                <script>
                    (function(d, s, id){
                        var js, ref = d.getElementsByTagName(s)[0];
                        if (!d.getElementById(id)){
                            js = d.createElement(s); js.id = id; js.async = true;
                            js.src = "https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js";
                            ref.parentNode.insertBefore(js, ref); }
                    }(document, "script", "paypal-js"));
                </script>
    
                <a class="action-default"
                data-paypal-button="true"
                href="<?= /* @noEscape */ $block->escapeUrl($referalUrl. '&displayMode=minibrowser') ?>"
                target="PPFrame"><?= /*@noEscape*/ __('Enable PayPal'); ?></a>
            </div>
            <?php
        } else {
            ?>
                <div class="setup-complete">
                    <?= /*@noEscape*/ __('Setup is Complete'); ?>
                </div>
                <div class="missing-permission">
                <?php
                if (!$statusData['payments_receivable']) {
                    ?>
                    <?= /*@noEscape*/ __('Not authorized to Receive Payments please contact Admin'); ?>
                    <?php
                }
                if (!$statusData['primary_email_confirmed']) {
                    ?>
                    <?= /*@noEscape*/
                    __('Please confirm you primary email address in order to receive the payments'); ?>
                    <?php
                }
                ?>
                </div>
            <?php
        }
        ?>
        
    </div>
    <?php
}
