Class: Veritrans::Generators::SampleGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_controller_fileObject



32
33
34
35
36
37
# File 'lib/generators/install_generator.rb', line 32

def create_controller_file
  acts = "app/controllers/vtlink/"
  path = __FILE__.sub(__FILE__.split('/').pop,"templates/#{acts}")
  create_file("#{acts}merchant_controller.rb", IO.read("#{path}merchant_controller.rb"))
  create_file("#{acts}veritrans_controller.rb",IO.read("#{path}veritrans_controller.rb"))
end

#create_or_update_config_filesObject



57
58
59
60
# File 'lib/generators/install_generator.rb', line 57

def create_or_update_config_files
  path = __FILE__.sub(__FILE__.split('/').pop,'templates/config/')
  create_file("config/veritrans.yml",IO.read("#{path}veritrans.yml"))
end

#create_view_filesObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/generators/install_generator.rb', line 39

def create_view_files
  acts = "app/views/layouts/"
  path = __FILE__.sub(__FILE__.split('/').pop,"templates/#{acts}")
  create_file("#{acts}layout_auto_post.html.erb",IO.read("#{path}layout_auto_post.html.erb" ))

  acts = "app/views/vtlink/merchant/"
  path = __FILE__.sub(__FILE__.split('/').pop,"templates/#{acts}")
  create_file("#{acts}checkout.html.erb",IO.read("#{path}checkout.html.erb" ))

  acts = "app/views/vtlink/veritrans/"
  path = __FILE__.sub(__FILE__.split('/').pop,"templates/#{acts}")
  create_file("#{acts}confirm.html.erb", IO.read("#{path}confirm.html.erb"))
  create_file("#{acts}cancel.html.erb",  IO.read("#{path}cancel.html.erb" ))
  create_file("#{acts}pay.html.erb",     IO.read("#{path}pay.html.erb"    ))
  create_file("#{acts}finish.html.erb",  IO.read("#{path}finish.html.erb" ))
  create_file("#{acts}error.html.erb",   IO.read("#{path}error.html.erb"  ))
end

#update_routesObject



62
63
64
65
66
67
68
69
70
71
# File 'lib/generators/install_generator.rb', line 62

def update_routes
  route("end")
  route("  match '/' => 'merchant#checkout', :via => :get  # show checkout form")
  route("  match 'confirm'  => 'veritrans#confirm', :via => :post # pay-confirmation autosubmit to veritrans server")
  route("  match 'cancel'   => 'veritrans#cancel',  :via => :post # canceling transaction redirect back to merchant-web")
  route("  match 'pay'      => 'veritrans#pay',     :via => :post # server to server pay-notification to merchant-web")
  route("  match 'finish'   => 'veritrans#finish',  :via => :post # successfull transaction redirect back to merchant-web")
  route("  match 'error'    => 'veritrans#error',   :via => :post # error transaction redirect back to merchant-web")
  route("namespace :vtlink do")
end