Sha256: b85c237d523e5312ff86129bddd84b5a292a3073b20d18a0f5f09a094fc699b6

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

# encoding: utf-8

module WirecardCheckoutPage
  class ResponseChecksum
    include WirecardCheckoutPage::Utils

    def initialize(params)
      @params = stringify_keys(params)
      unless response_fingerprint_order_parts.include? 'secret'
        raise InvalidResponseFingerPrintOrder, 'Missing :secret as a part of the responseFingerprintOrder'
      end
    end

    attr_reader :params

    def valid?
      params['responseFingerprint'] == computed_fingerprint
    end

    private

    def response_fingerprint_order_parts
      params['responseFingerprintOrder'].to_s.split(',')
    end

    def fingerprint_string
      response_fingerprint_order_parts.map {|key| params[key.to_s] }.join
    end

    def computed_fingerprint
      Digest::MD5.hexdigest fingerprint_string
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wirecard_checkout_page-0.1.0 lib/wirecard_checkout_page/response_checksum.rb