<commit_before># -*- encoding : utf-8 -*-
Spree::CheckoutController.class_eval do
  before_filter :redirect_to_mercado_pago_if_needed, :only => [:update]

  def redirect_to_mercado_pago_if_needed
    return unless params[:state] == "payment"

    selected_method_id = params[:order][:payments_attributes].first[:payment_method_id]
    @payment_method = Spree::PaymentMethod.find(selected_method_id)

    if @payment_method && @payment_method.kind_of?(PaymentMethod::MercadoPago)
      @order.update_attributes(object_params)

      back_urls = {
        success: mercado_pago_success_url,
        pending: mercado_pago_pending_url,
        failure: mercado_pago_failure_url
      }

      m = SpreeMercadoPagoClient.new(@order, back_urls)
      
      if m.authenticate && m.send_data
        redirect_to m.redirect_url
      else
        render :action => :mercado_pago_error
      end
    end
  end
end<commit_msg>Fixing route generation<commit_after># -*- encoding : utf-8 -*-
Spree::CheckoutController.class_eval do
  before_filter :redirect_to_mercado_pago_if_needed, :only => [:update]

  def redirect_to_mercado_pago_if_needed
    return unless params[:state] == "payment"

    selected_method_id = params[:order][:payments_attributes].first[:payment_method_id]
    @payment_method = Spree::PaymentMethod.find(selected_method_id)

    if @payment_method && @payment_method.kind_of?(PaymentMethod::MercadoPago)
      @order.update_attributes(object_params)

      back_urls = {
        success: main_app.mercado_pago_success_url,
        pending: main_app.mercado_pago_pending_url,
        failure: main_app.mercado_pago_failure_url
      }

      m = SpreeMercadoPagoClient.new(@order, back_urls)
      
      if m.authenticate && m.send_data
        redirect_to m.redirect_url
      else
        render :action => :mercado_pago_error
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09256286784376672, 'fraction_numerical': 0.001070090957731407, 'mean_word_length': 3.770408163265306, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4665523', 'n_tokens_mistral': 629, 'n_tokens_neox': 618, 'n_words': 93}