Module: HncbEAtm::ViewHelpers

Includes:
ActionView::Context, ActionView::Helpers
Defined in:
lib/hncb_e_atm/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#hncb_e_atm_form_for(params, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/hncb_e_atm/view_helpers.rb', line 9

def hncb_e_atm_form_for(params, &block)
  query_string = HncbEAtm::Serialization.new(params).serialize
  val = Base64.encode64(query_string)
  mac = Digest::SHA1.hexdigest(query_string).upcase

  html_form = []

  html_form << "<form action='"+HncbEAtm.endpoint+"' method='post'>"
  html_form << "<input type='hidden' name='trx' value='com.eatm.wibc.trx.web.EAtmWShopping'>"
  html_form << "<input type='hidden' name='state' value='prompt'>"
  html_form << "<input type='hidden' name='val' value='#{val}'>"
  html_form << "<input type='hidden' name='mac' value='#{mac}'>"
  html_form << capture(&block) if block_given?
  html_form << "</form>"

  html_form = html_form.join("\n")

  concat(html_form.respond_to?(:html_safe) ? html_form.html_safe : html_form)

  nil
end


31
32
33
34
35
36
37
38
39
40
41
# File 'lib/hncb_e_atm/view_helpers.rb', line 31

def hncb_e_atm_link_for(params)
  query_string = HncbEAtm::Serialization.new(params).serialize
  val = Base64.encode64(query_string)
  mac = Digest::SHA1.hexdigest(query_string).upcase

  html_link = "#{HncbEAtm.endpoint}?trx=com.eatm.wibc.trx.web.EAtmWShopping&state=prompt&val=#{val}&mac=#{mac}"

  concat(html_link.respond_to?(:html_safe) ? html_link.html_safe : html_form)

  nil
end