Module: ActiveMerchant::Billing::Integrations::WebPay::Common

Included in:
Helper, Notification
Defined in:
lib/active_merchant/billing/integrations/web_pay/common.rb

Instance Method Summary collapse

Instance Method Details

#generate_signature(type) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/active_merchant/billing/integrations/web_pay/common.rb', line 6

def generate_signature(type)
  string = case type
  when :request
    request_signature_string
  when :notify
    notify_signature_string
  end
  if type != :notify && @fields[mappings[:version]] == '2'
    Digest::SHA1.hexdigest(string)
  else
    Digest::MD5.hexdigest(string)
  end
end

#notify_signature_stringObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/active_merchant/billing/integrations/web_pay/common.rb', line 32

def notify_signature_string
  [
    params['batch_timestamp'],
    params['currency_id'],
    params['amount'],
    params['payment_method'],
    params['order_id'],
    params['site_order_id'],
    params['transaction_id'],
    params['payment_type'],
    params['rrn'],
    secret
  ].join
end

#request_signature_stringObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/active_merchant/billing/integrations/web_pay/common.rb', line 20

def request_signature_string
  [
    @fields[mappings[:seed]],
    @fields[mappings[:account]],
    @fields[mappings[:order]],
    @fields[mappings[:test]],
    @fields[mappings[:currency]],
    @fields[mappings[:amount]],
    secret
  ].join
end