<commit_before>Admin::PaymentsController.class_eval do
  alias old_fire fire
  
  def fire
    load_object
    if event = params[:e] 
      if @payment.payment_source
        return old_fire 
      else  
        #Assume payment:check  TODO check this
        if event == "pay" #only respond to action we stubbed in Payment_decorator
          if @payment.state == "checkout" #and only for new paymnets
            @payment.pay
            redirect_to collection_path
          end
        end
      end
    end
  end
end
<commit_msg>fixes issue 2, apply to correct states and update order<commit_after>Admin::PaymentsController.class_eval do
  alias old_fire fire
  
  def fire
    load_object
    if event = params[:e]         #only respond to action we stubbed in Payment_decorator
      if @payment.payment_method.type == "PaymentMethod::Check" and event == "pay" 
        # checkout means new from admin side, pending means new on user side
        if @payment.state == "checkout" or @payment.state == "pending"
          @payment.pay
          @payment.order.update!
          redirect_to collection_path
        end
      else
        return old_fire
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.06155143338954469, 'fraction_numerical': 0.0008431703204047217, 'mean_word_length': 2.252054794520548, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1688224', 'n_tokens_mistral': 333, 'n_tokens_neox': 327, 'n_words': 113}