public function validate_subscription($html)
 {
     $sub = Shortcode_Tracker::shortcode_exists_current('stripe_subscription');
     $uea = Shortcode_Tracker::shortcode_exists_current('stripe_amount');
     //$html = '';
     // Neither exist so we can just exit now
     if ($sub === false && $uea === false) {
         return $html;
     }
     $sub_id = isset($sub['attr']['id']) ? true : false;
     $sub_children = isset($sub['children']) ? true : false;
     $use_amount = isset($sub['attr']['use_amount']) && $sub['attr']['use_amount'] == 'true' ? true : false;
     // Can't have both an ID and UEA
     if (($sub_id || $sub_children) && $uea) {
         Shortcode_Tracker::update_error_count();
         if (current_user_can('manage_options')) {
             Shortcode_Tracker::add_error_message('<h6>' . __('Subscriptions must specify a plan ID or include a user-entered amount field. You cannot include both or omit both.', 'sc_sub') . '</h6>');
         }
     }
     if (empty($sub_id) && ($uea || $use_amount) && $sub != false) {
         $interval = isset($sub['attr']['interval']) ? $sub['attr']['interval'] : 'month';
         $interval_count = isset($sub['attr']['interval_count']) ? $sub['attr']['interval_count'] : 1;
         $statement_description = isset($sub['attr']['statement_description']) ? $sub['attr']['statement_description'] : '';
         $html .= '<input type="hidden" name="sc_sub_id" class="sc_sub_id" value="" />';
         $html .= '<input type="hidden" name="sc_sub_interval" class="sc_sub_interval" value="' . $interval . '" />';
         $html .= '<input type="hidden" name="sc_sub_interval_count" class="sc_sub_interval_count" value="' . $interval_count . '" />';
         $html .= '<input type="hidden" name="sc_sub_statement_description" class="sc_sub_statement_description" value="' . $statement_description . '" />';
     }
     if (empty($sub_id) && !$uea && empty($sub_children) && $use_amount === false) {
         Shortcode_Tracker::update_error_count();
         if (current_user_can('manage_options')) {
             Shortcode_Tracker::add_error_message('<h6>' . __('Subscriptions must specify a plan ID or include a user-entered amount field. You cannot include both or omit both.', 'sc_sub') . '</h6>');
         }
     }
     return $html;
 }
 public static function reset_error_count()
 {
     self::$error_count = 0;
 }
 public function total_fields($reset = false)
 {
     static $counter = 0;
     if ($reset == true) {
         $counter = 0;
         return '';
     }
     $counter++;
     if ($counter > 20) {
         $counter = 0;
         Shortcode_Tracker::update_error_count();
         if (current_user_can('manage_options')) {
             echo '<p>' . __('Admin note: You have entered more fields than are currently allowed by Stripe. Please limit your fields to 20 or less.', 'stripe') . '</p>';
         }
     }
 }
 /**
  * [stripe_recurring_total] shortcode.
  */
 public function recurring_total($attr)
 {
     global $sc_script_options;
     static $counter = 1;
     $attr = shortcode_atts(array('label' => __('Recurring payment:', 'sc_sub') . ' '), $attr, 'stripe_recurring_total');
     $label = $attr['label'];
     $currency = strtoupper($sc_script_options['script']['currency']);
     $amount = $sc_script_options['script']['amount'];
     $setup_fee = isset($sc_script_options['script']['setupFee']) ? $sc_script_options['script']['setupFee'] : 0;
     Shortcode_Tracker::add_new_shortcode('stripe_recurring_total_' . $counter, 'stripe_total', $attr, false);
     $html = $label . ' ';
     $html .= '<span class="' . apply_filters('sc_recurring_total_amount_class', 'sc-recurring-total-amount') . '">';
     // USD only: Show dollar sign on left of amount.
     if ($currency === 'USD') {
         $html .= '$';
     }
     $html .= Stripe_Checkout_Misc::to_formatted_amount($amount + $setup_fee, $currency);
     // Non-USD: Show currency on right of amount.
     if ($currency !== 'USD') {
         $html .= ' ' . $currency;
     }
     $html .= '</span>';
     //sc-recurring-total-amount
     $counter++;
     // Set args to send with filter
     $args = array();
     $args['label'] = $label;
     $args['currency'] = $currency;
     $args['amount'] = $amount;
     $args['setup_fee'] = $setup_fee;
     return '<div class="' . apply_filters('sc_form_group_class', 'sc-form-group') . '">' . apply_filters('sc_stripe_recurring_total', $html, $args) . '</div>';
 }