Module: OffsitePayments::Integrations::WirecardCheckoutPage::Common

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

Instance Method Summary collapse

Instance Method Details

#messageObject



56
57
58
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 56

def message
  @message
end

#verify_response(params, secret) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/offsite_payments/integrations/wirecard_checkout_page.rb', line 60

def verify_response(params, secret)
  logstr = ''
  params.each { |key, value|
    logstr += "#{key} #{value}\n"
  }

  @paymentstate = 'FAILURE'

  unless params.has_key?('paymentState')
    @message = "paymentState is missing"
    return false
  end

  if params['paymentState'] == 'SUCCESS' || params['paymentState'] == 'PENDING'
    unless params.has_key?('responseFingerprint')
      @message = "responseFingerprint is missing"
      return false
    end

    unless params.has_key?('responseFingerprintOrder')
      @message = "responseFingerprintOrder is missing"
      return false
    end

  end

  if params['paymentState'] == 'SUCCESS' || params['paymentState'] == 'PENDING'
    fields = params['responseFingerprintOrder'].split(",")
    values = ''
    fields.each { |f|
      values += f == 'secret' ? secret : params[f]
    }


    if Digest::MD5.hexdigest(values) != params['responseFingerprint']
      @message = "responseFingerprint verification failed"
      return false
    end
  end

  @paymentstate = params['paymentState']
  true
end