Module: Payu::Helpers

Defined in:
lib/payu/helpers.rb

Instance Method Summary collapse

Instance Method Details

#payu_hidden_fields(transaction) ⇒ Object

Generates form fields for specified transaction object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/payu/helpers.rb', line 6

def payu_hidden_fields(transaction)
  html = ""

  %w(pos_id pos_auth_key pay_type session_id amount amount_netto desc
  order_id desc2 trsDesc first_name last_name street street_hn
  street_an city post_code country email phone language client_ip
  js payback_login sig ts
  ).each do |field|
    value = transaction.send(field)
    html << hidden_field_tag(field, value) unless value.blank?
  end

  html.html_safe
end

#payu_verify_params(params) ⇒ Object

Verifies signature of passed parameters from Payu request



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/payu/helpers.rb', line 22

def payu_verify_params(params)
  pos_id = params['pos_id']
  pos = Payu[pos_id]

  Signature.verify!(
    params['sig'],
    params['pos_id'],
    params['session_id'],
    params['ts'],
    pos.key2
  )
end