module EcconnectRails::ControllerActions

Public Instance Methods

check() click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 38
def check
  @ecconnect_payment = resource_class.find params[:id]
  respond_to do |format|
    format.html do 
      render 'check'
    end
    format.json{ render json: @ecconnect_payment.ecconnect_json }
  end
end
create() click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 13
def create
  @ecconnect_payment = resource_class.new params[:ecconnect_payment]
  if @ecconnect_payment.save
    respond_to do |format|
      format.html{ redirect_to ecconnect_payment_path(@ecconnect_payment.to_param) }
      format.json{ render json: @ecconnect_payment.ecconnect_json }
    end
  else
    respond_to do |format|
      format.html{ render 'new' }
      format.json{ render json: @ecconnect_payment.ecconnect_json }
    end
  end
end
failure() click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 48
def failure
  @ecconnect_payment = resource_class.where(order_id: params[:OrderID]).limit(1).first
  @ecconnect_payment.update_by params
  if @ecconnect_payment.check_signature
    failure_right_signature @ecconnect_payment
    failure_respond @ecconnect_payment
  else
    failure_wrong_signature @ecconnect_payment
    wrong_signature_respond @ecconnect_payment
  end
end
new() click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 3
def new
  @ecconnect_payment = resource_class.new
  respond_to do |format|
    format.html do 
      render 'new'
    end
    format.json{ render json: @ecconnect_payment.ecconnect_json }
  end
end
notify() click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 77
def notify
  @ecconnect_payment = resource_class.where(order_id: params[:OrderID]).limit(1).first
  @ecconnect_payment.update_by params
  if @ecconnect_payment.check_signature
    if @ecconnect_payment.tran_code == '000'
      @action = 'approve'
      @forward_url = forward_url_success
      notify_right_signature_and_code @ecconnect_payment
      notify_respond @ecconnect_payment
    else
      @action = 'reverse'
      @reason = I18n.t "ecconnect_rails.codes.code_503"
      @forward_url = forward_url_failure
      notify_right_signature @ecconnect_payment
      notify_respond @ecconnect_payment
    end
  else
    @action = 'reverse'
    @reason = I18n.t "ecconnect_rails.codes.code_405"
    @forward_url = forward_url_failure
    notify_wrong_signature @ecconnect_payment
    notify_respond @ecconnect_payment
  end
end
show() click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 28
def show
  @ecconnect_payment = resource_class.find params[:id]
  respond_to do |format|
    format.html do 
      render 'show'
    end
    format.json{ render json: @ecconnect_payment.ecconnect_json }
  end
end
success() click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 60
def success
  @ecconnect_payment = resource_class.where(order_id: params[:OrderID]).limit(1).first
  @ecconnect_payment.update_by params
  if @ecconnect_payment.check_signature
    if @ecconnect_payment.tran_code == '000'
      success_right_signature @ecconnect_payment
      success_respond @ecconnect_payment
    else
      failure_right_signature @ecconnect_payment
      failure_respond @ecconnect_payment
    end
  else
    success_wrong_signature @ecconnect_payment
    wrong_signature_respond @ecconnect_payment
  end
end

Private Instance Methods

failure_respond(ecconnect_payment) click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 128
def failure_respond ecconnect_payment
  respond_to do |format|
    format.html do
      flash[:error] = I18n.t "ecconnect_rails.codes.code_#{@ecconnect_payment.tran_code}" 
      render 'failure'
    end
    format.json{ render json: @ecconnect_payment.ecconnect_json }
  end
end
failure_right_signature(ecconnect_payment) click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 154
def failure_right_signature ecconnect_payment
end
failure_wrong_signature(ecconnect_payment) click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 157
def failure_wrong_signature ecconnect_payment
end
forward_url_failure() click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 107
def forward_url_failure
end
forward_url_success() click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 104
def forward_url_success
end
notify_respond(ecconnect_payment) click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 110
def notify_respond ecconnect_payment
  respond_to do |format|
    format.html do 
      render 'notify', layout: nil
    end
  end
end
notify_right_signature(ecconnect_payment) click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 160
def notify_right_signature ecconnect_payment
end
notify_right_signature_and_code(ecconnect_payment) click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 163
def notify_right_signature_and_code ecconnect_payment
end
notify_wrong_signature(ecconnect_payment) click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 166
def notify_wrong_signature ecconnect_payment
end
success_respond(ecconnect_payment) click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 118
def success_respond ecconnect_payment
  respond_to do |format|
    format.html do
      flash[:notice] = I18n.t "ecconnect_rails.success"  
      render 'success'
    end
    format.json{ render json: @ecconnect_payment.ecconnect_json }
  end
end
success_right_signature(ecconnect_payment) click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 148
def success_right_signature ecconnect_payment
end
success_wrong_signature(ecconnect_payment) click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 151
def success_wrong_signature ecconnect_payment
end
wrong_signature_respond(ecconnect_payment) click to toggle source
# File lib/ecconnect_rails/controller_actions.rb, line 138
def wrong_signature_respond ecconnect_payment
  respond_to do |format|
    format.html do
      flash[:error] = I18n.t "ecconnect_rails.wrong_signature" 
      render 'failure'
    end
    format.json{ render json: @ecconnect_payment.ecconnect_json }
  end
end