<commit_before>class UnlockPaypal::ContributionsController < ::ApplicationController

  is_unlock_gateway
  after_action :verify_authorized, except: %i[ipn]

  def create

    if create_contribution

      paypal = PayPal::Recurring.new({
        return_url: edit_paypal_contribution_url(@contribution),
        cancel_url: new_initiative_contribution_url(@initiative.id),
        ipn_url: ipn_paypal_contributions_url,
        description: @initiative.name,
        amount:  ('%.2f' % @contribution.value),
        currency: @initiative.currency
      }.merge(@contribution.paypal_auth))

      checkout = paypal.checkout

      if checkout.valid?
        redirect_to checkout.checkout_url
      else
        error = t('flash.actions.create.alert', resource_name: @contribution.class.model_name.human)
        @contribution.errors.add(:base, "#{error} (PayPal - checkout_url)")
        return render '/initiatives/contributions/new'
      end

    end

  end

  def edit
    authorize @contribution
    @initiative = @contribution.initiative
    @gateways = @initiative.gateways.without_state(:draft).order(:ordering)<commit_msg>Changes ordering order to ordered scope<commit_after>class UnlockPaypal::ContributionsController < ::ApplicationController

  is_unlock_gateway
  after_action :verify_authorized, except: %i[ipn]

  def create

    if create_contribution

      paypal = PayPal::Recurring.new({
        return_url: edit_paypal_contribution_url(@contribution),
        cancel_url: new_initiative_contribution_url(@initiative.id),
        ipn_url: ipn_paypal_contributions_url,
        description: @initiative.name,
        amount:  ('%.2f' % @contribution.value),
        currency: @initiative.currency
      }.merge(@contribution.paypal_auth))

      checkout = paypal.checkout

      if checkout.valid?
        redirect_to checkout.checkout_url
      else
        error = t('flash.actions.create.alert', resource_name: @contribution.class.model_name.human)
        @contribution.errors.add(:base, "#{error} (PayPal - checkout_url)")
        return render '/initiatives/contributions/new'
      end

    end

  end

  def edit
    authorize @contribution
    @initiative = @contribution.initiative
    @gateways = @initiative.gateways.without_state(:draft).ordered
{'fraction_non_alphanumeric': 0.09881422924901186, 'fraction_numerical': 0.000878348704435661, 'mean_word_length': 3.556, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7056429', 'n_tokens_mistral': 724, 'n_tokens_neox': 667, 'n_words': 118}