<?php

/**
 * @author      Open Source Team
 * @copyright   2022 Pagar.me (https://pagar.me)
 * @license     https://pagar.me Copyright
 *
 * @link        https://pagar.me
 */

/** @var \Woocommerce\Pagarme\Block\Checkout\Payment\CreditCard $this */

declare(strict_types=1);

if (!function_exists('add_action')) {
    exit(0);
}

wp_localize_script(
    WCMP_JS_HANDLER_BASE_NAME . 'googlepay',
    'wc_pagarme_googlepay',
    [
        'allowedCcFlags' => $this->getConfig()->getCcFlags(),
        'merchantName' => $this->getConfig()->getGooglepayGoogleMerchantName(),
        'merchantId' => $this->getConfig()->getGooglepayGoogleMerchantId(),
        'accountId' => $this->getConfig()->getAccountId(),
        'isSandboxMode' => $this->getConfig()->getIsSandboxMode()
    ]
);

if ( $this->getConfig()->getEnableGooglepay()  == "yes" && !$this->hasSubscriptionProductInCart() ) : ?>
    <div id="pagarme-googlepay"></div>
    <div class="pagarme_creditcard_divider">
        <p>
            <?=__("Or pay with card", 'woo-pagarme-payments')?>
        </p>
    </div>
<?php
endif; // Enable or disable googlepay
$this->createBlock(
    '\Woocommerce\Pagarme\Block\Checkout\Form\Card',
    'pagarme.checkout.form.card',
    [
        'payment_instance' => $this->getPaymentInstance(),
        'qty_cards' => $this->getQtyCards()
    ]
)->toHtml();

$this->createBlock(
    '\Woocommerce\Pagarme\Block\Checkout\Form\Tds',
    'pagarme.checkout.form.tds',
    [
        'payment_instance' => $this->getPaymentInstance()
    ]
)->toHtml();
