Sha256: c9a03495fd734ca6017fd5f4e35d7f57cebf53a71a95bf42632843ce078bbcc9

Contents?: true

Size: 1.52 KB

Versions: 8

Compression:

Stored size: 1.52 KB

Contents

# coding: utf-8
class PaymentsController < ApplicationController
  before_filter :authenticate_terminal

  def limits
    provider = Provider.find_by_keyword params[:provider]

    render :json => provider.limits.actual.
                      by_terminal_profile_and_agent_ids(@terminal.terminal_profile_id, @terminal.agent_id).
                      by_payment_type(params[:payment_type]).
                      as_json(:only => [:min, :max], :methods => [:weight])
  end

  def create
    payment = Payment.build!(@terminal, Provider.find_by_keyword(params[:provider]), params[:payment])

    if payment
      payment.check!

      render :json => {
        :id               => payment.id,
        :state            => payment.state,
        :requires_print   => payment.provider.requires_print,
        :limits           => Limit.for(payment, false).as_json(
                                :only => [:min, :max], :methods => [:weight]
                             ),
        :commissions      => Commission.for(payment, false).as_json(
                                :only => [:min, :max, :percent_fee, :static_fee, :payment_type],
                                :methods => [:weight]
                             ),
        :receipt_template => ProviderReceiptTemplate.for(payment).compile(payment)
      }
    else
      render :text => nil, :status => 406
    end
  end
  
  def pay
    payment = @terminal.payments.find(params[:id])
    payment.enqueue!(params[:payment]) unless payment.queue?

    render :text => nil, :status => 200
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
smartkiosk-server-0.11.11 app/controllers/payments_controller.rb
smartkiosk-server-0.11.10 app/controllers/payments_controller.rb
smartkiosk-server-0.11.9 app/controllers/payments_controller.rb
smartkiosk-server-0.11.8 app/controllers/payments_controller.rb
smartkiosk-server-0.11.7 app/controllers/payments_controller.rb
smartkiosk-server-0.11.6 app/controllers/payments_controller.rb
smartkiosk-server-0.11.5 app/controllers/payments_controller.rb
smartkiosk-server-0.11.4 app/controllers/payments_controller.rb