Sha256: fc2e9f90451e9cedfb81bbe1add6a47951efb0a241522b958fc7c8797d1e8259

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Account
  class TransactionsController < Account::BaseController
    before_action :find_payment, only: [:show]
    skip_before_action :verify_authenticity_token, only: [:update]

    respond_to :json, only: [:update, :features]

    def show
      @structure = Structure.with_type(StructureType.page).where(slug: 'order-text').first

      respond_with @payment
    end

    def features
      @features = TranslationCms::Api::Customers::Feature.get_available(params[:order_id])
                                                         .reject { |f| f.feature_type.preferred_writer? }
      @payment_types = PaymentType.visible
      @exchange_rates = TranslationCms::Api::Rates::Currency.all!

      respond_with @features
    end

    def update
      params[:order_id] ||= params[:id]
      @form = Account::FeaturesForm.new(params)
      @form.submit if @form.valid?
      respond_with @form
    end

    private

    def find_payment
      @payment = TranslationCms::Api::Payment.find(params[:id])
      raise ActiveRecord::RecordNotFound, "Payment #{params[:id]} not found" if @payment.nil?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/controllers/account/transactions_controller.rb