<commit_before>class @SubscriptionCheckout
  @form_selector: '.zahlen-subscription-form'
  @payment_method: 'card'

  constructor: (options = {}) ->
    $.extend @, {}, options
    @handlers()
    $(@constructor.form_selector).find('.zahlen-error').hide()
    @displayPaymentMethodData()

  handlers: ->
    @formSubmitHandler()
    @getInitPaymentMethod()
    @paymentMethodToggle()

  formSubmitHandler: ->
    self = @
    form_selector = @constructor.form_selector
    self.payment_method = $("input[data-zahlen='payment-method']:checked").val()

    $(document).off("submit#{form_selector}").on "submit#{form_selector}", "#{form_selector}", (e) ->
      e.preventDefault()
      if self.payment_method in ['card']
        if !self.validateForm()
          SubscriptionCheckout.showError(Zahlen.locale().errors.not_valid)
          return false

      $(this).find(':submit').prop('disabled', true);
      $('.zahlen-spinner').show();

      if !self.payment_method?
        console.log "No payment method has been found. Please check your form."
        return false

      if self.payment_method in ['card']
        Conekta.Token.create($(form_selector), self.conektaSuccessResponseHandler, self.conektaErrorResponseHandler)
      else
        self.offlineReponseHandler()
      return false

  getInitPaymentMethod: ->
    @payment_method = $("input[data-zahlen='payment-method']").val()

  paymentMethodToggle: ->
    self = @
    form_selector = @constructor.form_selector
    $('body').on "change", "input[data-zahlen='payment-method']", (e) ->
      self.payment_method = payment_method
      self.displayPaymentMethodData()

  displayPaymentMethodData: ->
    payment_method = @payment_method.replace(/_/, '-')
    $('.payment-method-fields').hide()
    $(".#{payment_method}-fields").show()
<commit_msg>Min fix ...<commit_after>class @SubscriptionCheckout
  @form_selector: '.zahlen-subscription-form'
  @payment_method: 'card'

  constructor: (options = {}) ->
    $.extend @, {}, options
    @handlers()
    $(@constructor.form_selector).find('.zahlen-error').hide()
    @displayPaymentMethodData()

  handlers: ->
    @formSubmitHandler()
    @getInitPaymentMethod()
    @paymentMethodToggle()

  formSubmitHandler: ->
    self = @
    form_selector = @constructor.form_selector
    self.payment_method = $("input[data-zahlen='payment-method']:checked").val()

    $(document).off("submit#{form_selector}").on "submit#{form_selector}", "#{form_selector}", (e) ->
      e.preventDefault()
      if self.payment_method in ['card']
        if !self.validateForm()
          SubscriptionCheckout.showError(Zahlen.locale().errors.not_valid)
          return false

      $(this).find(':submit').prop('disabled', true);
      $('.zahlen-spinner').show();

      if !self.payment_method?
        console.log "No payment method has been found. Please check your form."
        return false

      if self.payment_method in ['card']
        Conekta.Token.create($(form_selector), self.conektaSuccessResponseHandler, self.conektaErrorResponseHandler)
      else
        self.offlineReponseHandler()
      return false

  getInitPaymentMethod: ->
    @payment_method = $("input[data-zahlen='payment-method']").val()

  paymentMethodToggle: ->
    self = @
    form_selector = @constructor.form_selector
    $('body').on "change", "input[data-zahlen='payment-method']", (e) ->
      payment_method = $(this).val().replace(/_/, '-')
      self.payment_method = payment_method
      self.displayPaymentMethodData()

  displayPaymentMethodData: ->
    $('.payment-method-fields').hide()
    $(".#{@payment_method}-fields").show()

{'fraction_non_alphanumeric': 0.15946020380060588, 'fraction_numerical': 0.0, 'mean_word_length': 3.580075662042875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6612955', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1083, 'n_words': 172}