/**
         * Conditionally adds the payment token fields to the Admin User Edit
         * screen, if tokenization is enabled on the gateway, and the gateway
         * API does not support payment token retrieval (meaning the tokens
         * are stored only locally)
         *
         * @see SV_WC_Payment_Gateway_Admin_User_Edit_Handler::save_user_profile_tokenization_fields()
         * @param SV_WC_Payment_Gateway $gateway the gateway instance
         * @param WP_User $user user object for the current edit page
         */
        protected function maybe_add_user_profile_tokenization_fields($gateway, $user)
        {
            // ensure that it supports tokenization, but doesn't have a "get tokens" request, meaning that the tokens are stored and accessed locally
            if ($gateway->tokenization_enabled() && !$gateway->get_api()->supports_get_tokenized_payment_methods()) {
                $environments = $gateway->get_environments();
                foreach ($environments as $environment_id => $environment_name) {
                    // get any payment tokens
                    $payment_tokens = $gateway->get_payment_tokens($user->ID, array('environment_id' => $environment_id));
                    ?>

				<table class="form-table">
					<tr>
						<th style="padding-bottom: 0;"><?php 
                    echo count($environments) > 1 ? sprintf(esc_html__('%s Payment Tokens', 'woocommerce-plugin-framework'), $environment_name) : esc_html__('Payment Tokens', 'woocommerce-plugin-framework');
                    ?>
</th>
						<td style="padding-bottom: 0;">
							<?php 
                    if (empty($payment_tokens)) {
                        /* translators: Payment Token as in a specific entity used to make payments, such as a specific credit card, e-check account, bank account, etc. */
                        echo "<p>" . esc_html__('This customer has no saved payment tokens', 'woocommerce-plugin-framework') . "</p>";
                    } else {
                        ?>
								<ul style="margin:0;">
									<?php 
                        foreach ($payment_tokens as $token) {
                            ?>
											<li>
												<?php 
                            echo esc_html($token->get_id());
                            ?>
 (<?php 
                            /* translators: %1$s - credit card type (mastercard, visa, ...), %2$s - last 4 numbers of the card, %3$s - card expiry date */
                            printf('%1$s ending in %2$s expiring %3$s', $token->get_type_full(), $token->get_last_four(), $token->get_exp_month() . '/' . $token->get_exp_year());
                            echo $token->is_default() ? ' <strong>' . esc_html__('Default card', 'woocommerce-plugin-framework') . '</strong>' : '';
                            ?>
)
												<a href="#" class="js-sv-wc-payment-token-delete" data-payment_token="<?php 
                            echo esc_attr($token->get_id());
                            ?>
"><?php 
                            esc_html_e('Delete', 'woocommerce-plugin-framework');
                            ?>
</a>
											</li>
										<?php 
                        }
                        ?>
								</ul>
								<input type="hidden" class="js-sv-wc-payment-tokens-deleted" name="wc_<?php 
                        echo $gateway->get_id();
                        ?>
_payment_tokens_deleted_<?php 
                        echo $environment_id;
                        ?>
" value="" />
							<?php 
                    }
                    ?>
						</td>
					</tr>
					<tr>
						<?php 
                    /* translators: Payment Token as in a specific entity used to make payments, such as a specific credit card, e-check account, bank account, etc.  */
                    ?>
						<th style="padding-top: 0;"><?php 
                    esc_html_e('Add a Payment Token', 'woocommerce-plugin-framework');
                    ?>
</th>
						<td style="padding-top: 0;">
							<input type="text" name="wc_<?php 
                    echo $gateway->get_id();
                    ?>
_payment_token_<?php 
                    echo $environment_id;
                    ?>
" placeholder="<?php 
                    esc_attr_e('Token', 'woocommerce-plugin-framework');
                    ?>
" style="width:145px;" />
							<?php 
                    if ($gateway->supports(SV_WC_Payment_Gateway::FEATURE_CARD_TYPES)) {
                        ?>
								<select name="wc_<?php 
                        echo $gateway->get_id();
                        ?>
_payment_token_type_<?php 
                        echo $environment_id;
                        ?>
">
									<option value=""><?php 
                        esc_html_e('Card Type', 'woocommerce-plugin-framework');
                        ?>
</option>
									<?php 
                        foreach ($gateway->get_card_types() as $card_type) {
                            $card_type = strtolower($card_type);
                            ?>
										<option value="<?php 
                            echo esc_attr($card_type);
                            ?>
"><?php 
                            echo esc_html(SV_WC_Payment_Gateway_Helper::payment_type_to_name($card_type));
                            ?>
</option>
										<?php 
                        }
                        ?>
								</select>
							<?php 
                    }
                    ?>
							<input type="text" name="wc_<?php 
                    echo $gateway->get_id();
                    ?>
_payment_token_last_four_<?php 
                    echo $environment_id;
                    ?>
" placeholder="<?php 
                    printf(esc_attr__('Last Four', 'woocommerce-plugin-framework'), substr(date('Y') + 1, -2));
                    ?>
" style="width:75px;" />
							<input type="text" name="wc_<?php 
                    echo $gateway->get_id();
                    ?>
_payment_token_exp_date_<?php 
                    echo $environment_id;
                    ?>
" placeholder="<?php 
                    printf(esc_attr__('Expiry Date (01/%s)', 'woocommerce-plugin-framework'), date('Y') + 1);
                    ?>
" style="width:155px;" />
							<br/>
							<span class="description"><?php 
                    echo apply_filters('wc_payment_gateway_' . $gateway->get_id() . '_user_profile_add_token_description', '', $gateway, $user);
                    ?>
</span>
						</td>
					</tr>
				</table>
				<?php 
                }
                $this->maybe_add_user_profile_tokenization_fields_js();
            }
        }
 /**
  * Edit the Subscriptions automatic renewal payments support column content
  * when a gateway supports subscriptions (via tokenization) but tokenization
  * is not enabled
  *
  * @since 4.1.0
  * @param string $html column content
  * @param \WC_Payment_Gateway|\SV_WC_Payment_Gateway $gateway payment gateway being checked for support
  * @return string html
  */
 public function subscriptions_maybe_edit_renewal_support_status($html, $gateway)
 {
     // only for our gateways
     if (!in_array($gateway->id, $this->get_gateway_ids())) {
         return $html;
     }
     if ($gateway->is_enabled() && $gateway->supports_tokenization() && !$gateway->tokenization_enabled()) {
         $tool_tip = esc_attr__('You must enable tokenization for this gateway in order to support automatic renewal payments with the WooCommerce Subscriptions extension.', 'woocommerce-plugin-framework');
         $status = esc_html__('Inactive', 'woocommerce-plugin-framework');
         $html = sprintf('<a href="%1$s"><span class="sv-wc-payment-gateway-renewal-status-inactive tips" data-tip="%2$s">%3$s</span></a>', esc_url(SV_WC_Payment_Gateway_Helper::get_payment_gateway_configuration_url($this->get_gateway_class_name($gateway->get_id()))), $tool_tip, $status);
     }
     return $html;
 }
        /**
         * Conditionally adds the payment token fields to the Admin User Edit
         * screen, if tokenization is enabled on the gateway, and the gateway
         * API does not support payment token retrieval (meaning the tokens
         * are stored only locally)
         *
         * @see SV_WC_Payment_Gateway_Admin_User_Edit_Handler::save_user_profile_tokenization_fields()
         * @param SV_WC_Payment_Gateway $gateway the gateway instance
         * @param WP_User $user user object for the current edit page
         */
        protected function maybe_add_user_profile_tokenization_fields($gateway, $user)
        {
            // ensure that it supports tokenization, but doesn't have a "get tokens" request, meaning that the tokens are stored and accessed locally
            if ($gateway->tokenization_enabled() && !$gateway->get_api()->supports_get_tokenized_payment_methods()) {
                $environments = $gateway->get_environments();
                foreach ($environments as $environment_id => $environment_name) {
                    // get any payment tokens
                    $payment_tokens = $gateway->get_payment_tokens($user->ID, null, $environment_id);
                    ?>

				<table class="form-table">
					<tr>
						<th style="padding-bottom:0px;"><?php 
                    echo count($environments) > 1 ? sprintf(__('%s Payment Tokens', $this->text_domain), $environment_name) : __('Payment Tokens', $this->text_domain);
                    ?>
</th>
						<td style="padding-bottom:0px;">
							<?php 
                    if (empty($payment_tokens)) {
                        echo "<p>" . __('This customer has no saved payment tokens', $this->text_domain) . "</p>";
                    } else {
                        ?>
								<ul style="margin:0;">
									<?php 
                        foreach ($payment_tokens as $token) {
                            ?>
											<li>
												<?php 
                            echo $token->get_token();
                            ?>
 (<?php 
                            printf('%s ending in %s expiring %s', $token->get_type_full(), $token->get_last_four(), $token->get_exp_month() . '/' . $token->get_exp_year());
                            echo $token->is_default() ? ' <strong>' . __('Default card', $this->text_domain) . '</strong>' : '';
                            ?>
)
												<a href="#" class="js-sv-wc-payment-token-delete" data-payment_token="<?php 
                            echo $token->get_token();
                            ?>
"><?php 
                            _e('Delete', $this->text_domain);
                            ?>
</a>
											</li>
										<?php 
                        }
                        ?>
								</ul>
								<input type="hidden" class="js-sv-wc-payment-tokens-deleted" name="wc_<?php 
                        echo $gateway->get_id();
                        ?>
_payment_tokens_deleted_<?php 
                        echo $environment_id;
                        ?>
" value="" />
							<?php 
                    }
                    ?>
						</td>
					</tr>
					<tr>
						<th style="padding-top:0px;"><?php 
                    _e('Add a Payment Token', $this->text_domain);
                    ?>
</th>
						<td style="padding-top:0px;">
							<input type="text" name="wc_<?php 
                    echo $gateway->get_id();
                    ?>
_payment_token_<?php 
                    echo $environment_id;
                    ?>
" placeholder="<?php 
                    esc_attr_e('Token', $this->text_domain);
                    ?>
" style="width:145px;" />
							<?php 
                    if ($gateway->supports(SV_WC_Payment_Gateway::FEATURE_CARD_TYPES)) {
                        ?>
								<select name="wc_<?php 
                        echo $gateway->get_id();
                        ?>
_payment_token_type_<?php 
                        echo $environment_id;
                        ?>
">
									<option value=""><?php 
                        _e("Card Type", $this->text_domain);
                        ?>
</option>
									<?php 
                        foreach ($gateway->get_card_types() as $card_type) {
                            $card_type = strtolower($card_type);
                            ?>
										<option value="<?php 
                            echo $card_type;
                            ?>
"><?php 
                            echo SV_WC_Payment_Gateway_Payment_Token::type_to_name($card_type);
                            ?>
</option>
										<?php 
                        }
                        ?>
								</select>
							<?php 
                    }
                    ?>
							<input type="text" name="wc_<?php 
                    echo $gateway->get_id();
                    ?>
_payment_token_last_four_<?php 
                    echo $environment_id;
                    ?>
" placeholder="<?php 
                    printf(esc_attr__('Last Four', $this->text_domain), substr(date('Y') + 1, -2));
                    ?>
" style="width:75px;" />
							<input type="text" name="wc_<?php 
                    echo $gateway->get_id();
                    ?>
_payment_token_exp_date_<?php 
                    echo $environment_id;
                    ?>
" placeholder="<?php 
                    printf(esc_attr__('Expiry Date (01/%s)', $this->text_domain), date('Y') + 1);
                    ?>
" style="width:155px;" />
							<br/>
							<span class="description"><?php 
                    echo apply_filters('wc_payment_gateway_' . $gateway->get_id() . '_user_profile_add_token_description', '', $gateway, $user);
                    ?>
</span>
						</td>
					</tr>
				</table>
				<?php 
                }
                $this->maybe_add_user_profile_tokenization_fields_js();
            }
        }