Sha256: d455f4df3f282664f1c1bbfbb2e6b5a1c8744c174f7a56e92a502a8cff33a445
Contents?: true
Size: 937 Bytes
Versions: 1
Compression:
Stored size: 937 Bytes
Contents
class EpayTools::HashCalculatorService < ServicePattern::Service attr_reader :query_parameters, :epay_md5_key def initialize(query_parameters:, epay_md5_key:) @query_parameters = query_parameters @epay_md5_key = epay_md5_key end def execute! ServicePattern::Response.new( result: { calculated_hash: calculated_hash, validated: validated? } ) end private def calculated_hash @_calculated_hash ||= Digest::MD5.hexdigest("#{parameters_to_use.values.join}#{epay_md5_key}") end def parameters_to_use parameters = {} EpayTools::OrderedParameters::ORDERED_PARAMETERS.each do |ordered_parameter| parameters[ordered_parameter] = query_parameters.fetch(ordered_parameter) end parameters end def validated? return false unless query_parameters.key?("hash") return true if calculated_hash == query_parameters.fetch("hash") false end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
epay_tools-0.0.1 | lib/epay_tools/hash_calculator_service.rb |