<?php
/**
 * Copyright © Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

use Amazon\Pay\Block\TokenRenderer;
use Magento\Framework\Escaper;

/**
 *
 * @var TokenRenderer $block
 * @var Escaper $escaper
 */

$ccNumberView = $escaper->escapeHtml($block->getPaymentDescriptor());
?>
<tr>
    <td data-th="<?= $escaper->escapeHtml(__('Type')) ?>" class="col card-type">
        <img src="<?= /* @noEscape */ $block->getIconUrl() ?>"
             width="<?= /* @noEscape */ $block->getIconWidth() ?>"
             height="<?= /* @noEscape */ $block->getIconHeight() ?>"
        >
    </td>
    <td data-th="<?= $escaper->escapeHtml(__('Card Number')) ?>" class="col card-number">
        <?= /* @noEscape */ $ccNumberView ?>
    </td>
    <td data-th="<?= $escaper->escapeHtmlAttr(__('Actions')) ?>" class="col actions">
        <form class="form"
              action="<?= $escaper->escapeUrl($block->getUrl('vault/cards/deleteaction')) ?>"
              method="post">
            <?= $block->getBlockHtml('formkey') ?>
            <input name="public_hash"
                   value="<?= $escaper->escapeHtmlAttr($block->getToken()->getPublicHash()) ?>"
                   type="hidden"/>
            <button type="submit"
                    class="action delete"
                    data-mage-init='{
                        "Magento_Vault/js/customer_account/deleteWidget":{
                            "type": "popup",
                            "modalClass": "my-credit-cards-popup",
                            "toggleEvent": "click",
                            "title": "<?= $escaper->escapeHtmlAttr(__('Delete')) ?>",
                            "content": "<?= $escaper->escapeHtmlAttr(__('Are you sure you want to delete this Amazon ' .
                                'payment method? All associated subscriptions will be canceled.')) ?>"
                        }
                    }'>
                <span><?= $escaper->escapeHtml(__('Delete')) ?></span>
            </button>
        </form>
    </td>
</tr>

