Module: ActiveMerchant::Billing::Integrations::WirecardCheckoutPage::Common

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

Instance Method Summary collapse

Instance Method Details

#messageObject



50
51
52
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/common.rb', line 50

def message
  @message
end

#verify_response(params, secret) ⇒ Object



54
55
56
57
58
59
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
# File 'lib/active_merchant/billing/integrations/wirecard_checkout_page/common.rb', line 54

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