/**
  * 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;
 }
 /**
  * Save the Admin User Edit screen payment token fields, if any
  *
  * @see SV_WC_Payment_Gateway_Plugin::maybe_add_user_profile_tokenization_fields()
  * @param SV_WC_Payment_Gateway $gateway the gateway instance
  * @param int $user_id identifies the user to save the settings for
  */
 protected function save_user_profile_tokenization_fields($gateway, $user_id)
 {
     foreach (array_keys($gateway->get_environments()) as $environment_id) {
         // deleting any payment tokens?
         $payment_tokens_deleted_name = 'wc_' . $gateway->get_id() . '_payment_tokens_deleted_' . $environment_id;
         $delete_payment_tokens = SV_WC_Helper::get_post($payment_tokens_deleted_name) ? explode(',', trim(SV_WC_Helper::get_post($payment_tokens_deleted_name), ',')) : array();
         // see whether we're deleting any
         foreach ($delete_payment_tokens as $token) {
             $gateway->remove_payment_token($user_id, $token, $environment_id);
         }
         // adding a new payment token?
         $payment_token_name = 'wc_' . $gateway->get_id() . '_payment_token_' . $environment_id;
         if (SV_WC_Helper::get_post($payment_token_name)) {
             $exp_date = explode('/', SV_WC_Helper::get_post('wc_' . $gateway->get_id() . '_payment_token_exp_date_' . $environment_id));
             // add the new payment token, making it active if this is the first card
             $gateway->add_payment_token($user_id, $gateway->build_payment_token(SV_WC_Helper::get_post($payment_token_name), array('type' => $gateway->is_credit_card_gateway() ? 'credit_card' : 'check', 'card_type' => SV_WC_Helper::get_post('wc_' . $gateway->get_id() . '_payment_token_type_' . $environment_id), 'last_four' => SV_WC_Helper::get_post('wc_' . $gateway->get_id() . '_payment_token_last_four_' . $environment_id), 'exp_month' => count($exp_date) > 1 ? sprintf('%02s', $exp_date[0]) : null, 'exp_year' => count($exp_date) > 1 ? $exp_date[1] : null)));
         }
     }
 }