Module: OffsitePayments::Integrations::WebPay::Common

Included in:
Helper, Notification
Defined in:
lib/offsite_payments/integrations/web_pay.rb

Instance Method Summary collapse

Instance Method Details

#generate_signature(type) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/offsite_payments/integrations/web_pay.rb', line 38

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



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/offsite_payments/integrations/web_pay.rb', line 64

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



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/offsite_payments/integrations/web_pay.rb', line 52

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